dEngine
Simple 2D C++ game engine
|
Manages the loading, unloading, and playing of sounds. More...
#include <AudioManager.h>
Public Member Functions | |
void | AddSound (std::string name, std::string filepath) |
Add a sound to audio manager. More... | |
void | LoadSounds () |
Load added sounds to memory. More... | |
void | PlaySound (std::string name) |
Play a sound. More... | |
void | ClearSounds () |
Clear all stored sounds. More... | |
void | RemoveSound (std::string name) |
Remove a single sound. More... | |
bool | HasSound (std::string name) |
Check if sound has been added. More... | |
Static Public Member Functions | |
static AudioManager & | GetInstance () |
Private Attributes | |
std::map< std::string, std::shared_ptr< Sound > > | audioCollection |
Static Private Attributes | |
static AudioManager * | instance |
Manages the loading, unloading, and playing of sounds.
The audio manager is designed to be used by individual GameLevels to help manage sounds on a per level basis allowing only sounds for that level to be loaded at the loading screen
void AudioManager::AddSound | ( | std::string | name, |
std::string | filepath | ||
) |
Add a sound to audio manager.
Add a sound to the audio manager without loading it into memory
filepath | Filepath to the wave file |
name | The name of the sound |
void AudioManager::ClearSounds | ( | ) |
Clear all stored sounds.
Clear all currently added and loaded sounds freeing up previously allocated space
|
static |
Returns an instance of the audio manager
bool AudioManager::HasSound | ( | std::string | name | ) |
Check if sound has been added.
Checks if sound has been added to audiomanager
name | Name of the sound |
void AudioManager::LoadSounds | ( | ) |
Load added sounds to memory.
Loads all added sounds into memory
void AudioManager::PlaySound | ( | std::string | name | ) |
Play a sound.
Plays a sound through the default audio device
name | The name of the sound |
void AudioManager::RemoveSound | ( | std::string | name | ) |
Remove a single sound.
Removes a single sound by name from memory
name | Name of sound to remove |
|
private |
Referenced by AddSound(), ClearSounds(), HasSound(), LoadSounds(), PlaySound(), and RemoveSound().
|
staticprivate |
Referenced by GetInstance().