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.

Sound.h 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*!
  2. * \file include/Sound.h
  3. * \brief This is the audio manager Header
  4. *
  5. * \author xythobuz
  6. * \author Mongoose
  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 Move listener and repositions them
  40. * \param pos New position for listener
  41. * \param angle New orientation for listener
  42. */
  43. void listenAt(float pos[3], float angle[3]);
  44. /*!
  45. * \brief Move sound source to position
  46. * \param source valid source id
  47. * \param pos new position for source
  48. */
  49. void sourceAt(int source, float pos[3]);
  50. /*!
  51. * \brief Load wav file from disk
  52. * \param filename not NULL!
  53. * \param source not NULL! Returns new source ID or -1 on error.
  54. * \param flags set options. Use SoundFlags enum bitwise OR-ed
  55. * \returns 0 for no error or < 0 error flag
  56. */
  57. int addFile(const char *filename, int *source, unsigned int flags);
  58. /*!
  59. * \brief Load wav file from buffer
  60. * \param wav not NULL! Is a valid waveform buffer!
  61. * \param length length of wav buffer
  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 addWave(unsigned char *wav, unsigned int length, int *source, unsigned int flags);
  67. /*!
  68. * \brief Remove all loaded sounds
  69. */
  70. void clear();
  71. /*!
  72. * \brief Play sound source
  73. * \param source sound source to play
  74. */
  75. void play(int source);
  76. /*!
  77. * \brief Stop playing sound source
  78. * \param source sound source to stop
  79. */
  80. void stop(int source);
  81. private:
  82. bool mInit; //!< Guard to ensure ausio system is active
  83. std::vector<unsigned int> mBuffer; //!< Audio buffer id list
  84. std::vector<unsigned int> mSource; //!< Audio source id list
  85. };
  86. #endif