<br><br><div class="gmail_quote">On Wed, Apr 8, 2009 at 9:02 AM, Heinrich Taube <span dir="ltr">&lt;<a href="mailto:taube@uiuc.edu">taube@uiuc.edu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
this might do it, at least it sounds better in chicken. the problem is that it may screw up other things<div class="im"><br>
<br>
<br>
            else<br>
             {<br>
                double after=Time::getMillisecondCounterHiRes();<br></div>
                delta*=1000.0; // convert user&#39;s wait value to milliseconds<br>
                delta-=(after-curtime); // subtract out scheme&#39;s overhead<br>
                //time=(delta&gt;0.0) ? (after+delta) : after;<br>
                time=(delta&gt;0.0) ? (curtime+delta) : curtime;<br>
              }<br>
</blockquote></div><br><br clear="all">Rick,
<div><br></div><div>I applied this patch (with Chicken 3.4.0) and it seems to work. I listened for many minutes and couldn&#39;t detect the phase drifting between the two processes.</div><div><br></div><div>I&#39;m using this process:</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;">   for t from 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>
<div><br></div><div>With your patch and the original process that doesn&#39;t attempt to compensate for the overhead, I still saw phase drift, although it may have taken longer to become apparent:</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><br></div><div>Thanks,</div><div><br></div><div>Neil</div></div><div><br></div></div>