In this project, we will build on top of the simple audio manager developed in the last chapter, and make it more flexible and game oriented. This time, besides loading and playing sounds, we will also be able to stop them and control their volume, which is necessary in almost every game. Furthermore, we will divide all sounds into two categories, each with its own set of features and behaviors:
Sound effects (SFXs): Sounds that are loaded into memory and do not loop. Multiple instances can be played at the same time. Their volume and pitch can be controlled directly, or randomized within a user-defined range, to add variation to the sound.
Songs: Sounds that are streamed and set to loop. Only one song can be playing at any time. Transitions between songs are handled smoothly by the audio manager with volume fades.
Each game has its own needs, so you might want to create more categories, such as one for speech or ambient tracks.