Skip to main content
GameDev.net gamedev.net
🔒 Locked

OpenAL Attenuation

Started by wioneo Aug 10, 2010 at 12:58 AM 2 replies 6.7k views
Original Post
wioneo
wioneo
Using "alSourcei(source, AL_REFERENCE_DISTANCE, 10);" should make it so that whenever the source is closer than 10 units to the listener it will play at full volume correct? and with "alSourcef(dest_source, AL_MAX_DISTANCE, 20);" the source should not be heard farther than 20 units right? So a source that is 15 units away after those two calls should play with a gain of 0.5, correct?

For some reason, it seems like for me changing "AL_REFERENCE_DISTANCE" has no effect at all, and "AL_MAX_DISTANCE" plays the sound at what I assume is full volume with a value of 1, and nearly inaudibly with a value of 1000 and my speakers turned all the way up. Shouldn't the opposite be happening? The source position is about 850 units away from the listener while I'm testing, and I set the listener orientation as "{0,0,0, 0,0,0}" hoping to make sound play based solely on distance.

Also, is it possible to return the gain value that a source is playing at? It would be useful to be able to judge differences without human error.
Arvydas
Arvydas
Check if you are using single-channel sounds. OpenAL attenuation doesn't work with stereo sounds.
Ohforf sake
Ohforf sake
What kind of attenuation model are you using?
AFAIK, not all of them actually use AL_MAX_DISTANCE and AL_REFERENCE_DISTANCE.

See http://connect.creativelabs.com/openal/Documentation/OpenAL%201.1%20Specification.htm Section "3.4. Attenuation By Distance" for details.

I think what you want is "Linear Distance Clamped Model".
wioneo
wioneo
OpenAL tells me that the buffer has one channel so I'm assuming that emans it's mono?

Thank you very much that makes the change based on distance easily noticeable, but I'm wondering why the default mode was acting so strangely...based on the graphs on the specs page it makes sense for the dropoff to be sharper but not backwards...

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.