Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
sound3dhandle.cpp
Go to the documentation of this file.
1/*
2** Command & Conquer Generals Zero Hour(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/***********************************************************************************************
20 *** 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 ***
21 ***********************************************************************************************
22 * *
23 * Project Name : wwaudio *
24 * *
25 * $Archive:: /Commando/Code/WWAudio/sound3dhandle.cpp $*
26 * *
27 * Author:: Patrick Smith *
28 * *
29 * $Modtime:: 8/23/01 4:54p $*
30 * *
31 * $Revision:: 2 $*
32 * *
33 *---------------------------------------------------------------------------------------------*
34 * Functions: *
35 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
36
37#include "sound3dhandle.h"
38#include "audiblesound.h"
39
40
42//
43// Sound3DHandleClass
44//
51
52
54//
55// ~Sound3DHandleClass
56//
62
63
65//
66// Initialize
67//
69void
71{
73
74 if (SampleHandle != (H3DSAMPLE)INVALID_MILES_HANDLE && Buffer != NULL) {
75
76 //
77 // Configure the 3D sample
78 //
79 U32 success = ::AIL_set_3D_sample_file (SampleHandle, Buffer->Get_Raw_Buffer ());
80
81 S32 test1 = 0;
82 S32 test2 = 0;
83 Get_Sample_MS_Position (&test1, &test2);
84
85 //
86 // Check for success
87 //
88 WWASSERT (success != 0);
89 if (success == 0) {
90 WWDEBUG_SAY (("WWAudio: Couldn't set 3d sample file. Reason %s\r\n", ::AIL_last_error ()));
91 }
92
93 }
94
95 return ;
96}
97
98
100//
101// Start_Sample
102//
104void
106{
107 if (SampleHandle != (H3DSAMPLE)INVALID_MILES_HANDLE) {
108 ::AIL_start_3D_sample (SampleHandle);
109 }
110 return ;
111}
112
113
115//
116// Stop_Sample
117//
119void
121{
122 if (SampleHandle != (H3DSAMPLE)INVALID_MILES_HANDLE) {
123 ::AIL_stop_3D_sample (SampleHandle);
124 }
125
126 return ;
127}
128
129
131//
132// Resume_Sample
133//
135void
137{
138 if (SampleHandle != (H3DSAMPLE)INVALID_MILES_HANDLE) {
139 ::AIL_resume_3D_sample (SampleHandle);
140 }
141 return ;
142}
143
144
146//
147// End_Sample
148//
150void
152{
153 if (SampleHandle != (H3DSAMPLE)INVALID_MILES_HANDLE) {
154 ::AIL_end_3D_sample (SampleHandle);
155 }
156
157 return ;
158}
159
160
162//
163// Set_Sample_Pan
164//
166void
171
172
174//
175// Get_Sample_Pan
176//
178S32
180{
181 return 64;
182}
183
184
186//
187// Set_Sample_Volume
188//
190void
192{
193 if (SampleHandle != (H3DSAMPLE)INVALID_MILES_HANDLE) {
194 ::AIL_set_3D_sample_volume (SampleHandle, volume);
195 }
196
197 return ;
198}
199
200
202//
203// Get_Sample_Volume
204//
206S32
208{
209 S32 retval = 0;
210
211 if (SampleHandle != (H3DSAMPLE)INVALID_MILES_HANDLE) {
212 retval = ::AIL_3D_sample_volume (SampleHandle);
213 }
214
215 return retval;
216}
217
218
220//
221// Set_Sample_Loop_Count
222//
224void
226{
227 if (SampleHandle != (H3DSAMPLE)INVALID_MILES_HANDLE) {
228 ::AIL_set_3D_sample_loop_count (SampleHandle, count);
229 }
230
231 return ;
232}
233
234
236//
237// Get_Sample_Loop_Count
238//
240U32
242{
243 U32 retval = 0;
244
245 if (SampleHandle != (H3DSAMPLE)INVALID_MILES_HANDLE) {
246 retval = ::AIL_3D_sample_loop_count (SampleHandle);
247 }
248
249 return retval;
250}
251
252
254//
255// Set_Sample_MS_Position
256//
258void
260{
261 if (SampleHandle != (H3DSAMPLE)INVALID_MILES_HANDLE) {
262
263 WWASSERT (Buffer != NULL);
264 U32 bytes_per_sec = (Buffer->Get_Rate () * Buffer->Get_Bits ()) >> 3;
265 U32 bytes = (ms * bytes_per_sec) / 1000;
266 bytes += (bytes & 1);
267 ::AIL_set_3D_sample_offset (SampleHandle, bytes);
268 }
269
270 return ;
271}
272
273
275//
276// Get_Sample_MS_Position
277//
279void
281{
282 if (SampleHandle != (H3DSAMPLE)INVALID_MILES_HANDLE) {
283
284 WWASSERT (Buffer != NULL);
285 if (pos != NULL) {
286 U32 bytes = ::AIL_3D_sample_offset (SampleHandle);
287 U32 bytes_per_sec = (Buffer->Get_Rate () * Buffer->Get_Bits ()) >> 3;
288 U32 ms = (bytes * 1000) / bytes_per_sec;
289 (*pos) = ms;
290 }
291
292 if (len != NULL) {
293 U32 bytes = ::AIL_3D_sample_length (SampleHandle);
294 U32 bytes_per_sec = (Buffer->Get_Rate () * Buffer->Get_Bits ()) >> 3;
295 U32 ms = (bytes * 1000) / bytes_per_sec;
296 (*len) = ms;
297 }
298 }
299
300 return ;
301}
302
303
305//
306// Set_Sample_User_Data
307//
309void
311{
312 if (SampleHandle != (H3DSAMPLE)INVALID_MILES_HANDLE) {
313 ::AIL_set_3D_object_user_data (SampleHandle, i, val);
314 }
315 return ;
316}
317
318
320//
321// Get_Sample_User_Data
322//
324U32
326{
327 U32 retval = 0;
328
329 if (SampleHandle != (H3DSAMPLE)INVALID_MILES_HANDLE) {
330 retval = AIL_3D_object_user_data (SampleHandle, i);
331 }
332
333 return retval;
334}
335
336
338//
339// Get_Sample_Playback_Rate
340//
342S32
344{
345 S32 retval = 0;
346
347 if (SampleHandle != (H3DSAMPLE)INVALID_MILES_HANDLE) {
348 retval = ::AIL_3D_sample_playback_rate (SampleHandle);
349 }
350
351 return retval;
352}
353
354
356//
357// Set_Sample_Playback_Rate
358//
360void
362{
363 if (SampleHandle != (H3DSAMPLE)INVALID_MILES_HANDLE) {
364 ::AIL_set_3D_sample_playback_rate (SampleHandle, rate);
365 }
366
367 return ;
368}
369
370
372//
373// Set_Miles_Handle
374//
376void
378{
380
381 SampleHandle = (H3DSAMPLE)handle;
382 return ;
383}
const MILES_HANDLE INVALID_MILES_HANDLE
#define NULL
Definition BaseType.h:92
#define WWASSERT
unsigned long uint32
Definition bittype.h:46
U32 Get_Sample_User_Data(S32 i)
void Get_Sample_MS_Position(S32 *len, S32 *pos)
void Set_Sample_Volume(S32 volume)
U32 Get_Sample_Loop_Count(void)
void Set_Sample_Pan(S32 pan)
void Set_Sample_Loop_Count(U32 count)
void Set_Sample_User_Data(S32 i, U32 val)
void Set_Miles_Handle(uint32 handle)
void Set_Sample_Playback_Rate(S32 rate)
void Set_Sample_MS_Position(U32 ms)
S32 Get_Sample_Playback_Rate(void)
void Initialize(SoundBufferClass *buffer)
SoundBufferClass * Buffer
virtual void Initialize(SoundBufferClass *buffer)
#define S32
Definition md5.cpp:62
else return(RetVal)
#define WWDEBUG_SAY(x)
Definition wwdebug.h:114