Open Source Tomb Raider Engine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SoundManager.h 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*!
  2. * \file include/SoundManager.h
  3. * \brief This is the audio manager Header
  4. *
  5. * \author xythobuz
  6. */
  7. #ifndef _SOUNDMANAGER_H_
  8. #define _SOUNDMANAGER_H_
  9. #include <vector>
  10. class SoundSource {
  11. public:
  12. SoundSource(glm::vec3 p, int i, int f)
  13. : pos(p), id(i), flags(f), source(-1) { }
  14. void prepare();
  15. glm::vec3 getPos() { return pos; }
  16. int getID() { return id; }
  17. int getFlags() { return flags; }
  18. int getSource() { return source; }
  19. private:
  20. glm::vec3 pos;
  21. int id, flags, source;
  22. };
  23. class SoundDetail {
  24. public:
  25. SoundDetail(int s, float v) : sample(s), source(-1), volume(v) { }
  26. int getSample() { return sample; }
  27. float getVolume() { return volume; }
  28. int getSource() { return source; }
  29. void setSource(int s) { source = s; }
  30. private:
  31. int sample, source;
  32. float volume;
  33. };
  34. class SoundManager {
  35. public:
  36. static void clear();
  37. static int prepareSources();
  38. static void addSoundSource(glm::vec3 p, int id, int flags);
  39. static void addSoundMapEntry(int id);
  40. static void addSoundDetail(int sample, float volume);
  41. static void addSampleIndex(int index);
  42. // index --> SoundMap --> SoundDetails --> SampleIndices --> play
  43. static int getIndex(int index, float* volume = nullptr, SoundDetail** sd = nullptr);
  44. static int playSound(int index);
  45. static void listenAt(glm::vec3 pos, glm::vec3 at, glm::vec3 up);
  46. static void display();
  47. private:
  48. static std::vector<SoundSource> soundSources;
  49. static std::vector<int> soundMap;
  50. static std::vector<SoundDetail> soundDetails;
  51. static std::vector<int> sampleIndices;
  52. };
  53. #endif