OpenAL - 3D Sound's Volume Problem

Post your questions, suggestions and experiences regarding game design, integration of external libraries here. For irrEdit, irrXML and irrKlang, see the
ambiera forums
Post Reply
freetimecoder
Posts: 226
Joined: Fri Aug 22, 2008 8:50 pm
Contact:

OpenAL - 3D Sound's Volume Problem

Post by freetimecoder »

Hi,

I hope I've posted in the right forum and I hope there is someone who knows what I am talking about.

Simple question: How can I change the volume of a 3D Sound?
A soundengine should be capable of doing so, in fact I have searched for hours, found API-Documentations, people with same problems, but no solution. Gain and Pitch were mentioned several times. This is NOT what I want. Since pitch alters the "speed" of replay and Gain the range of the sound. Not the final or maximum volume.

If I wanted to change a 2D sound, that would be no problem. There I could do it with gain, but not in 3D space.

So in conclusion, i think i have to access and change a source's buffer directly in order to change it's volume. But how do I do that?

hope for help
greetings
FTC
Halifax
Posts: 1424
Joined: Sun Apr 29, 2007 10:40 pm
Location: $9D95

Post by Halifax »

Gain defines an amplitude multiplier, thus representing volume. The valid values for the gain are [0.0,inf] with 1.0 being the default. If you modify the listener's gain, then that will change the global volume, but if you modify a source's gain that will change that respective source's volume.

(By the way, note that an OpenAL implementation can clamp the value you provide to gain to any arbitrary number it chooses.)
TheQuestion = 2B || !2B
freetimecoder
Posts: 226
Joined: Fri Aug 22, 2008 8:50 pm
Contact:

Post by freetimecoder »

Halifax wrote: but if you modify a source's gain that will change that respective source's volume.
And thats exactly what it is not. Thanks anyway.
Setting the Listener's gain, works for global. But alSourcef(Source,AL_GAIN,Gain) with range[0,inf] changes just how far a sound can be heard. Testing different gains when placing the listener besides the source makes no differences in the volume.

greetings
FuzzYspo0N
Posts: 914
Joined: Fri Aug 03, 2007 12:43 pm
Location: South Africa
Contact:

Post by FuzzYspo0N »

OpenAL implementation can clamp the value you provide to gain to any arbitrary number it chooses.
This is something we noticed as well, sometimes a sound will get a value for its gain and internally it got clamped, or cut off and popped back to full gain its weird.
changes just how far a sound can be heard
Err, that is gain. If you play the sound in an external media player (lets say audacity) and it sounds X volume, you can never get it louder than X volume in game. You have to modify the actual audio file if you want it louder.

Its like, max gain + 20, i think. it wont work, because its max gain is determined by the audio itself, as well as the gain in the engine. If the gain is max in the engine, and the sound is not loud enough, use audacity to make it louder.
wildrj
Posts: 301
Joined: Thu Mar 23, 2006 12:49 am
Location: Texas/ Cyberspace
Contact:

Post by wildrj »

Hey if you want to free yourself from the burden of using raw openal. You can use my wrapper cAudio can be found at http://www.deathtouchstudios.com
http://wild.deathtouchstudios.com << My gamedev blog
<Programming is a way of life>
If at first you don't succeed press the delete key till you do :)
freetimecoder
Posts: 226
Joined: Fri Aug 22, 2008 8:50 pm
Contact:

Post by freetimecoder »

FuzzYspo0N wrote:internally it got clamped, or cut off and popped back to full gain its weird.
:shock: Thats indeed weird. Is OpenAL really that bad?
So there is also absoulutley no way to seperate the volume from the maximal distance you can hear it?
(ok execpt I would make all sources relative and set them like i want them)
wildrj wrote:You can use my wrapper cAudio
Thanks, but I already got most of openal wrapped. Additionally, when I tried your wrapper and loaded a wav (which worked with raw openal), it played to fast (with setPitch I was not able to change anything) Also, since your setVolume uses the Gain aswell, this provides no real solution for my problem.

greetings
Post Reply