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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*!
  2. * \file include/Sound.h
  3. * \brief This is the audio manager Header
  4. *
  5. * \author Mongoose
  6. * \author xythobuz
  7. */
  8. #ifndef _SOUND_H_
  9. #define _SOUND_H_
  10. #include <vector>
  11. /*!
  12. * \brief This is the audio manager for OpenRaider
  13. */
  14. class Sound {
  15. public:
  16. typedef enum {
  17. SoundFlagsNone = 0, //!< No effect
  18. SoundFlagsLoop = (1 << 0) //!< Enable looping during playback
  19. } SoundFlags;
  20. /*!
  21. * \brief Constructs an object of Sound
  22. */
  23. Sound();
  24. /*!
  25. * \brief Deconstructs an object of Sound
  26. */
  27. ~Sound();
  28. /*!
  29. * \brief Initialize sound system
  30. * \returns 0 on success or < 0 error flags
  31. */
  32. int initialize();
  33. void setEnabled(bool on);
  34. /*!
  35. * \brief Set the volume
  36. * \param vol new source gain
  37. */
  38. void setVolume(float vol);
  39. /*!
  40. * \brief Get number of registered sources
  41. * \returns number of registered sources
  42. */
  43. int registeredSources();
  44. /*!
  45. * \brief Remove all loaded sounds
  46. */
  47. void clear();
  48. /*!
  49. * \brief Move listener and repositions them
  50. * \param pos New position for listener
  51. * \param angle New orientation for listener
  52. */
  53. void listenAt(float pos[3], float angle[3]);
  54. /*!
  55. * \brief Move sound source to position
  56. * \param source valid source id
  57. * \param pos new position for source
  58. */
  59. void sourceAt(int source, float pos[3]);
  60. /*!
  61. * \brief Load wav file from disk
  62. * \param filename not NULL!
  63. * \param source not NULL! Returns new source ID or -1 on error.
  64. * \param flags set options. Use SoundFlags enum bitwise OR-ed
  65. * \returns 0 for no error or < 0 error flag
  66. */
  67. int addFile(const char *filename, int *source, unsigned int flags);
  68. /*!
  69. * \brief Load wav file from buffer
  70. * \param wav not NULL! Is a valid waveform buffer!
  71. * \param length length of wav buffer
  72. * \param source not NULL! Returns new source ID or -1 on error.
  73. * \param flags set options. Use SoundFlags enum bitwise OR-ed
  74. * \returns 0 for no error or < 0 error flag
  75. */
  76. int addWave(unsigned char *wav, unsigned int length, int *source, unsigned int flags);
  77. /*!
  78. * \brief Play sound source
  79. * \param source sound source to play
  80. */
  81. void play(int source);
  82. /*!
  83. * \brief Stop playing sound source
  84. * \param source sound source to stop
  85. */
  86. void stop(int source);
  87. private:
  88. bool mEnabled;
  89. bool mInit; //!< Guard to ensure ausio system is active
  90. float mVolume; //!< Listener gain
  91. std::vector<unsigned int> mBuffer; //!< Audio buffer id list
  92. std::vector<unsigned int> mSource; //!< Audio source id list
  93. };
  94. #endif