thestk / rtmidi

A set of C++ classes that provide a common API for realtime MIDI input/output across Linux (ALSA & JACK), Macintosh OS X (CoreMIDI) and Windows (Multimedia)
Other
993 stars 275 forks source link

MidiClock out? #112

Open starfishmod opened 7 years ago

starfishmod commented 7 years ago

Is it possible to add a new option to RtMidiOut for midiClock out? e.g.

RtMidiOut *midiout = new RtMidiOut();
midiout->openPort( 0 );
midiout->startClock(120.0); //in BPM
midiout->stopClock();

AFAICT alsa has the ability to set this up with snd_seq_ev_schedule_tick, I have no idea if others have this kind of option.

While I know this can be done using code around the RtMidi API it would good to have some kind of reliable low level solution that is non-blocking with fairly accurate timing.

Thanks for the great work so far!

starfishmod commented 7 years ago

@radarsat1 Any further thoughts on this? I'm willing to put down some cash if this could be done? Thanks Andrew

radarsat1 commented 7 years ago

I think if there is operating system support it makes sense to expose it, I suppose the API should also support some callback method or other for doing local clock-synchronized stuff too. But I don't have time to investigate how it work would right now, especially on other operating systems. It should at least make an effort to be similar on all supported platforms.

starfishmod commented 7 years ago

@radarsat1 if it helps this is based on my research about various midiclock subsystems - NOTE I'm not a c/c++ developer and none of this maybe useful

Windows now has clock built in - https://blogs.windows.com/buildingapps/2016/09/21/midi-enhancements-in-windows-10/#XYBC0JmAzXheiVED.97 has an example on how to write code

ALSA - see the attached file, as an example, it uses internal ALSA handling for clock AFAICT ametro.txt

Jack doesn't seem to have a built in clock generator the closest I can find is http://www.teuton.org/~gabriel/jack_midi_clock/ and https://github.com/x42/jack_midi_clock

CoreMidi - I didn't have much luck with the closest I got was https://github.com/michaeltyson/TheSpectacularSyncEngine/blob/master/TheSpectacularSyncEngine/SEMIDIClockSender.m

both Jack and CoreMidi look like they create their own timers?? If I can help in any other way please let me know