Re: [LAD] making sense of Jack MIDI; or, is this an appropriate use for Jack?

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: M Donalies <ingeniousnebbish@...>
Cc: <linux-audio-dev@...>
Date: Friday, February 15, 2013 - 7:15 pm

--nextPart1509075.BFZR8oHLrC
Content-Transfer-Encoding: 7Bit
Content-Type: text/plain; charset="us-ascii"

I'm not going to comment your whole message, only this little bit:

On Friday 15 February 2013 13:33:48 M Donalies wrote:

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
this moment.

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
external master.

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.

Regards,
Pedro

--nextPart1509075.BFZR8oHLrC
Content-Transfer-Encoding: 7Bit
Content-Type: text/html; charset="us-ascii"

p, li { white-space: pre-wrap; }

 
I'm not going to comment your whole message, only this little bit:
 
On Friday 15 February 2013 13:33:48 M Donalies wrote:

 
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 this moment.
 
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 external master.
 
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.
 
Regards,
Pedro
 
--nextPart1509075.BFZR8oHLrC--

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [LAD] making sense of Jack MIDI; or, is this an appropri..., Pedro Lopez-Cabanillas, (Fri Feb 15, 5:53 pm)
Re: [LAD] making sense of Jack MIDI; or, is this an appropri..., Pedro Lopez-Cabanillas, (Sat Feb 16, 12:16 pm)
Re: [LAD] making sense of Jack MIDI; or, is this an appropri..., Pedro Lopez-Cabanillas, (Sat Feb 16, 5:22 pm)
Re: [LAD] making sense of Jack MIDI; or, is this an appropri..., Pedro Lopez-Cabanillas, (Sat Feb 16, 9:39 am)
Re: [LAD] making sense of Jack MIDI; or, is this an appropri..., Pedro Lopez-Cabanillas, (Sat Feb 16, 10:03 am)
Re: [LAD] making sense of Jack MIDI; or, is this an appropri..., Pedro Lopez-Cabanillas, (Sat Feb 16, 11:03 am)
Re: [LAD] making sense of Jack MIDI; or, is this an appropri..., Pedro Lopez-Cabanillas, (Fri Feb 15, 7:15 pm)