View Full Version : [OpenAL] Maximum distance at which sound can be heard

29-07-2008, 06:35 PM
How exactly do i set the max distance at which the sound can be heard? i checked out AL_MAX_DISTANCE, but the default constant for that is max float which makes little sense to me, i just want to make the sound play in 1:1 gain at distance up to 1, and then fade out completely at distance of 2, how is this stuff set up in openal?

30-07-2008, 05:07 PM
Look at the following functions:

0 is not heard
1 is no attenuation
values between 0..1 give attenuation

Also use SetDistanceModel to set the proper distance model.
Bypasses distance attenuation for all sound sources.

Inverse distance attenuation described by the following formula:

Gain = ReferenceDistance / (ReferenceDistance + RolloffFactor * (Distance ReferenceDistance)

Essentially the InverseDistance model extended to guarantee that for distances below the ReferenceDistance, gain is clamped.

But there is more:

Do have a read on the manual that comes with the creative sdk. That is better capeable of explaining this.

13-11-2019, 08:19 PM
For the record, solution is:

1. use a proper distance model.


2. sources need AL_MAX_DISTANCE - you can also add AL_REFERENCE_DISTANCE and AL_ROLLOFF_FACTOR for good measure to have better effects.

3. AL_ORIENTATION must be correctly set on listener!!

Yes, i'm replying to my own thread from 2008, i only now correctly solved this properly.

15-11-2019, 02:41 PM
Yes, i'm replying to my own thread from 2008, i only now correctly solved this properly.

There is nothing wrong about this. Your answer may help others to spend so much time looking for correct solution as you did ;)

15-11-2019, 07:54 PM
Exactly :) this thread actually popped up in google when searching, so i hope it helps someone.

28-11-2019, 05:26 PM
Thank you for sharing the solution after all these years, it helped my friend !

Mini Militia (https://www.minimilitia.mobi/) App Lock (https://www.applock.ooo/) 7Zip (https://www.7zip.vip/)