Managing sounds
Due to the limitations on the number of sounds we can have in an application, it's best to have a centralized way of handling and recycling them. This is where the SoundManager
class comes in. Let's begin aliasing a data type for sound IDs:
using SoundID = int;
A simple integer type is more than qualified for the job of keeping sounds identified.
Additionally, we'll want to store some information with the sound instance:
struct SoundInfo{ SoundInfo(const std::string& l_name): m_name(l_name), m_manualPaused(false){} std::string m_name; bool m_manualPaused; };
In order to properly deallocate resources when it counts, we're going to want to store the string identifier of the audio file that the sound is using. Keeping track of whether the sound has been paused automatically or not is important for consistency. That's what the m_manualPaused
Boolean flag is there for.
Lastly, before we delve deeper into the sound manager, looking at a few type...