<div dir="ltr"><div>about receiving external clock, I think the goal there is to use the clock to drive the algorithm.</div><div>I wouldn&#39;t try to calculate the BPM if not for just displaying it somewhere.<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, 2 Jul 2019 at 22:17, Michael Heuer &lt;<a href="mailto:heuermh@gmail.com">heuermh@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">All,<br>
<br>
I&#39;m curious how to use MIDI clock effectively in ChucK, in two main use cases:<br>
<br>
>From a sample-rate-based timer in ChucK, how should I send out MIDI clock?<br>
<br>
while (true) {<br>
  10::ms =&gt; now;<br>
  // send MIDI clock<br>
}<br>
<br>
or<br>
<br>
TimeSignature.common(120) @=&gt; TimeSignature ts;<br>
<br>
while (true) {<br>
  ts.e =&gt; now;<br>
  // send MIDI clock<br>
}<br>
<br>
or (this one allows the caller to modify the tempo later)<br>
<br>
TimeSignature.common(120) @=&gt; TimeSignature ts;<br>
ts.eighthProvider() @=&gt; EighthProvider e;<br>
<br>
while (true) {<br>
  e.evaluate() =&gt; now;<br>
  // send MIDI clock<br>
}<br>
<br>
<br>
>From receiving MIDI clock messages from an external source, how should one adjust the BPM in ChucK?<br>
<br>
MidiIn min;<br>
MidiMsg msg;<br>
<br>
TimeSignature.common(120) @=&gt; TimeSignature ts;<br>
<br>
while (min.recv(msg)) {<br>
  // if is clock … {<br>
    /* new BPM */ =&gt; ts.tempo;<br>
  }<br>
}<br>
<br>
I would imagine I would want to window over the last n clock messages to average?<br>
<br>
Thanks in advance,<br>
<br>
   michael<br>
_______________________________________________<br>
chuck-users mailing list<br>
<a href="mailto:chuck-users@lists.cs.princeton.edu" target="_blank">chuck-users@lists.cs.princeton.edu</a><br>
<a href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users" rel="noreferrer" target="_blank">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users</a><br>
</blockquote></div>