Game Develop C++ Platform: SoundManager.h Source File

| Game Develop C++ Platform Platform for developing native games based on OpenGL and SFML with Game Develop

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Groups Pages
SoundManager.h
Go to the documentation of this file.
1
6 #ifndef SOUNDMANAGER_H
7 #define SOUNDMANAGER_H
8
9 #include <SFML/Audio.hpp>
10 #include "GDCpp/Sound.h"
11 #include "GDCpp/Music.h"
12 #include <boost/shared_ptr.hpp>
13 #include <string>
14 #include <vector>
15 #include <map>
16
17 using namespace std;
18
27 class GD_API SoundManager
28 {
29 public:
30 vector < boost::shared_ptr<Music> > musics;
31 vector < boost::shared_ptr<Sound> > sounds;
32
36 boost::shared_ptr<Music> & GetMusicOnChannel(int channel);
37
41 void SetMusicOnChannel(int channel, boost::shared_ptr<Music> music);
42
46 boost::shared_ptr<Sound> & GetSoundOnChannel(int channel);
47
51 void SetSoundOnChannel(int channel, boost::shared_ptr<Sound> sound);
52
60 inline float GetGlobalVolume() const { return globalVolume; }
61
69 void SetGlobalVolume(float volume);
70
74 void ClearAllSoundsAndMusics()
75 {
76 musicsChannel.clear();
77 soundsChannel.clear();
78 sounds.clear();
79 musics.clear();
80 }
81
85 void ManageGarbage();
86
87 static SoundManager *GetInstance()
88 {
89 if ( NULL == _singleton )
90 {
91 _singleton = new SoundManager;
92 }
93
94 return ( static_cast<SoundManager*>( _singleton ) );
95 }
96
97 static void DestroySingleton()
98 {
99 if ( NULL != _singleton )
100 {
101 delete _singleton;
102 _singleton = NULL;
103 }
104 }
105
106 private:
107
108 std::map<unsigned int, boost::shared_ptr<Sound> > soundsChannel;
109 std::map<unsigned int, boost::shared_ptr<Music> > musicsChannel;
110
111 float globalVolume;
112
113 SoundManager();
114 ~SoundManager();
115 static SoundManager *_singleton;
116 };
117
118
119 #endif // SOUNDMANAGER_H
120