[Openal] Playing multiple sounds
chris.kcat at gmail.com
Tue May 1 19:32:20 PDT 2007
On Tuesday 01 May 2007 06:27:19 pm Ben Martin wrote:
> I am working on a game using OpenAL and OGGVorbis with about 50
> different sounds. Several of these sounds can be played simultaneously
> at any given time. In my first implementation, I was creating several
> OpenAL contexts and I was assigning the sounds to be played to each
> "player" using round robin. I know this is a very poor implementation so
> I want to redo it using multiple sources instead of contexts.
> Most examples I found either have only 1 source or each source is
> associated with only one sound buffer. I don't want to create 50 sources
> as I think this can cause problems with some systems (correct me if I'm
To play a sound, you must have a source object. Whether you have 1 context
with 50 sources, or 50 contexts with 1 source each. A sound is played from a
source, and heard by a listener.
Basically think of it as:
Buffer = what's played
Source = how/where it's played
Listener/context = how/where it's heard
Moving the listener 5 units to the right would be the same as moving the
source 5 units to the left (assuming AL_SOURCE_RELATIVE is false).
A single buffer can be attached to multiple sources, so for instance, if you
have an explosion sound effect, you can have multiple sources playing an
explosion all at different places and times, but only need the sound loaded
in one buffer, and heard by one listener (the "camera").
Hope this helps.
More information about the Openal