Game Development Reference
In-Depth Information
Source Data
Source data referstotheoriginalaudiofilesthatarecreatedbythesounddesigner
using a tool such as Audacity ( http://audacity.sourceforge.net ) . In the footstep
scenario, there might be dozens of different source files, such as fs1.wav, fs2.wav,
fs3.wav, and so on. A common approach is to store short sound effects as WAV
files or another uncompressed file format, and store longer sounds, such as music
or dialogue, in a compressed format such as MP3 or OGG.
When it comes to playing back these sound files in a game, there are two common
approaches. It usually makes sense to preload short sound effects into memory, so
when it's time to play the sound there is no time spent fetching the file from the
disk. On the other hand, because compressed music or dialogue files are typically
much larger in size, they are usually streamed off of a storage device. This means
that as the sound file is being played, small segments of it are loaded on demand
from the disk.
In order to load and play back source data, certain platforms have built-in sound
libraries (such as CoreAudio on iOS). But for cross-platform support, OpenAL
( http://kcat.strangesoft.net/openal.html ) is a very popular solution.
Sound Cues
A sound cue , sometimes called a sound event, maps to one or more source data
files. The sound cue is what is actually triggered by the game code—so rather than
having code that directly plays the fs1.wav data file, there might be code that trig-
gers a sound cue called “footstep.” The idea is that the sound cue can be a contain-
er for any number of source data files as well as store metadata about the sound as
a whole.
For example, suppose there is an explosion cue. This cue should randomly trigger
one of five different explosion WAV files. Additionally, because an explosion is
something that can be heard from far away, there might be meta information that
specifies the maximum distance the sound will be heard. It would be wise to also
have a high priority assigned to the explosion cue, so even if all the channels are
currently in use, the explosion is still audible. The basic layout of this cue is illus-
trated in Figure 6.1 .
Search WWH ::




Custom Search