<div dir="ltr"><div>I think it&#39;s customary to wait on a midi event instead of regular pauses, like:<br><br></div>min =&gt; now;<br><pre>while( min.recv( msg ) )<br>(...)<br><span style="font-family:arial,helvetica,sans-serif"><br></span></pre><pre><span style="font-family:arial,helvetica,sans-serif">Check out the midi section in the docs:<br><a href="http://chuck.cs.princeton.edu/doc/language/event.html#midi">http://chuck.cs.princeton.edu/doc/language/event.html#midi</a><br></span><br></pre><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Oct 23, 2014 at 3:59 AM, Peter Lutek <span dir="ltr">&lt;<a href="mailto:peter@peterlutek.com" target="_blank">peter@peterlutek.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 2014-10-22 13:12, Moisés Gabriel Cachay Tello wrote:<br>
</span><span class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
In order to advance &#39;now&#39; and make it eventually equal or higher than<br>
&#39;later&#39; you should put inside your loop something like:<br>
<br>
now + 5::second =&gt; time later;<br>
while(now &lt; later) {<br>
  ...<br>
  1::second =&gt; now;<br>
}<br>
</blockquote>
<br></span>
ok, so now it works sometimes, but other times ChucK crashes, with this error:<br>
chuck: pthread_mutex_lock.c:62: __pthread_mutex_lock: Assertion `mutex-&gt;__data.__owner == 0&#39; failed.<br>
<br>
any clues?<br>
<br>
here&#39;s the code, as it stands:<br>
<br>
/////////<br>
<br>
// set up MIDI<br>
MidiIn min;<br>
MidiOut mout;<br>
MidiMsg msgin;<br>
MidiMsg msgout;<br>
<br>
// connect to port 1 and print result<br>
&lt;&lt;&lt;&quot;&quot;,&quot;&quot;&gt;&gt;&gt;;<br>
&lt;&lt;&lt;&quot;MIDI-in then MIDI-out:&quot;,&quot;&quot;&gt;&gt;&gt;;<br>
&lt;&lt;&lt; min.open(1),&quot;&quot; &gt;&gt;&gt;;<br>
&lt;&lt;&lt; mout.open(1),&quot;&quot; &gt;&gt;&gt;;<br>
&lt;&lt;&lt;&quot;&quot;,&quot;&quot;&gt;&gt;&gt;;<br>
<br>
dur beat;<br>
<br>
now + 30::second =&gt; time later;<br>
while( now &lt; later ){<br>
       if( min.recv(msgin) ){<span class=""><br>
                  ( msgin.data3 + 10 ) * 50::ms =&gt; beat;<br>
                  &lt;&lt;&lt;beat&gt;&gt;&gt;;<br>
              }<br></span>
              50::ms =&gt; now;<br>
}<br>
&lt;&lt;&lt;&quot;done&quot;&gt;&gt;&gt;;<br>
<br>
//////////<br>
<br>
thanks for any help... cheers!<div class="HOEnZb"><div class="h5"><br>
.pltk.<br>
<br>
<br>
-- <br>
Peter Lutek<br>
improvising musician in Toronto, Canada<br>
<a href="http://peterlutek.com" target="_blank">http://peterlutek.com</a><br>
______________________________<u></u>_________________<br>
chuck-users mailing list<br>
<a href="mailto:chuck-users@lists.cs.princeton.edu" target="_blank">chuck-users@lists.cs.<u></u>princeton.edu</a><br>
<a href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users" target="_blank">https://lists.cs.princeton.<u></u>edu/mailman/listinfo/chuck-<u></u>users</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Release me, insect, or I will destroy the Cosmos!
</div>