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.

Sound.h 2.5KB

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