[Openal] OpenAL useful for sound synthesis??

Garin Hiebert garinh at cheesetoast.net
Thu Sep 21 13:11:04 PDT 2006


>  I will be calculating a few milliseconds of sound samples at a time 
> and playing these as soon as they get processed.
>
> I just have to make sure that everything is real-time and sounds 
> continuous and that there are no clicks or anything between samples.

OpenAL can be used to play your stream of samples using its buffer 
queuing mechanism -- you'd set up a single source for playback and then 
queue a series of small buffers on the source.  A few things to watch 
out for:

1)  The format of the data for input and output -- if you are 
synthesizing mono data, you probably won't have a problem.  If you are 
synthesizing something other than mono data (stereo, 5.1, etc.), then 
how the implementation handles that data may be 
implementation-dependent.  Stereo data in an OpenAL 1.1 implementation 
is played without modification (no 3D spatialization).  Mono data is 
played with 3D spatialization, although you are free to place the source 
and listener on top of one another of course.

2)  If you're streaming data and you want the playback to be continuous, 
the application does of course have to be able to supply the synthesized 
data in real time -- there's no way for OpenAL to be glitch-free if it's 
starved of data.

Other cross-platform audio libraries which may be worth considering for 
your application:

    PortAudio -- http://www.portaudio.com/
    SDL -- http://www.libsdl.org/index.php

Garin



More information about the Openal mailing list