<html><body><div style="color:#000; background-color:#fff; font-family:arial, helvetica, sans-serif;font-size:10pt"><div><span>All 3 replies were spot-on, thanks very much.  Tom Lieber, your suggestion works perfectly for my application, verbatim.  Thanks guys, this list is fantastic!  Loving ChucK.</span></div><div><br><span></span></div><div><span>-crwicks<br></span></div><div><br></div>  <div style="font-family: arial, helvetica, sans-serif; font-size: 10pt;"> <div style="font-family: times new roman, new york, times, serif; font-size: 12pt;"> <div dir="ltr"> <font size="2" face="Arial"> <hr size="1">  <b><span style="font-weight:bold;">From:</span></b> Tom Lieber <tom@alltom.com><br> <b><span style="font-weight: bold;">To:</span></b> [chriswicks] <crwicks@yahoo.com>; ChucK Users Mailing List <chuck-users@lists.cs.princeton.edu> <br> <b><span style="font-weight: bold;">Sent:</span></b> Thursday, May 3, 2012 11:08
 AM<br> <b><span style="font-weight: bold;">Subject:</span></b> Re: [chuck-users] coordinating rhythmic timing with unpredictable OSC events<br> </font> </div> <br>
On Thu, May 3, 2012 at 10:54 AM, [chriswicks] <<a ymailto="mailto:crwicks@yahoo.com" href="mailto:crwicks@yahoo.com">crwicks@yahoo.com</a>> wrote:<br>> Hello all!  I'm quite new to ChucK, and I have a question concerning<br>> rhythmic timing.  I've got a program that I'm working on that accepts OSC<br>> events being sent from a C++ application.  Now, the program chugs along,<br>> it's quite rhytmic, and I'd like to trigger melodic shreds based on values<br>> sent through OSC.  No problem doing that.  My problem comes from the fact<br>> that the C++ app isn't in sync with the ChucK VM, so the times at which it<br>> chooses to send data are pretty much never in sync with everything else<br>> that's going on, so the melodic shred is triggered but is not lined up<br>> rhythmically with everything else that's going on.<br>><br>> Is there any way to hack it so that it waits to add the shred until
 it's<br>> lined up with everything else (quantized, so to speak).  I'm not sure if I'm<br>> properly expressing the problem, so let me know if there's some way I can<br>> further clarify.<br><br>Simplest way is to prepend your shreds with synchronization code like this:<br><br>  second / 2 => dur beat;<br>  beat - (now % beat) => now;<br><br>If your tempo varies, you might need an object that sends 'beat'<br>events and you could wait to receive one of those at the start of the<br>shred instead.<br><br>-- <br>Tom Lieber<br>http://AllTom.com/<br>http://infinite-sketchpad.com/<br><br><br> </div> </div>  </div></body></html>