Attenuation By Distance
From DmWiki
A basic definition of attenuation is the reduction in strength of a signal, so attenuation by distance describes the reduction in sound volume based in the distance to the listener.
Attenuation is used in games to give an impression of a 3D world. Without attenuation, all samples in the game would be played at the same volume, meaning the little bumble bee hovering around a plant would play at the same volume as a nuclear explosion.
In most cases, attenuation is calculated in one of two ways (though various sound API's have differing models, these are the two most common.
| Table of contents |
Minimum and Maximum Distance
At the heart of all attenuation models, there are minimum and maximum distances. It is these distances that give the impression of increasing and decreasing sound.
Minimum distance is the easiest to understand. This states that at all distances shorter than the minimum distance, no attenuation will take place. This means that the sample will play at full volume whenever the player is less than the minimum distance away from the source.
Maximum distance is a bit more complicated, as it can mean different things according to different API's. In one case, Maximum distance means the point in which attenuation will no longer take place. To explain this in more detail, imagine the player is moving away from a source. The volume is attenuating, and has reached a relative volume of 0.4f (where the range is 1.0 to 0.0) by the time they reach the maximum distance. In this case, the sound will no longer attenuate, so from now on, the relative volume will be 0.4f no matter how far away from the source the player gets.
In another case, maximum distance can mean the point in which the sample reaches a relative volume of 0.0. This is rarely used, as it doesn't account for real life situations.
Roll Off Factor
A roll off factor decides how fast the sound attenuates. By default, most API's set the roll of factor to 1.0, meaning a sound will attenuate at a 'decent' rate. Increasing the roll off factor means the sound will attenuate faster. For example, a roll of rate of 2.0 means the rate of attenuation is double the normal rate. A rate of 0.5 means attenuation occurs twice as slowly.
Roll Off Factors are usually applied to Quadratic based attenuation models, as they relate directly to the curve of the attenuation graph (more on this below). Roll off rates can be applied to linear attenuation models, but that is rarely done.
Inverse Distance Fall Off Models
Attenuation based on inverse distance is one of the most common, as it is based on a real life model. Unfortunately, it can be difficult to understand and get right.
The "inverse square law" used in physics applies to sound intensity (energy), which is proportional to the square of linear gain (amplitude). Thus the inverse distance model describes a physically correct inverse square behavior if ROLLOFF_FACTOR is set to 1.0.
A basic inverse distance works on the principle that as the distance between the position and the previous position doubles, the sound halves in volume. So, the sound is at full volume when it is 1 meter away from the listener, at half volume at 2 meters, at quarter volume at 4 meters, and so on.
The rate of drop off will be tied directly to the minimum and maximum distance (remember, there is no attenuation before the minimum distance). The larger the minimum distance for the source, the smaller the rate of attenuation (before fall off rate is applied). As the sound approaches the maximum distance, it will continue to attenuate. Go past the maximum distance, and the sound will no longer attenuate, meaning it will stay at a constant relative volume.
The following diagram (taken from the DirectX SDK) should give a good example of attenuation based on two very different min and max distances.
In this example, the Bee has a high fall off rate due to the small minimum distance, whereas the plane as a much lower one, meaning the plane sound will attenuate much slower and can be heard from a greater distance.
By altering the min and max distances and the fall off rate, you can easily change the presence of a sound in the environment. In the above example, the bee will be hard to notice and quickly fade out, where as the jet, which should be obvious to the player and present for quite a distance, will fade out slowly.
Linear Fall Off Models
Linear fall off models are the simplest to understand, and the least used (sound in the real world does not fall off in a linear fashion).
A linear drop off model alters the relative volume depending on the player’s position between the min and max distances in a linear fashion. So, if the player is half way between min and max, the volume will be set to half. Three quarters of a way to the max distance will see the relative volume being set to 0.25 (in the range 1.0 to 0.0). At maximum distance, the volume will be clamped to 0.0.
The following diagram shows the same situation as above, but with a linear attenuation model applied.
The above example would act in almost the same way as the quadratic model, but the attenuation will be more noticeable to the player and follow and easy to recognise pattern.


