OpenRaider  0.1.4-dev
Open Source Tomb Raider Game Engine implementation
SoundManager.h
Go to the documentation of this file.
1 
8 #ifndef _SOUNDMANAGER_H_
9 #define _SOUNDMANAGER_H_
10 
11 #include <vector>
12 
13 class SoundSource {
14  public:
15  SoundSource(glm::vec3 p, int i, int f)
16  : pos(p), id(i), flags(f), source(-1), playing(false) { }
17  void prepare();
18  void play();
19  void stop();
20  glm::vec3 getPos() { return pos; }
21  int getID() { return id; }
22  int getFlags() { return flags; }
23  int getSource() { return source; }
24  bool isPlaying() { return playing; }
25 
26  private:
27  glm::vec3 pos;
28  int id, flags, source;
29  bool playing;
30 };
31 
32 class SoundDetail {
33  public:
34  SoundDetail(int s, float v) : sample(s), source(-1), volume(v) { }
35  int getSample() { return sample; }
36  float getVolume() { return volume; }
37  int getSource() { return source; }
38  void setSource(int s) { source = s; }
39 
40  private:
41  int sample, source;
42  float volume;
43 };
44 
45 class SoundManager {
46  public:
47  static void clear();
48  static int prepareSources();
49 
50  static void addSoundSource(glm::vec3 p, int id, int flags);
51  static void addSoundMapEntry(int id);
52  static void addSoundDetail(int sample, float volume);
53  static void addSampleIndex(int index);
54 
55  // index --> SoundMap --> SoundDetails --> SampleIndices --> play
56  static int getIndex(int index, float* volume = nullptr, SoundDetail** sd = nullptr);
57  static int playSound(int index);
58 
59  static void listenAt(glm::vec3 pos, glm::vec3 at, glm::vec3 up);
60  static void display();
61 
62  private:
63  static std::vector<SoundSource> soundSources;
64  static std::vector<int> soundMap;
65  static std::vector<SoundDetail> soundDetails;
66  static std::vector<int> sampleIndices;
67 };
68 
69 #endif
70 
static int getIndex(int index, float *volume=nullptr, SoundDetail **sd=nullptr)
int getFlags()
Definition: SoundManager.h:22
static std::vector< int > sampleIndices
Definition: SoundManager.h:66
bool isPlaying()
Definition: SoundManager.h:24
static std::vector< SoundDetail > soundDetails
Definition: SoundManager.h:65
glm::vec3 pos
Definition: SoundManager.h:27
float volume
Definition: SoundManager.h:42
float getVolume()
Definition: SoundManager.h:36
static void listenAt(glm::vec3 pos, glm::vec3 at, glm::vec3 up)
SoundSource(glm::vec3 p, int i, int f)
Definition: SoundManager.h:15
int getSample()
Definition: SoundManager.h:35
static int prepareSources()
int getSource()
Definition: SoundManager.h:23
static void addSampleIndex(int index)
static void addSoundSource(glm::vec3 p, int id, int flags)
static std::vector< int > soundMap
Definition: SoundManager.h:64
static void addSoundMapEntry(int id)
void setSource(int s)
Definition: SoundManager.h:38
int getSource()
Definition: SoundManager.h:37
SoundDetail(int s, float v)
Definition: SoundManager.h:34
static void clear()
glm::vec3 getPos()
Definition: SoundManager.h:20
static std::vector< SoundSource > soundSources
Definition: SoundManager.h:63
void prepare()
static void display()
static int playSound(int index)
static void addSoundDetail(int sample, float volume)