[LAD] Deriving a steady MIDI clock crossplatform?

Jeanette C. julien at mail.upb.de
Thu May 19 19:52:33 CEST 2022

Hey hey,
I wonder how would you best derive a steady MIDI clock in software for a cross 
platform application? Cross platform in this case almost certainly means Linux 
and mac.

I know about one or two applications that use the timeofday/sleep mechanism, 
but from first hand experience I know that these tend to drift and wobble. 
This becomes apparent when syncing a synth with clock synced delays to that 
clock. There is a slight chorus effect. Furthermore, subsequent renderings of 
the same song is too much out of sync. Exact re-runs are necessary with 
connected mono timbral instruments that have to contribute several sounds to 
the same song.

I did think about using RtAudio with a very low blocksize. The callback 
function could supply a steady time source at the connected soundcard's 
samplerate (or any subdivision thereof). Is that feasible? Or will some 
function from any of the Boost libraries do? I haven't found the right one 
yet. The Thread library contains its versions of sleep (i.e. sleep_for) and 
other libraries supply all kinds of finely grained time formats. But 
apparently, they too are based on a timeofday based mechanism.

Being new to this kind of task, I am a bit at a loss. So any practical 
pointers and hints are welcome.

Best wishes,


  * 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

If there's nothing missing in my life
Then why do these tears come at night <3
(Britney Spears)

More information about the Linux-audio-dev mailing list