soundstreamhandle.cpp 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : wwaudio *
  23. * *
  24. * $Archive:: /Commando/Code/WWAudio/soundstreamhandle.cpp $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 8/23/01 4:47p $*
  29. * *
  30. * $Revision:: 2 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #include "soundstreamhandle.h"
  36. #include "audiblesound.h"
  37. //////////////////////////////////////////////////////////////////////
  38. //
  39. // SoundStreamHandleClass
  40. //
  41. //////////////////////////////////////////////////////////////////////
  42. SoundStreamHandleClass::SoundStreamHandleClass (void) :
  43. SampleHandle ((HSAMPLE)INVALID_MILES_HANDLE),
  44. StreamHandle ((HSTREAM)INVALID_MILES_HANDLE)
  45. {
  46. return ;
  47. }
  48. //////////////////////////////////////////////////////////////////////
  49. //
  50. // ~SoundStreamHandleClass
  51. //
  52. //////////////////////////////////////////////////////////////////////
  53. SoundStreamHandleClass::~SoundStreamHandleClass (void)
  54. {
  55. return ;
  56. }
  57. //////////////////////////////////////////////////////////////////////
  58. //
  59. // Initialize
  60. //
  61. //////////////////////////////////////////////////////////////////////
  62. void
  63. SoundStreamHandleClass::Initialize (SoundBufferClass *buffer)
  64. {
  65. SoundHandleClass::Initialize (buffer);
  66. if (Buffer != NULL) {
  67. //
  68. // Create a stream from the sample handle
  69. //
  70. StreamHandle = ::AIL_open_stream_by_sample (WWAudioClass::Get_Instance ()->Get_2D_Driver (),
  71. SampleHandle, buffer->Get_Filename (), 0);
  72. /*StreamHandle = ::AIL_open_stream (WWAudioClass::Get_Instance ()->Get_2D_Driver (),
  73. buffer->Get_Filename (), 0);*/
  74. }
  75. return ;
  76. }
  77. //////////////////////////////////////////////////////////////////////
  78. //
  79. // Start_Sample
  80. //
  81. //////////////////////////////////////////////////////////////////////
  82. void
  83. SoundStreamHandleClass::Start_Sample (void)
  84. {
  85. if (StreamHandle != (HSTREAM)INVALID_MILES_HANDLE) {
  86. ::AIL_start_stream (StreamHandle);
  87. }
  88. return ;
  89. }
  90. //////////////////////////////////////////////////////////////////////
  91. //
  92. // Stop_Sample
  93. //
  94. //////////////////////////////////////////////////////////////////////
  95. void
  96. SoundStreamHandleClass::Stop_Sample (void)
  97. {
  98. if (StreamHandle != (HSTREAM)INVALID_MILES_HANDLE) {
  99. ::AIL_pause_stream (StreamHandle, 1);
  100. }
  101. return ;
  102. }
  103. //////////////////////////////////////////////////////////////////////
  104. //
  105. // Resume_Sample
  106. //
  107. //////////////////////////////////////////////////////////////////////
  108. void
  109. SoundStreamHandleClass::Resume_Sample (void)
  110. {
  111. if (StreamHandle != (HSTREAM)INVALID_MILES_HANDLE) {
  112. ::AIL_pause_stream (StreamHandle, 0);
  113. }
  114. return ;
  115. }
  116. //////////////////////////////////////////////////////////////////////
  117. //
  118. // End_Sample
  119. //
  120. //////////////////////////////////////////////////////////////////////
  121. void
  122. SoundStreamHandleClass::End_Sample (void)
  123. {
  124. //
  125. // Stop the sample and then release our hold on the stream handle
  126. //
  127. Stop_Sample ();
  128. if (StreamHandle != (HSTREAM)INVALID_MILES_HANDLE) {
  129. ::AIL_close_stream (StreamHandle);
  130. StreamHandle = (HSTREAM)INVALID_MILES_HANDLE;
  131. }
  132. return ;
  133. }
  134. //////////////////////////////////////////////////////////////////////
  135. //
  136. // Set_Sample_Pan
  137. //
  138. //////////////////////////////////////////////////////////////////////
  139. void
  140. SoundStreamHandleClass::Set_Sample_Pan (S32 pan)
  141. {
  142. if (StreamHandle != (HSTREAM)INVALID_MILES_HANDLE) {
  143. ::AIL_set_stream_pan (StreamHandle, pan);
  144. }
  145. return ;
  146. }
  147. //////////////////////////////////////////////////////////////////////
  148. //
  149. // Get_Sample_Pan
  150. //
  151. //////////////////////////////////////////////////////////////////////
  152. S32
  153. SoundStreamHandleClass::Get_Sample_Pan (void)
  154. {
  155. S32 retval = 0;
  156. if (StreamHandle != (HSTREAM)INVALID_MILES_HANDLE) {
  157. retval = ::AIL_stream_pan (StreamHandle);
  158. }
  159. return retval;
  160. }
  161. //////////////////////////////////////////////////////////////////////
  162. //
  163. // Set_Sample_Volume
  164. //
  165. //////////////////////////////////////////////////////////////////////
  166. void
  167. SoundStreamHandleClass::Set_Sample_Volume (S32 volume)
  168. {
  169. if (StreamHandle != (HSTREAM)INVALID_MILES_HANDLE) {
  170. ::AIL_set_stream_volume (StreamHandle, volume);
  171. }
  172. return ;
  173. }
  174. //////////////////////////////////////////////////////////////////////
  175. //
  176. // Get_Sample_Volume
  177. //
  178. //////////////////////////////////////////////////////////////////////
  179. S32
  180. SoundStreamHandleClass::Get_Sample_Volume (void)
  181. {
  182. S32 retval = 0;
  183. if (StreamHandle != (HSTREAM)INVALID_MILES_HANDLE) {
  184. retval = ::AIL_stream_volume (StreamHandle);
  185. }
  186. return retval;
  187. }
  188. //////////////////////////////////////////////////////////////////////
  189. //
  190. // Set_Sample_Loop_Count
  191. //
  192. //////////////////////////////////////////////////////////////////////
  193. void
  194. SoundStreamHandleClass::Set_Sample_Loop_Count (U32 count)
  195. {
  196. if (StreamHandle != (HSTREAM)INVALID_MILES_HANDLE) {
  197. ::AIL_set_stream_loop_block (StreamHandle, 0, -1);
  198. ::AIL_set_stream_loop_count (StreamHandle, count);
  199. }
  200. return ;
  201. }
  202. //////////////////////////////////////////////////////////////////////
  203. //
  204. // Get_Sample_Loop_Count
  205. //
  206. //////////////////////////////////////////////////////////////////////
  207. U32
  208. SoundStreamHandleClass::Get_Sample_Loop_Count (void)
  209. {
  210. U32 retval = 0;
  211. if (StreamHandle != (HSTREAM)INVALID_MILES_HANDLE) {
  212. ::AIL_stream_loop_count (StreamHandle);
  213. }
  214. return retval;
  215. }
  216. //////////////////////////////////////////////////////////////////////
  217. //
  218. // Set_Sample_MS_Position
  219. //
  220. //////////////////////////////////////////////////////////////////////
  221. void
  222. SoundStreamHandleClass::Set_Sample_MS_Position (U32 ms)
  223. {
  224. if (StreamHandle != (HSTREAM)INVALID_MILES_HANDLE) {
  225. ::AIL_set_stream_ms_position (StreamHandle, ms);
  226. }
  227. return ;
  228. }
  229. //////////////////////////////////////////////////////////////////////
  230. //
  231. // Get_Sample_MS_Position
  232. //
  233. //////////////////////////////////////////////////////////////////////
  234. void
  235. SoundStreamHandleClass::Get_Sample_MS_Position (S32 *len, S32 *pos)
  236. {
  237. if (StreamHandle != (HSTREAM)INVALID_MILES_HANDLE) {
  238. ::AIL_stream_ms_position (StreamHandle, len, pos);
  239. }
  240. return ;
  241. }
  242. //////////////////////////////////////////////////////////////////////
  243. //
  244. // Set_Sample_User_Data
  245. //
  246. //////////////////////////////////////////////////////////////////////
  247. void
  248. SoundStreamHandleClass::Set_Sample_User_Data (S32 i, U32 val)
  249. {
  250. if (SampleHandle != (HSAMPLE)INVALID_MILES_HANDLE) {
  251. ::AIL_set_sample_user_data (SampleHandle, i, val);
  252. }
  253. return ;
  254. }
  255. //////////////////////////////////////////////////////////////////////
  256. //
  257. // Get_Sample_User_Data
  258. //
  259. //////////////////////////////////////////////////////////////////////
  260. U32
  261. SoundStreamHandleClass::Get_Sample_User_Data (S32 i)
  262. {
  263. U32 retval = 0;
  264. if (SampleHandle != (HSAMPLE)INVALID_MILES_HANDLE) {
  265. retval = ::AIL_sample_user_data (SampleHandle, i);
  266. }
  267. return retval;
  268. }
  269. //////////////////////////////////////////////////////////////////////
  270. //
  271. // Get_Sample_Playback_Rate
  272. //
  273. //////////////////////////////////////////////////////////////////////
  274. S32
  275. SoundStreamHandleClass::Get_Sample_Playback_Rate (void)
  276. {
  277. S32 retval = 0;
  278. if (StreamHandle != (HSTREAM)INVALID_MILES_HANDLE) {
  279. retval = ::AIL_stream_playback_rate (StreamHandle);
  280. }
  281. return retval;
  282. }
  283. //////////////////////////////////////////////////////////////////////
  284. //
  285. // Set_Sample_Playback_Rate
  286. //
  287. //////////////////////////////////////////////////////////////////////
  288. void
  289. SoundStreamHandleClass::Set_Sample_Playback_Rate (S32 rate)
  290. {
  291. if (StreamHandle != (HSTREAM)INVALID_MILES_HANDLE) {
  292. ::AIL_set_stream_playback_rate (StreamHandle, rate);
  293. }
  294. return ;
  295. }
  296. //////////////////////////////////////////////////////////////////////
  297. //
  298. // Set_Miles_Handle
  299. //
  300. //////////////////////////////////////////////////////////////////////
  301. void
  302. SoundStreamHandleClass::Set_Miles_Handle (uint32 handle)
  303. {
  304. SampleHandle = (HSAMPLE)handle;
  305. return ;
  306. }