Voxellancer  0.3
A game about voxels in space
 All Classes Functions Pages
soundmanager.h
1 #pragma once
2 
3 #include <memory>
4 #include <string>
5 #include <unordered_map>
6 #include <list>
7 
8 #include <glm/glm.hpp>
9 #include <glm/gtc/quaternion.hpp>
10 
11 
12 namespace sf {
13  class SoundBuffer;
14 }
15 
16 class Sound;
17 class SoundProperties;
18 
19 class SoundManager {
20 public:
21  SoundManager();
22  ~SoundManager();
23 
24  void setListener(const glm::vec3& position, const glm::quat& orientation);
25  std::shared_ptr<Sound> create(std::string soundFile);
26  std::shared_ptr<Sound> play(std::string soundFile, const glm::vec3& position, bool relative = false);
27  std::shared_ptr<Sound> play(const SoundProperties& soundProperties, const glm::vec3& position, bool relative = false);
28 
29  void activate();
30  void deactivate();
31 
32 
33  void stopAll();
34 
35  static SoundManager* current();
36 
37 
38 protected:
39  std::unordered_map<std::string, sf::SoundBuffer*> m_buffer;
40  std::list<std::shared_ptr<Sound>> m_sounds;
41  int m_nextCleanup;
42 
43  sf::SoundBuffer* obtain(std::string soundFile);
44  void cleanUp();
45  void forcedCleanup();
46  std::shared_ptr<Sound> createNullSound();
47 
48  static SoundManager* s_current;
49 };
50 
Definition: soundmanager.h:19
Definition: sound.h:12
Definition: soundproperties.h:5