[LAD] making sense of Jack MIDI; or, is this an appropriate use for Jack?
pedro.lopez.cabanillas at gmail.com
Fri Feb 15 19:15:09 UTC 2013
I'm not going to comment your whole message, only this little bit:
On Friday 15 February 2013 13:33:48 M Donalies wrote:
> 2) Jack let's me know what time it is through a callback.
It does. As a frame position within the audio stream. It depends on the sample
rate of the audio stream, you know: 44.1/48 kHz. Your callback will be
invoked by Jack not 48000 times in one second, but once each jack period,
which depends on an user setting. The period size is usually quite small,
because Jack users want "low latency" even when watching YouTube videos.
As a musician, you are used to time units like bars and beats, which only make
sense in relation to tempo. Songs may occasionally change the tempo and
rhythm: prepare yourself to make calculations in frames for each MIDI event,
and don't deliver the events until the right callback with the right frame
count has arrived.
You need to be careful to avoid invoking directly or indirectly any GUI widget
methods from your callback, because it is executed in a real-time thread. You
shouldn't call any blocking API functions, like allocating memory. You may
enjoy some other nice restrictions that I am too relaxed to think about it at
The real fun starts if you want to provide your users with the ability to set
a playback tempo scale, with controls allowing to play slower or faster while
the playback is already running (this was a common functionality among MIDI-
only sequencers, do you remember Cakewalk?), or syncing time and tempo to an
You may want to pay this price for the advantage of playing audio and MIDI at
once, with MIDI events placed at frame-accurate instants including the events
delivered to MIDI soft synths. If you don't care, and your MIDI events are
usually sent to MIDI hardware devices, you may want to think twice about it.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Linux-audio-dev