[SDL] SDL useful for sound synthesis?
david at olofson.net
Thu Sep 21 11:09:21 PDT 2006
On Thursday 21 September 2006 19:12, Waltzer George wrote:
> I think that's the clasic problem trying to stream anything,
> regardless if audio or video.
Real time sound synthesis is quite different from streaming, in that
you essentially want zero latency. That is, you can't use any
buffering beyond what the audio subsystem needs to avoid glitches, or
you lose the whole point of trying to keep the audio output latency
low in the first place.
> How to do this without clicks and ugly stuff? Use the treading
> posibility of SDL,
> create a thread(there are tutorials about this). You should play
> from within that tread.
I would strongly recommend *not* using any extra threads for low
latency audio on most platforms. It increases the risk of operating
system "coffee breaks" interfering with your audio, and you need
additional buffering between each pair of threads in the chain,
adding to the total latency.
SDL already provides an audio thread on platforms that need it, and
your best bet is to do all audio processing in that thread, that is,
in the context of the callback from SDL audio.
That said, there *are* low latency audio subsystems that use multiple
threads or even processes to great effect (http://jackaudio.org/),
but getting that to work reliably can be hard, if at all possible, on
some platforms. "Don't try this at home!" ;-)
//David Olofson - Programmer, Composer, Open Source Advocate
.------- http://olofson.net - Games, SDL examples -------.
| http://zeespace.net - 2.5D rendering engine |
| http://audiality.org - Music/audio engine |
| http://eel.olofson.net - Real time scripting |
'-- http://www.reologica.se - Rheology instrumentation --'
More information about the SDL