Hey hey,
I want to record MIDI into a sequencer application, using RtMidi. My
understanding is:
inside that application's tracks events are directly stamped with delta
times, measured in ticks, since the last event in that track. Internally
the sequencer runs a clock at a high rate (480PPQ or higher).
It's probably best to "quantise" events to that internal clock while
they are recorded. So the track object, with its connected MIDI input
device, must be linked to the clock, which will wake up, whenever it is
time for a tick. Linked meaning there must be some way to exchange relevant
info (one of them owning a reference, callback, shared data, ...)
If that basic, and simplified, principle is sound. Which solutions have
been proven feasible to achieve that? For example: make every active
track a thread and have a global mutex? Each track registers a callback
function with the clock to store events. ...?
RtMidi's input object (RtMidiIn) offers to register a callback function,
that will be called with a received MIDI message, when input is
available. Such messages could be stored in a container and be delivered
when it's tick time. -- So again, a track might own a reference to the
Clock thread object and query the current tick count since the last
record start command and use that information to calculate the correct
delta. Not sure though, whether that might raise issues with execution
times. Using an atomic variable as a tick counter will avoid having to
use mutex locks, at least.
Is there any practical advice? Something based on experience? A good
read?
Best wishes and thanks,
Jeanette
--
* Website:
http://juliencoder.de - for summer is a state of sound
* Youtube:
https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
* Audiobombs:
https://www.audiobombs.com/users/jeanette_c
* GitHub:
https://github.com/jeanette-c
But now I'm stronger than yesterday <3
(Britney Spears)