[Openal] Positive Gain on Listener

Jason Daly jdaly at ist.ucf.edu
Mon Jul 9 15:04:38 PDT 2007


Paul Wilkinson wrote:
> I'm writing a mixer that will play several sounds through a single 
> OpenAL source.
>
> If I mix all of my sounds through a single OpenAL source, will this be 
> quieter than playing each sound through a different source? Presumably 
> the volume needs to be scaled down in order to allow multiple sounds 
> without clipping - how is the volume scaled? By a fixed factor?
>
> What's the best way to get full volume out of a single source? I tried 
> playing turning up the gain on the listener, but it had no effect.


In general, if your source is at 0, 0, 0, your listener is at 0, 0, 0, 
your source gain is 1.0 and your listener gain is 1.0, you'll get the 
full volume of your buffer out of the source you play it through.  You 
can also set the distance model to NONE to disable distance attenuation 
and take the source/listener positions out of the equation.

Also, in general, when dealing with sound, 1+1=1.  That is, if you add 
the samples of one sound to that of another, you'll get a mixed sound of 
about the same gain.  You do have to check the arithmetic, and clip any 
sums that would exceed the maximum or minimum, but this won't happen as 
often as you might think.  One thing to note, though, if you're dealing 
with 8-bit data, it's normally stored unsigned (0 - 255 instead of -128 
- 127), so you'll have to subtract 128 from each sample before doing the 
mixing, and then add it back when you're done.

Finally, if you let us know which OS and OpenAL implementation you're 
using, we might be able to give you more specific answers.

-- 

--"J"

"I'm a castaway stranded in a desolate land,
 I can see the footprints in the virtual sand."
	--Neil Peart



More information about the Openal mailing list