Robot Devastation
|
Music and sound effects manager. More...
#include <AudioManager.hpp>
Public Member Functions | |
virtual bool | start ()=0 |
Start the AudioManager. More... | |
virtual bool | stop ()=0 |
Stops the AudioManager. | |
virtual bool | isStopped () const =0 |
True if the manager is not active. | |
virtual bool | configure (const std::string ¶meter, const std::string &value) |
Configures a parameter with a value. | |
virtual bool | load (const std::string &music_filepath, const std::string &id, const int &type)=0 |
Loads an audio file, assigning it a string as identifier. More... | |
virtual bool | play (const std::string &id, int loop=1)=0 |
Plays a music/sound effect file previously loaded. More... | |
virtual bool | stopMusic ()=0 |
Stops the music being played currently. More... | |
Static Public Member Functions | |
static AudioManager * | getAudioManager () |
Get a reference to the AudioManager. More... | |
static AudioManager * | getAudioManager (const std::string &id) |
Get a reference to the AudioManager. More... | |
static bool | destroyAudioManager () |
Deallocate all the registered AudioManager. | |
Static Public Attributes | |
static const int | MUSIC = 0 |
Identifier for music tracks. | |
static const int | FX = 1 |
Identifier for sound effect tracks. | |
Static Protected Member Functions | |
static bool | Register (AudioManager *manager, const std::string &id) |
This function allows subclasses to install their unique instances in the singleton register to be selected later by the user. | |
Static Private Attributes | |
static AudioManager * | audioManagerInstance = NULL |
Stores the unique instance of the AudioManager. | |
static std::string | currentId = "" |
Stores the id of the current unique instance used. | |
static std::map< std::string, AudioManager * > | audioManagerRegistry = std::map<std::string, rd::AudioManager *>() |
Stores all the AudioManager that have been registered. | |
AudioManager can load several audio files and assign them a string for identification, so that they can be played later.
AudioManager is a singleton text (only one instance of this object can exist, that is is shared by all the users). To use this class, we first get the reference to the AudioManager with getAudioManager() and then we access the manager with that reference.
When the program finishes, the AudioManager can be deallocated using destroAudioManager().
|
static |
|
static |
|
pure virtual |
music_filepath | Path to the file to be loaded |
id | String that will identify the audio loaded |
type | Can take a value of MUSIC or FX depending if the audio is to be loaded as game music or sound effect |
Implemented in rd::MockAudioManager, and rd::SDLAudioManager.
|
pure virtual |
id | String that identifies the music / sound effect track |
loop | Number of times the music is played. -1 means play the music forever. |
Implemented in rd::MockAudioManager, and rd::SDLAudioManager.
|
pure virtual |
This function is supposed to be called after AudioManager configuration.
Implemented in rd::MockAudioManager, and rd::SDLAudioManager.
|
pure virtual |
Implemented in rd::MockAudioManager, and rd::SDLAudioManager.