Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Just like a graphics subsystem, audio subsystems can have a few different implementations. DirectSound, Miles Audio, WWise, and FMod are a few examples. It’s a good idea to create an implementation-agnostic wrapper for your sound system so that you are free to choose the implementation right for your game. The audio system presented in this chapter can use DirectSound or Miles, and the only change you have to make for your high-level game code is one line of code. Figure 13.4 shows the class hierarchy for our sound system.
Figure 13.4
Sound system class hierarchy.
The sound system inherits from IAudio. This object is responsible for the list of sounds currently active. As you might predict, you only need one of these for your game. The Audio base class implements some implementation-generic routines, and the DirectSoundAudio class completes the implementation with DirectSound-specific calls.