Open Source Tomb Raider Engine
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

SoundManager.h 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*!
  2. * \file include/SoundManager.h
  3. * \brief Sound Source Manager
  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), playing(false) { }
  14. void prepare();
  15. void play();
  16. void stop();
  17. glm::vec3 getPos() { return pos; }
  18. int getID() { return id; }
  19. int getFlags() { return flags; }
  20. int getSource() { return source; }
  21. bool isPlaying() { return playing; }
  22. private:
  23. glm::vec3 pos;
  24. int id, flags, source;
  25. bool playing;
  26. };
  27. class SoundDetail {
  28. public:
  29. SoundDetail(int s, float v) : sample(s), source(-1), volume(v) { }
  30. int getSample() { return sample; }
  31. float getVolume() { return volume; }
  32. int getSource() { return source; }
  33. void setSource(int s) { source = s; }
  34. private:
  35. int sample, source;
  36. float volume;
  37. };
  38. class SoundManager {
  39. public:
  40. static void clear();
  41. static int prepareSources();
  42. static void addSoundSource(glm::vec3 p, int id, int flags);
  43. static void addSoundMapEntry(int id);
  44. static void addSoundDetail(int sample, float volume);
  45. static void addSampleIndex(int index);
  46. // index --> SoundMap --> SoundDetails --> SampleIndices --> play
  47. static int getIndex(int index, float* volume = nullptr, SoundDetail** sd = nullptr);
  48. static int playSound(int index);
  49. static void listenAt(glm::vec3 pos, glm::vec3 at, glm::vec3 up);
  50. static void display();
  51. private:
  52. static std::vector<SoundSource> soundSources;
  53. static std::vector<int> soundMap;
  54. static std::vector<SoundDetail> soundDetails;
  55. static std::vector<int> sampleIndices;
  56. };
  57. #endif