Open Source Tomb Raider Engine
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

Sound.h 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 init();
  33. /*!
  34. * \brief Get number of registered sources
  35. * \returns number of registered sources
  36. */
  37. int registeredSources();
  38. /*!
  39. * \brief Remove all loaded sounds
  40. */
  41. void clear();
  42. /*!
  43. * \brief Set the volume
  44. * \param vol new source gain
  45. */
  46. void setVolume(float vol);
  47. /*!
  48. * \brief Move listener and repositions them
  49. * \param pos New position for listener
  50. * \param angle New orientation for listener
  51. */
  52. 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. void sourceAt(int 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. int addFile(const char *filename, int *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. int addWave(unsigned char *wav, unsigned int length, int *source, unsigned int flags);
  76. /*!
  77. * \brief Play sound source
  78. * \param source sound source to play
  79. */
  80. void play(int source);
  81. /*!
  82. * \brief Stop playing sound source
  83. * \param source sound source to stop
  84. */
  85. void stop(int source);
  86. private:
  87. bool mInit; //!< Guard to ensure ausio system is active
  88. float mVolume; //!< Listener gain
  89. std::vector<unsigned int> mBuffer; //!< Audio buffer id list
  90. std::vector<unsigned int> mSource; //!< Audio source id list
  91. };
  92. #endif