I'm seeing timing drift between two processes running cm3 on OSX/Leopard. I'm also seeing the timing drift on Linux that another user reported, but I think this case is unrelated to that one.
<div><br></div><div>Here&#39;s the code:</div><div><br></div><div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">(define (note-cycle endtime keys rate)</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">  (process with pat = (make-cycle keys)</span></div>
<div><span class="Apple-tab-span" style="white-space:pre"><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">        </span></span><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">   while (&lt; (elapsed) endtime)</span></div>
<div><span class="Apple-tab-span" style="white-space:pre"><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">        </span></span><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">   do</span></div>
<div><span class="Apple-tab-span" style="white-space:pre"><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">        </span></span><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">   (send &quot;mp:midi&quot; key: (next pat) dur: rate)</span></div>
<div><span class="Apple-tab-span" style="white-space:pre"><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">        </span></span><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">   (wait rate)))</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;"><br></span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">(let* ((k1 (key &#39;(c4 g4 a4 bf4)))</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">       (k2 (key &#39;(c2 e2 g2 a2 bf2 a2 g2 e2)))</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">       (stop 8000))</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">  (sprout </span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">   (list (note-cycle stop k1 .4)</span></div>
<div><span class="Apple-tab-span" style="white-space:pre"><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">        </span></span><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;"> (note-cycle stop k2 .2))))</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;; font-size: 12px;"><br></span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;; font-size: 12px;"><br></span></div>
<div><span class="Apple-style-span" style="font-size: 12px; "><span class="Apple-style-span" style="font-family: arial, helvetica, sans-serif;">If I define the two time delays to be equal, the processes seem to stay in sync for at least a few minutes. But if I define them as above, they drift apart fairly soon.</span></span></div>
<div><span class="Apple-style-span" style="font-size: 12px;"><br></span></div><div><span class="Apple-style-span" style="font-size: 12px;">I think the reason for this is that there is some overhead in the process that gets added on to the wait time for each iteration. So if the wait time is shorter, the loop executes more often, and the overhead is incurred more often. (The overhead would be everything in the loop apart from the wait time).</span></div>
<div><span class="Apple-style-span" style="font-size: 12px;"><br></span></div><div><span class="Apple-style-span" style="font-size: 12px;">What&#39;s the correct way to fix this? I can think of a way to do it that involves sprouting only a single process, and sending multiple notes each time through the loop, but it gets ugly fast if there are more than a couple of parts/instruments.</span></div>
<div><span class="Apple-style-span" style="font-size: 12px;"><br></span></div><div><span class="Apple-style-span" style="font-size: 12px;">I guess what I want is to wait an amount of time that would bring me to the start of the next beat, but I&#39;m not sure how to express that. I tried the following, but it didn&#39;t help:</span></div>
<div><span class="Apple-style-span" style="font-size: 12px;"><br></span></div><div><span class="Apple-style-span" style="font-size: 12px;"><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">(define (note-cycle endtime keys rate)</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">  (process with pat = (make-cycle keys)</span></div><div><span class="Apple-tab-span" style="white-space:pre"><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">        </span></span><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">   for t = rate by rate</span></div>
<div><span class="Apple-tab-span" style="white-space:pre"><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">        </span></span><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">   while (&lt; (elapsed) endtime)</span></div>
<div><span class="Apple-tab-span" style="white-space:pre"><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">        </span></span><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">   do</span></div>
<div><span class="Apple-tab-span" style="white-space:pre"><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">        </span></span><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">   (send &quot;mp:midi&quot; key: (next pat) dur: rate)</span></div>
<div><span class="Apple-tab-span" style="white-space:pre"><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">        </span></span><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">   (wait (- t (elapsed)))))</span></div>
</span></div><div><span class="Apple-style-span" style="font-size: 12px;"><br></span></div><div><span class="Apple-style-span" style="font-size: 12px;">(I was attempting to pre-compute the value of &quot;elapsed&quot; at the start of the next iteration.)</span></div>
<div><span class="Apple-style-span" style="font-size: 12px;"><br></span></div><div><span class="Apple-style-span" style="font-size: 12px;">Basically I&#39;m wanting to have one process run at an exact multiple of the speed of another.</span></div>
<div><span class="Apple-style-span" style="font-size: 12px;"><br></span></div><div><span class="Apple-style-span" style="font-size: 12px;">Neil</span></div></div>