Open erwald opened 7 years ago
You are right, MIDI clock is not in yet.
I think the place where MIDI-Clock messages have to be sent is in flushBackend
https://github.com/tidalcycles/tidal-midi/blob/1.0-dev/Sound/Tidal/MIDI/Output.hs#L140
The underlying bindings to portMIDI require us to make sure all MIDI messages have strictly monotonic timestamps, otherwise messages are dropped (which leads to glitches and or hanging notes).
You would have to find out the current tempo and send midi clock messages along with the rest of the (normal) midi messages, I guess.
If I understand how MIDI-Clock works, it is essentially a special message sent 24 times per quarter note on all MIDI channels (NOTE: quarter notes have no real meaning in Tidal, so we just stick to beat).
The message would need to be constructed for each channel via makeEvent
(https://github.com/tidalcycles/tidal-midi/blob/1.0-dev/Sound/Tidal/MIDI/Output.hs#L140) with a status of 0xF8
.
Tempo in Tidal is given in cps
(cycles per second), playing note "a"
with cps 1
should be effectively 60bpm.
Currently (this is subject to change) Tidal ticks (schedules events) 8
times per cycle, so given cps 1
this would mean: every tick you have to send out 3 MIDI-Clock messages (24 per beat / 8 ticks per beat) spaced evenly across the tick (The time between this tick and the next).
Please bear with me if I made glaring mistakes in the above calculation, but I hope this helps you get started if you are interested in implementing this.
kindly,
Lennart
From what I understand midi clock is not channelized. It does not need to be sent on all channels or any channels.
Midi sync in Tidal would be awesome. I want to hook tidal up to my DAW as a midi generator.
You can send midi clock from tidal via the in-development superdirt midi support https://github.com/musikinformatik/SuperDirt/issues/68
First of all, thanks for this library; it's great!
I have a couple of synthesisers as well as a drum machine, and want to use Tidal to send MIDI notes to the synths and keep the drum machine in sync with those (but sequencing the drums on the machine itself).
As far as I'm able to tell (correct me if I'm wrong!), this isn't currently possible with tidal-midi. If that's the case, consider this a feature request. If anyone can provide me with some advice on how to get started implementing it, I'd be happy to give it a shot.
Cheers