On 21/12/2007, <b class="gmail_sendername">Julien Canet</b> &lt;<a href="mailto:jools@free.fr">jools@free.fr</a>&gt; wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br><br>Thanks for your interest on the subject and your answers.</blockquote><div><br>I think a lot of people would be interested in this, it would help a lot in integrating ChucK with other (consumer) programs and tools.
<br><br>&nbsp;</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Now with Kassen explanations I have an idea why it is not implemented<br>(&quot;The actual clock message -according to the specs- is very high
<br><br>priority and can interrupt another message which will then continue<br><br>after the clock byte&quot;...losing sync etc).</blockquote><div><br>I don&#39;t think this will lead to lost sync, in fact if it is implemented according to those specs it should be easier to keep sync. What it does need is a sort of small stack to keep yet unfinished messages. Let me explain by pretending to be a MIDI module.
<br><br>I receive the first byte of a note on message, it says it&#39;s a note on channel 3.<br>I receive a clock tick.<br>&nbsp;&nbsp;&nbsp; Now I have to put the note-on byte on my stack <br>&nbsp;&nbsp;&nbsp; and process the tick<br>&nbsp;&nbsp;&nbsp; put the note-on back where it was.
<br>I receive the note number (C4)<br>I receive the velocity (107)<br>&nbsp;&nbsp;&nbsp; Now I have all three bytes to construct a note on<br>&nbsp;&nbsp;&nbsp; I process it.<br>&nbsp;<br>No sync is lost but it&#39;s definitely a bit more complicated then only taking note and cc messages and sending off a block of three bytes every time we have a complete one.
<br><br>One of the advantages of the current -simple- MIDI implementation is that we never have to figure out how many bytes there are in the input signal as it&#39;s always 3, this makes it easy to use and protects us from how arbitrary and flat out weird MIDI can be.
<br><br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">I do not have a high CPU usage in chuck. And<br>with my test I think I keep the MIDI sync.
<br>I guess I have to modify the lex + yacc parser to add<br>MidIn::ignoreTypes recognition in ChucK language.</blockquote><div><br>You don&#39;t? Well, maybe I&#39;m just a bit paranoid about high-speed loops. How much processing are you applying to the clock? Just figuring out where the quarter notes are or something more complicated?
<br>&nbsp;</div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">I also love the idea of<br><br>&quot;Because of this I think it&#39;s worthy of consideration to make a
<br>separate MidiClockIn (and out?) class that would send events named<br>after notes (and tick, possibly) and do the smoothing for us as well<br>as provide start/stop and reset and take advantage of the higher<br>degree of optimisation in C. &quot;
<br><br><br>But I think it is better but harder to implement (at least too hard for me...).</blockquote><div><br>Oh, the C part would definitely be more complicated in that scenario but OTOH it would save complexity at the ChucK-side. I&#39;m suggesting this because a larger ChucK program that would be synced to MIDI and base the amount of time it advances in various shreds on it might run into sync and internal synchronisation issues if there would be a lot of jitter. Perhaps we could work around that by basing it all on events generated by a shred that parses the clock, I never tried that as I never had clock :¬)
<br>&nbsp;</div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">I would like to try (I say try because I am not deep into ChucK code)<br>to modify chuck to accept 
midiIn.ignoreTypes; if I succeed, I will<br>post my changes in code to see if it is agree to commit them.<br><br>Who is still developing on ChucK code?</blockquote><div><br><br>Mainly Ge, I think? It seems like he has been very busy since moving; I haven&#39;t heard from him in a while. It&#39;d also be good to merge the ASIO stuff into the main Win release, now that we know it works and is stable, I haven&#39;t heard a single complaint about that one.
<br></div><br>&nbsp;Looks to me like your investigation is very worthwhile, I&#39;d love to hear how using clock in ChucK works out for you in practice. Has anybody ever tried if we can already use clock-out by ending the message with dummy bytes like we can with program-change? I seem to remember there was a issue there too yet I&#39;m quite interested in that functionality as well.
<br><br>Yours,<br>Kas.<br></div>