Game Development Reference
In-Depth Information
Assuming the sound is being generated with a constant power, you can see that the area
through which that power flows grows with increasing distance, r , from the source.
Intensity is equal to power divided by area, thus the intensity at radius r 4 is less than that
at, say, r 1 because the surface area at r 4 is larger. The surface area of a sphere is 4π r 2 .
Without going into all the details, we can state that the amplitude of the spherical sound
wave is inversely proportional to r 2 .
This is an ideal treatment so far. In reality attenuation is also a function of other factors,
including the scattering and absorption of the sound wave as it interacts with the me‐
dium and the environment. You can model attenuation in many ways, taking into ac‐
count various levels of detail at increasing computational expense. However, for games,
relatively simple distance-based models are sufficient.
Attenuation provides another cue that tells us something about the sound source. In
your game, you wouldn't want the intensity, or volume, of a sound generated far from
the player to be the same as that from a source very close to the player. Attenuation tells
the player something about the distance between him and the sound source.
OpenAL includes several different distance-based models from which you can choose.
The OpenAL documentation describes the particulars of each, but the default model is
an inverse distance-based model where the gain of the source sound is adjusted in
inverse proportion to the distance from the sound source. Gain is an amplification factor
applied to the recorded amplitude of the sound effect you're using.
You can change distance models in OpenAL using the alDistanceModel function (see
the OpenAL programmers manual for valid parameters).
Reflection
When sound waves passing through one medium reach another medium or object, such
as a wall, part of the original sound wave is reflected off the object, while part of it is
absorbed by (and transmitted through) the object. Depending on the dispositions of
the sound source and the listener, some sound waves will reach the listener via some
direct path. Reflected waves may also reach the listener, although their energy may have
been reduced after their interaction with whatever they bounced off. Figure 26-8 illus‐
trates this concept, where some sound waves reach the listener directly and others reach
the listener after having been reflected from walls.
Search Nedrilad ::

Custom Search