[Openal-devel] _AL_CUTOFF_ATTENUATION
Ed Phillips
ed at udel.edu
Wed Dec 14 12:14:26 PST 2005
Hi,
On Wed, 14 Dec 2005, Sven Panne wrote:
> The problem with AL_INVERSE_DISTANCE is the jump from +inf to -inf
> around
>
> distance = referenceDistance * ( 1 - 1 / rolloffFactor )
>
> Probably the gain should stay at a maximum float value when the distance
> approaches zero (avoiding a discontinuity), but that is not in the spec.
> Sorry for being so picky sometimes, but I need to know what to do to
> implement it correctly and consistently with other implementations.
>
> For the curious ones, I've attached a gnuplot batch file and a
> PostScript plot showing the effect of the various distance models.
I glad to see a bit of discussion on this...
FWIW, using this stuff in a practical situation, I know I spent several
long nights with gnuplot trying to understand and predict the effect of
the various attenuation schemes while working on the OpenAL support in our
game. I ended up using the regular AL_INVERSE_DISTANCE falloff with a
rolloff value computed to produce -18 dB gain at max distance. For our
sound emitters, we specify ref distance and max distance - with the notion
that ref distance is the "near" distance to the emitter (with gain = 1.0)
and max distance is actually were we want the sound source to be culled
(and at gain = 0.0). So to implement this, we needed to add a function to
attenuate the sound source near max distance by altering the gain as the
listener-to-sound-source distance approaches max distance.
Also, we have toyed with clamping the gain to 1.0 inside the ref
distance... but it hasn't been a big issue with OpenAL v1.1, given how our
camera is limited as to how close it can get to a sound emitter. With
v1.0, the sound definitely got MUCH louder in certain camera views
(listener locations), with the ref distance settings we used to use.
So strictly in a practical sense, I would vote that all of the models
clamp to gain = 1.0 at ref distance or closer. I *thought* I remember
seeing somewhere in OpenAL 1.0 code where it was being clamped to gain =
2.0, but I can't find where. This would account for the LOUD behavior we
saw in close-camera situations before we started using OpenAL 1.1
(actually we're still using a pre-1.1 CVS build at this point, but
eventually... <sigh>... just not enough time in the day...).
Originally, for our game, I tried to compute a rolloff value that would
attenuate to -48 dB (and some other very quiet values) at max distance -
seemed logical, we want the sound to attenuate to close-to-0dB at max
distance, but what ends up happening is that we heard a HUGE drop in
volume of the sound source at only a few units outside of ref distance and
then a large expanse of mostly-inaudible sound until reaching -48 dB at
max distance. Not very workable. But that's exactly what the
inverse-distance model equations do, as designed. The linear models don't
suffer from this, but they don't sound very "natural" either, to my ears
at least.
Cheers,
Ed
Ed Phillips <ed at udel.edu> University of Delaware (302) 831-6082
Systems Programmer III, Network and Systems Services
More information about the Openal-devel
mailing list