OpenAL - AL_MAX_DISTANCE

I can’t find an example online and it just won’t work for me. It doesn’t seem have any effect.

Anyone have a clue?

alSourcef(sourceId, AL_MAX_DISTANCE, range);

AL_MAX_DISTANCE and 3D effects in general, only work for MONO sources, think about it.

For further reading:

Riven’s point is good, but make sure your distance model is set up too.

The best distance model (that just werkz) is AL_LINEAR_DISTANCE_CLAMPED, set it like this:

alDistanceModel(AL_LINEAR_DISTANCE_CLAMPED);

IRC this is supposed to be the default according to the specification, but when I was working with AL, it didn’t work until I set it manually.

If it still doesn’t work, check the following things:

  • reference distance makes sense (the minimum distance you can be away before the sound starts fading/needs to be smaller than max distance)
  • rolloff is 1f
  • listener gain is between 0f and 1f (1f seems to cancel out attenuation, and 0f is obvious)

I’m a novice with OpenAL, but I wanted to help out since I have a bit of experience with it and there’s not a lot of resources online for getting it going. If I got something wrong I’m more than interested in being corrected.

I figured it out and had forgotten about this post.

@SkyAphid I think that was the issue. I don’t remember

Thanks guys.