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.

SoundAL.h 2.9KB

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