Creating a sound effect manager
Although not one of the best practices out there, one of the most common methods for handling audio is to create a manager class. The manager class should ensure that there is only one audio component in the whole game, which controls which sound is to be played, paused, looped, and so on. Although there are other ways of writing the manager class, this is the most standard practice.
Getting ready
For this recipe, you will need a Windows machine and Visual Studio.
How to do it…
In this recipe, we will find out how easy it is to add sound effect manager using the following snippet:
#pragma once #include <iostream> #include "../lib/SDL2/include/SDL2/SDL.h" #include "iaudiodevice.hpp" #include "iaudiocontext.hpp" #include "audioobject.hpp" #include "sdl/sdlaudiodevice.hpp" #include "sdl/sdlaudiocontext.hpp" #define FILE_PATH "./res/audio/testClip.wav" class GlobalAudioClass { private...