Skip to content
This repository has been archived by the owner on Mar 10, 2019. It is now read-only.

MIDI clock (feature request) #41

Open
erwald opened this issue Sep 3, 2017 · 4 comments
Open

MIDI clock (feature request) #41

erwald opened this issue Sep 3, 2017 · 4 comments

Comments

@erwald
Copy link

erwald commented Sep 3, 2017

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

@lennart
Copy link
Contributor

lennart commented Oct 7, 2017

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

@nsputnik
Copy link

From what I understand midi clock is not channelized. It does not need to be sent on all channels or any channels.

@magwa101
Copy link

Midi sync in Tidal would be awesome. I want to hook tidal up to my DAW as a midi generator.

@yaxu
Copy link
Member

yaxu commented Feb 20, 2018

You can send midi clock from tidal via the in-development superdirt midi support musikinformatik/SuperDirt#68

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants