Robot Devastation
SDLAudioManager.hpp
1 // Authors: see AUTHORS.md at project root.
2 // CopyPolicy: released under the terms of the LGPLv2.1, see LICENSE at project root.
3 // URL: https://github.com/asrob-uc3m/robotDevastation
4 
5 #ifndef __RD_SDL_AUDIO_MANAGER_HPP__
6 #define __RD_SDL_AUDIO_MANAGER_HPP__
7 
8 #include <map>
9 #include <string>
10 
11 #include <SDL_mixer.h>
12 
13 #include "AudioManager.hpp"
14 
15 namespace rd{
16 
24 {
25  public:
26  //---------------- Audio-related Stuff ----------------------------------------------------------------------//
27  bool load(const std::string& music_filepath, const std::string& id, const int& type);
28  bool play(const std::string &id, int loop);
29  bool stopMusic();
30 
31 
32  //---------------- Manager Stuff ----------------------------------------------------------------------//
33  virtual bool start();
34  virtual bool stop();
35  virtual bool isStopped() const;
36 
42  static bool RegisterManager();
43 
45  virtual ~SDLAudioManager();
46 
47 
49  static const std::string id;
50 
51 
52  private:
60 
62  SDLAudioManager & operator=(const SDLAudioManager &);
63 
66 
68  std::map<std::string, Mix_Chunk*> fx_sounds;
69 
71  std::map<std::string, Mix_Music*> music_sounds;
72 
73  bool stopped;
74 
75 };
76 
77 }
78 
79 #endif //-- __RD_SDL_AUDIO_MANAGER_HPP__
rd::SDLAudioManager::load
bool load(const std::string &music_filepath, const std::string &id, const int &type)
Loads an audio file, assigning it a string as identifier.
Definition: SDLAudioManager.cpp:29
rd::AudioManager
Music and sound effects manager.
Definition: AudioManager.hpp:28
rd::SDLAudioManager::stop
virtual bool stop()
Stops the AudioManager.
Definition: SDLAudioManager.cpp:106
rd
The main, catch-all namespace for Robot Devastation.
Definition: groups.dox:4
rd::SDLAudioManager::id
static const std::string id
String that identifies this manager.
Definition: SDLAudioManager.hpp:49
rd::SDLAudioManager::play
bool play(const std::string &id, int loop)
Plays a music/sound effect file previously loaded.
Definition: SDLAudioManager.cpp:59
rd::SDLAudioManager::stopMusic
bool stopMusic()
Stops the music being played currently.
Definition: SDLAudioManager.cpp:88
rd::SDLAudioManager::start
virtual bool start()
Start the AudioManager.
Definition: SDLAudioManager.cpp:100
rd::SDLAudioManager
Music and sound effects manager using SDL libraries.
Definition: SDLAudioManager.hpp:23
rd::SDLAudioManager::SDLAudioManager
SDLAudioManager()
Constructor.
Definition: SDLAudioManager.cpp:17
rd::SDLAudioManager::uniqueInstance
static SDLAudioManager * uniqueInstance
Stores the unique instance of the AudioManager.
Definition: SDLAudioManager.hpp:65
rd::SDLAudioManager::RegisterManager
static bool RegisterManager()
Register this manager in the AudioManager registry so that can be used.
Definition: SDLAudioManager.cpp:118
rd::SDLAudioManager::fx_sounds
std::map< std::string, Mix_Chunk * > fx_sounds
Dictionary for the sound effects.
Definition: SDLAudioManager.hpp:68
rd::SDLAudioManager::music_sounds
std::map< std::string, Mix_Music * > music_sounds
Dictionary for the music tracks.
Definition: SDLAudioManager.hpp:71
rd::SDLAudioManager::~SDLAudioManager
virtual ~SDLAudioManager()
Destructor. Used to reset the local static reference after destroying this manager.
Definition: SDLAudioManager.cpp:128
rd::SDLAudioManager::isStopped
virtual bool isStopped() const
True if the manager is not active.
Definition: SDLAudioManager.cpp:113