The only thing it's not clear to me is the your use case.
The problem I've always found with ext clocks (HW especially but not only) is the accuracy. All the HW machines I've tested are inaccurate to a certain degree. But usually what you do as a user is to use the MIDI clock as a trigger for the slave machine and at this point the inaccuracy doesn't matter anymore since all is in sync.
But in your case you said:
> "then I can adjust the BPM in the TimeSignature class as it is running"
Can you expand a bit on this?
Would like to receive a clock and decide when and whether to sync to it?

On Tue, 2 Jul 2019 at 23:09, Michael Heuer <heuermh@gmail.com> wrote:
The tempo in BPM is what drives the TimeSignature class in LicK, for example a 4/4 kick drum

RolandTr808 rolandTr808;
TimeSignature.common(120) @=> TimeSignature ts;
ts.quarterProvider() @=> QuarterProvider q;

spork ~ Loops.loop(rolandTr808.kickE, q).run();

// wait a minute, then change the tempo to 110 BPM
1::minute => now;
110 => ts.tempo;

// wait another minute, then decelerate the tempo by 0.8 over the next 30 seconds
1::minute => now;
spork ~ ts.decel(0.8, 30::second);

etc.

If I can calculate the BPM from external clock, then I can adjust the BPM in the TimeSignature class as it is running.

   michael


On Jul 2, 2019, at 4:37 PM, Mario Buoninfante <mario.buoninfante@gmail.com> wrote:

about receiving external clock, I think the goal there is to use the clock to drive the algorithm.
I wouldn't try to calculate the BPM if not for just displaying it somewhere.

On Tue, 2 Jul 2019 at 22:17, Michael Heuer <heuermh@gmail.com> wrote:
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
_______________________________________________
chuck-users mailing list
chuck-users@lists.cs.princeton.edu
https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
_______________________________________________
chuck-users mailing list
chuck-users@lists.cs.princeton.edu
https://lists.cs.princeton.edu/mailman/listinfo/chuck-users

_______________________________________________
chuck-users mailing list
chuck-users@lists.cs.princeton.edu
https://lists.cs.princeton.edu/mailman/listinfo/chuck-users