[chuck-users] how to use MIDI clock in ChucK

Michael Heuer heuermh at gmail.com
Tue Jul 2 17:17:14 EDT 2019


All,

I'm curious how to use MIDI clock effectively in ChucK, in two main use cases:

From a sample-rate-based timer in ChucK, how should I send out MIDI clock?

while (true) {
  10::ms => now;
  // send MIDI clock
}

or

TimeSignature.common(120) @=> TimeSignature ts;

while (true) {
  ts.e => now;
  // send MIDI clock
}

or (this one allows the caller to modify the tempo later)

TimeSignature.common(120) @=> TimeSignature ts;
ts.eighthProvider() @=> EighthProvider e;

while (true) {
  e.evaluate() => now;
  // send MIDI clock
}


From receiving MIDI clock messages from an external source, how should one adjust the BPM in ChucK?

MidiIn min;
MidiMsg msg;

TimeSignature.common(120) @=> TimeSignature ts;

while (min.recv(msg)) {
  // if is clock … {
    /* new BPM */ => ts.tempo;
  }
}

I would imagine I would want to window over the last n clock messages to average?

Thanks in advance,

   michael


More information about the chuck-users mailing list