[LAD] Realtime inter-thread communication

Len Ovens len at ovenwerks.net
Mon Feb 29 15:27:45 UTC 2016

On Mon, 29 Feb 2016, Sebastian Gesemann wrote:

> I've started writing a software synthesizer in C++ (using SDL2 for
> now) for kicks and giggles and ran into the problem of having the
> event loop thread that listens for keyboard events communicate with
> the audio callback.
> Are there any recommendations for how to pass real-time events (note
> on, note off, etc) to such an audio callback? I figured, this is
> already a solved problem and that I could benefit from your
> experiences. Maybe you know of some nice open-source C++ queue
> implementation that is suitable in such a situation.

I have used jackd ringbuffer for that.

If you don't want to link against jack you could probably pull the code 
out to use in your application. the ring buffer is a polled setup, so 
every time you do some audio processing you need to check the ring buffer 
to see if there are any new bytes to process.

Len Ovens

More information about the Linux-audio-dev mailing list