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 5.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
  2. /*================================================================
  3. *
  4. * Project : OpenRaider
  5. * Author : Mongoose
  6. * Website : http://www.westga.edu/~stu7440/
  7. * Email : stu7440@westga.edu
  8. * Object : Sound
  9. * License : No use w/o permission (C) 2001 Mongoose
  10. * Comments: This is the audio manager for OpenRaider
  11. *
  12. *
  13. * This file was generated using Mongoose's C++
  14. * template generator script. <stu7440@westga.edu>
  15. *
  16. *-- Test Defines -----------------------------------------------
  17. *
  18. * UNIT_TEST_SOUND - Builds Sound class as a console unit test
  19. *
  20. *-- History ----------------------------------------------------
  21. *
  22. * 2002.09.13:
  23. * Mongoose - API follows new code style guidelines
  24. *
  25. * 2002.01.03:
  26. * Mongoose - Flags use added
  27. *
  28. * 2001.05.23:
  29. * Mongoose - Created
  30. ================================================================*/
  31. #ifndef __OPENRAIDER_MONGOOSE_SOUND_H_
  32. #define __OPENRAIDER_MONGOOSE_SOUND_H_
  33. typedef enum
  34. {
  35. SoundFlagsNone = 0, /* No FX */
  36. SoundFlagsLoop = 1 /* Enable looping during playback */
  37. } SoundFlags;
  38. class Sound
  39. {
  40. public:
  41. Sound();
  42. /*------------------------------------------------------
  43. * Pre :
  44. * Post : Constructs an object of Sound
  45. *
  46. *-- History ------------------------------------------
  47. *
  48. * 2001.05.23:
  49. * Mongoose - Created
  50. ------------------------------------------------------*/
  51. ~Sound();
  52. /*------------------------------------------------------
  53. * Pre : Sound object is allocated
  54. * Post : Deconstructs an object of Sound
  55. *
  56. *-- History ------------------------------------------
  57. *
  58. * 2001.05.23:
  59. * Mongoose - Created
  60. ------------------------------------------------------*/
  61. int init();
  62. /*------------------------------------------------------
  63. * Pre :
  64. * Post : Initializes sound system
  65. *
  66. * No error returns 0 all others returns < 0
  67. * error flags
  68. *
  69. *-- History ------------------------------------------
  70. *
  71. * 2001.05.23:
  72. * Mongoose - Created
  73. ------------------------------------------------------*/
  74. void listenAt(float pos[3], float angle[3]);
  75. /*------------------------------------------------------
  76. * Pre : pos and angles are valid for listener
  77. * Post : Moves listener and repositions them
  78. *
  79. *-- History ------------------------------------------
  80. *
  81. * 2001.05.23:
  82. * Mongoose - Created
  83. ------------------------------------------------------*/
  84. void sourceAt(int source, float pos[3]);
  85. /*------------------------------------------------------
  86. * Pre : source and pos are valid for source
  87. * Post : Moves sound source to position
  88. *
  89. *-- History ------------------------------------------
  90. *
  91. * 2001.05.23:
  92. * Mongoose - Created
  93. ------------------------------------------------------*/
  94. int add(char *filename, int *source, unsigned int flags);
  95. /*------------------------------------------------------
  96. * Pre : filename and source aren't NULL
  97. * flags (un)set options
  98. *
  99. * Post : Loads wav file from disk
  100. *
  101. * Source returns it's sound source id,
  102. * source id is set -1 for error
  103. *
  104. * Returns either 0 for no error or < 0 error
  105. * flag
  106. *
  107. *-- History ------------------------------------------
  108. *
  109. * 2001.05.23:
  110. * Mongoose - Created
  111. ------------------------------------------------------*/
  112. // FIXME: Not implemented yet
  113. int add(unsigned char *wav, int *source, unsigned int flags);
  114. /*------------------------------------------------------
  115. * Pre : wav and source aren't NULL
  116. * wav is a valid waveform buffer
  117. *
  118. * flags (un)set options
  119. *
  120. * Post : Loads wav file from buffer
  121. *
  122. * Source returns it's sound source id,
  123. * source id is set -1 for error
  124. *
  125. * Returns either 0 for no error or < 0 error
  126. * flag
  127. *
  128. *-- History ------------------------------------------
  129. *
  130. * 2001.05.23:
  131. * Mongoose - Created
  132. ------------------------------------------------------*/
  133. void play(int source);
  134. /*------------------------------------------------------
  135. * Pre :
  136. * Post : Play sound source
  137. *
  138. *-- History ------------------------------------------
  139. *
  140. * 2001.05.23:
  141. * Mongoose - Created
  142. ------------------------------------------------------*/
  143. void stop(int source);
  144. /*------------------------------------------------------
  145. * Pre :
  146. * Post : Stop playing sound source
  147. *
  148. *-- History ------------------------------------------
  149. *
  150. * 2001.05.23:
  151. * Mongoose - Created
  152. ------------------------------------------------------*/
  153. private:
  154. bool mInit; /* Guard to ensure ausio system is active */
  155. unsigned int mBuffer[256]; /* Audio buffer id list */
  156. unsigned int mSource[256]; /* Audio source id list */
  157. unsigned int mNextBuffer; /* Audio buffer id cursor */
  158. unsigned int mNextSource; /* Audio source id cursor */
  159. };
  160. #endif