Open Source Tomb Raider Engine
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

Sound.h 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 FX
  17. SoundFlagsLoop = 1 //!< Enable looping during playback
  18. } SoundFlags;
  19. /*!
  20. * \brief Constructs an object of Sound
  21. */
  22. Sound();
  23. /*!
  24. * \brief Deconstructs an object of Sound
  25. */
  26. ~Sound();
  27. /*!
  28. * \brief Initialize sound system
  29. * \returns 0 on success or < 0 error flags
  30. */
  31. int init();
  32. /*!
  33. * \brief Get number of registered sources
  34. * \returns number of registered sources
  35. */
  36. int registeredSources();
  37. /*!
  38. * \brief Move listener and repositions them
  39. * \param pos New position for listener
  40. * \param angle New orientation for listener
  41. */
  42. void listenAt(float pos[3], float angle[3]);
  43. /*!
  44. * \brief Move sound source to position
  45. * \param source valid source id
  46. * \param pos new position for source
  47. */
  48. void sourceAt(int source, float pos[3]);
  49. /*!
  50. * \brief Load wav file from disk
  51. * \param filename not NULL!
  52. * \param source not NULL! Returns new source ID or -1 on error.
  53. * \param flags (un)set options. Use SoundFlags enum
  54. * \returns 0 for no error or < 0 error flag
  55. */
  56. int addFile(const char *filename, int *source, unsigned int flags);
  57. /*!
  58. * \brief Load wav file from buffer
  59. * \param wav not NULL! Is a valid waveform buffer!
  60. * \param length length of wav buffer
  61. * \param source not NULL! Returns new source ID or -1 on error.
  62. * \param flags (un)set options. Use SoundFlags enum
  63. * \returns 0 for no error or < 0 error flag
  64. */
  65. int addWave(unsigned char *wav, unsigned int length, int *source, unsigned int flags);
  66. /*!
  67. * \brief Remove a loaded sound
  68. * \param source valid source id
  69. */
  70. void remove(int source);
  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. unsigned int mBuffer[256]; //!< Audio buffer id list
  84. unsigned int mSource[256]; //!< Audio source id list
  85. int mNext; //!< Audio id cursor
  86. };
  87. #endif