Music and sound effects manager using SDL libraries.
#include <SDLAudioManager.hpp>
|
bool | load (const std::string &music_filepath, const std::string &id, const int &type) |
| Loads an audio file, assigning it a string as identifier. More...
|
|
bool | play (const std::string &id, int loop) |
| Plays a music/sound effect file previously loaded. More...
|
|
bool | stopMusic () |
| Stops the music being played currently. More...
|
|
virtual bool | start () |
| Start the AudioManager. More...
|
|
virtual bool | stop () |
| Stops the AudioManager.
|
|
virtual bool | isStopped () const |
| True if the manager is not active.
|
|
virtual | ~SDLAudioManager () |
| Destructor. Used to reset the local static reference after destroying this manager.
|
|
virtual bool | configure (const std::string ¶meter, const std::string &value) |
| Configures a parameter with a value.
|
|
|
static const std::string | id = "SDL" |
| String that identifies this manager.
|
|
static const int | MUSIC = 0 |
| Identifier for music tracks.
|
|
static const int | FX = 1 |
| Identifier for sound effect tracks.
|
|
|
std::map< std::string, Mix_Chunk * > | fx_sounds |
| Dictionary for the sound effects.
|
|
std::map< std::string, Mix_Music * > | music_sounds |
| Dictionary for the music tracks.
|
|
bool | stopped |
|
|
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.
|
|
◆ SDLAudioManager()
rd::SDLAudioManager::SDLAudioManager |
( |
| ) |
|
|
private |
Constructor for this class is private, since the singleton can only be instantiated once, and the instantiation is done at the RegisterManager() method
◆ load()
bool rd::SDLAudioManager::load |
( |
const std::string & |
music_filepath, |
|
|
const std::string & |
id, |
|
|
const int & |
type |
|
) |
| |
|
virtual |
- Parameters
-
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 |
- Returns
- True if sound was loaded successfully, false otherwise
Implements rd::AudioManager.
◆ play()
bool rd::SDLAudioManager::play |
( |
const std::string & |
id, |
|
|
int |
loop |
|
) |
| |
|
virtual |
- Parameters
-
id | String that identifies the music / sound effect track |
loop | Number of times the music is played. -1 means play the music forever. |
- Returns
- True if sound was played successfully, false otherwise
Implements rd::AudioManager.
◆ RegisterManager()
bool rd::SDLAudioManager::RegisterManager |
( |
| ) |
|
|
static |
It ensures that only one manager of this type is created (unique instance).
◆ start()
bool rd::SDLAudioManager::start |
( |
| ) |
|
|
virtual |
◆ stopMusic()
bool rd::SDLAudioManager::stopMusic |
( |
| ) |
|
|
virtual |
The documentation for this class was generated from the following files: