Game Development Reference
an enemy unit fires a gun in your 3D shooter, and that enemy is some distance from
your player. The player should see the muzzle flash before she hears the sound of the
gun firing. This delay is due to the fact that light travels far faster than sound. The delay
between seeing the muzzle flash and hearing the shot gives the player some sense of the
distance from which the enemy is firing.
With respect to 3D sound effects, our ears hear sounds coming from an oblique direction
at slightly different times because of the separation distance between our ears. That time
lag, albeit very short, gives us some cues as to the direction from which the sound is
coming. We'll say more on this later on this chapter.
Additionally, the Doppler effect, which we'll discuss later, is also a function of the speed
In OpenAL you set the desired sound speed using the alSpeedOfSound function, passing
a single floating-point argument representing the sound speed. The specified value is
saved in the AL_SPEED_OF_SOUND property. The default value is 343.3, which is the speed
of sound in air at 20°C expressed in m/s.
Attenuation is the falloff in intensity of a sound over distance. Earlier we explained that
sound intensity is related to how much power flows through a given area. Imagine a
point sound source , which creates spherical pressure waves that propagate radially from
the source. Figure 26-7 illustrates this concept.
Figure 26-7. Spherical sound waves