[alsa-devel] how to handle buffer underrun in a softsynth
Henning Thielemann
alsa at henning-thielemann.de
Mon Nov 28 17:06:03 CET 2011
I have written a software synthesizer in Haskell that fetches MIDI events
from ALSA sequencer and plays the rendered signal via ALSA pcm. However it
cannot cope correctly with buffer underruns.
I tried to learn the correct way from the miniFMsynth example of
http://alsamodular.sourceforge.net/alsa_programming_howto.html
however this program floods my terminal with buffer underrun messages
without even being connected to any MIDI event source. This is independent
from how large I choose the BUFSIZE constant.
I use:
$ pkg-config --modversion alsa
1.0.14
Also, as far as I understand, that program allows to start notes only at
block boundaries. This way it can ignore the timestamps of the incoming
events. But this is crucial for me: I want to allow large blocksizes
and thus I must allow notes to start anywhere inside a block.
Now when I detect a buffer underrun on writing a block to an ALSA pcm
sink, I like to know the time gap in order to adjust the timestamps of the
incoming MIDI events.
My question in short is: Is there an example software synthesizer as
simple as miniFMsynth, that works (on my machine), supports note start
within a block and copes with buffer underruns in a reasonable way? If no
working example, is there some documentation on how this is intended to
work?
Thank you for your help
Henning
More information about the Alsa-devel
mailing list