Debian Codegraph @

sndlib/hlsoundlib.h

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
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 --- HISTORICAL COMMENTS FOLLOW ---
19
20 * $Logfile: /DescentIII/Main/lib/hlsoundlib.h $
21 * $Revision: 47 $
22 * $Date: 3/20/00 12:26p $
23 * $Author: Matt $
24 *
25 * Descent III Device-independant sound library
26 *
27 * $Log: /DescentIII/Main/lib/hlsoundlib.h $
28 *
29 * 47 3/20/00 12:26p Matt
30 * Merge of Duane's post-1.3 changes.
31 * Lower MAX_SOUND_OBJECTS for Mac (Mac only)
32 *
33 * 46 10/21/99 9:27p Jeff
34 * B.A. Macintosh code merge
35 *
36 * 45 5/10/99 10:53p Ardussi
37 * changes to compile on Mac
38 *
39 * 44 4/27/99 2:10p Samir
40 * added code to set the desired sound card given the descriptive name of
41 * a sound card.
42 *
43 * 43 4/12/99 7:14p Samir
44 * prioritization code added.
45 *
46 * 42 4/11/99 2:17p Chris
47 * Made max sounds 3000 DAMN!
48 *
49 * 41 4/10/99 5:09p Samir
50 * beginning to add prioritization of sounds code. currently non
51 * functional, but allows me to change all calls to Play3dSound so that I
52 * can test later.
53 *
54 * 40 4/01/99 6:37p Chris
55 *
56 * 39 4/01/99 6:37p Chris
57 * Increased max sound objects
58 *
59 * 38 4/01/99 4:28p Samir
60 * hardware geometry integration if it's available.
61 *
62 * 37 2/21/99 5:48p Matt
63 * Added SetVolumeObject()
64 *
65 * 36 1/30/99 3:44p Chris
66 * Added support for time-offset'ed 3d sounds (like start at 1.2 seconds
67 * into the sound)
68 *
69 * 35 1/29/99 12:48p Matt
70 * Rewrote the doorway system
71 *
72 * 34 1/26/99 5:16p Matt
73 * Added StopObjectSound()
74 *
75 * 33 1/12/99 4:04p Samir
76 * added environmental audio on a per room basis.
77 *
78 * 32 1/08/99 6:31p Samir
79 * added reverb
80 *
81 * 31 1/08/99 5:37p Samir
82 * reverb values per room.
83 *
84 * 30 11/16/98 4:29p Chris
85 * Added pause new flag to the high level system
86 *
87 * 29 11/13/98 2:27p Samir
88 * moved music stuff to d3music.h
89 *
90 * 28 10/16/98 5:42p Chris
91 *
92 * 27 8/18/98 12:17p Chris
93 * f_in_game for begin sound frame (to do 3d processing)
94 *
95 * 26 8/10/98 5:52p Samir
96 * added tension levels for music.
97 *
98 * 25 7/28/98 5:41p Samir
99 * change some music system protos.
100 *
101 * 24 7/24/98 5:26p Samir
102 * added some D3 music functions.
103 *
104 * 23 7/09/98 8:34p Samir
105 * added argument to callback for streams.
106 *
107 * 22 6/29/98 9:29a Chris
108 * Added some support for Direct Sound 3d
109 *
110 * 21 6/24/98 12:09p Chris
111 * Update
112 *
113 * 20 6/22/98 12:00p Chris
114 * Working on sound system to make it in a nice shape.
115 *
116 * 19 6/19/98 3:03p Chris
117 * Made CheckAndForceSoundDataAlloc a SoundSystem function - useful for
118 * multiple mixers. Added IsSoundPlaying to the high level sound lib.
119 *
120 * 18 6/17/98 7:04p Chris
121 * Added support for 8bit stream data to be played by our 16bit sound
122 * mixer
123 *
124 * 17 6/16/98 3:48p Chris
125 * Updated the sound system and added the start of sound streaming
126 *
127 * 16 3/20/98 2:59p Chris
128 * Added a wall hit sound for the player and added support for a base
129 * volume for 3d sounds
130 *
131 * 15 2/27/98 5:31p Chris
132 * Changed how master_volume is set.
133 *
134 * 14 2/23/98 6:32p Chris
135 * Added support for a hlsoundlib unique id. This is what all the public
136 * functions use. Also, looping sounds are now correctly turned off and
137 * on.
138 *
139 * 13 2/15/98 6:41p Chris
140 * Added Update2dSound
141 *
142 * 12 2/13/98 5:15p Chris
143 * Fixed multiple problems with looping sounds not being able to be
144 * stopped
145 *
146 * 11 1/19/98 10:04a Matt
147 * Added new object handle system
148 *
149 * 10 1/13/98 5:08p Chris
150 * Increased sound object limit
151 *
152 * 9 1/06/98 2:12p Chris
153 * Added muffled sounds v.1 and made 3d sounds keep their roomnum.
154 *
155 * 8 1/02/98 5:32p Chris
156 * More radical changes to the sound system
157 *
158 * 7 12/31/97 2:58a Chris
159 * Another major revision to the SoundLib. This cleaned up the code after
160 * removing the direct sound secondary buffers.
161 *
162 * 6 12/30/97 2:15p Chris
163 * Adding further support for software 3d stuff
164 *
165 * 5 12/12/97 11:43a Chris
166 * Added support to toggle sndlib on/off
167 *
168 * 4 12/11/97 12:58p Chris
169 * Added support for fixed 3d position updating sounds.
170 *
171 * 3 12/10/97 4:47p Chris
172 * Revision 1.0 of new sound library (no hardware -- uses primary buffer
173 * streaming)
174 *
175 * 2 11/21/97 1:10p Chris
176 * Incremental Improvements
177 *
178 * 20 6/11/97 1:07p Samir
179 * The removal of gameos and replaced with oeApplication, oeDatabase
180 *
181 * 19 5/22/97 6:18p Chris
182 *
183 * 18 5/22/97 5:15p Chris
184 *
185 * 17 5/15/97 1:59a Chris
186 *
187 * 16 4/29/97 8:03a Chris
188 * Improved the sound code. High-level sound now
189 * fully uses the flags in the sound page and it
190 * resulted in a simpilier coding interface :)
191 *
192 * 15 4/28/97 11:21a Chris
193 * Incremental improvements is the sound system
194 *
195 * 14 4/24/97 3:25a Chris
196 * // Added some more support for 3d sounds
197 *
198 * 13 4/03/97 8:37p Chris
199 * Added the Main_OS object pass in the sound library
200 * initialization code.
201 *
202 * 12 3/15/97 1:34p Chris
203 *
204 * $NoKeywords: $
205 */
206
207 #ifndef __HLSOUNDLIB_H__
208 #define __HLSOUNDLIB_H__cxx . . $ `sndlib/hlsoundlib.h:208:9`!
209
210 #include "ssl_lib.h"cxx . . $ `<file>/sndlib/ssl_lib.h`/
211 #include "object.h"cxx . . $ `<file>/Descent3/object.h`/
212
213 //////////////////////////////////////////////////////////////////////////
214
215 #define MAX_SOUNDS_MIXEDcxx . . $ `sndlib/hlsoundlib.h:215:9`! 40
216 #define MIN_SOUNDS_MIXEDcxx . . $ `sndlib/hlsoundlib.h:216:9`! 20
217 #define MAX_SOUND_OBJECTScxx . . $ `sndlib/hlsoundlib.h:217:9`! 3000
218
219 extern char Sound_qualitycxx . . $ Sound_quality.;
220 extern char Sound_mixercxx . . $ Sound_mixer.;
221 extern char Sound_card_namecxx . . $ Sound_card_name.[];
222
223 class sound_objectcxx . . $ sound_object# {
224 public:
225 sound_objectcxx . . $ sound_object#sound_object(49f6e7a06ebc5aa8).() { m_obj_type_flagscxx . . $ sound_object#m_obj_type_flags. = SIF_UNUSEDcxx . . $ `sndlib/ssl_lib.h:377:9`!; }
226
227 public:
228 uint32_tcxx . . $ uint32_t# m_obj_type_flagscxx . . $ sound_object#m_obj_type_flags.;
229 int m_sound_uidcxx . . $ sound_object#m_sound_uid.;
230 int m_sound_indexcxx . . $ sound_object#m_sound_index.;
231 int m_hlsound_uidcxx . . $ sound_object#m_hlsound_uid.;
232
233 play_informationcxx . . $ play_information# play_infocxx . . $ sound_object#play_info.;
234
235 float volume_3dcxx . . $ sound_object#volume_3d.; // Used so that 3d sounds can have a base volume (for 2d this is in play_information)
236
237 unioncxx . . $ sound_object#$anonymous_type_0# {
238 structcxx . . $ sound_object#$anonymous_type_0#$anonymous_type_1# {
239 int segnumcxx . . $ sound_object#$anonymous_type_0#$anonymous_type_1#segnum.; // Use physics' bit-bit stuff (inside/outside)
240 vectorcxx . . $ vector# poscxx . . $ sound_object#$anonymous_type_0#$anonymous_type_1#pos.;
241 matrixcxx . . $ matrix# orientcxx . . $ sound_object#$anonymous_type_0#$anonymous_type_1#orient.; // only need pitch and heading -- not roll (sound cones are symetrical)
242 } pos_infocxx . . $ sound_object#$anonymous_type_0#pos_info.;
243
244 int object_handlecxx . . $ sound_object#$anonymous_type_0#object_handle.;
245 } m_link_infocxx . . $ sound_object#m_link_info.;
246 };
247
248 class hlsSystemcxx . . $ hlsSystem# {
249 int m_f_hls_system_initcxx . . $ hlsSystem#m_f_hls_system_init.;
250
251 class sound_objectcxx . . $ sound_object# m_sound_objectscxx . . $ hlsSystem#m_sound_objects.[MAX_SOUND_OBJECTScxx . . $ `sndlib/hlsoundlib.h:217:9`!];
252
253 float m_master_volumecxx . . $ hlsSystem#m_master_volume.;
254 int m_sounds_playedcxx . . $ hlsSystem#m_sounds_played.;
255
256 bool m_pause_newcxx . . $ hlsSystem#m_pause_new.;
257 uint8_tcxx . . $ uint8_t# m_cur_environmentcxx . . $ hlsSystem#m_cur_environment.; // current environment being played.
258 int n_lls_soundscxx . . $ hlsSystem#n_lls_sounds.; // number of sounds that we want the low level mixer to mix.
259
260 bool Emulate3dSoundcxx . . $ hlsSystem#Emulate3dSound(83c267b20bac841a).(int sound_obj_index);
261 bool ComputePlayInfocxx . . $ hlsSystem#ComputePlayInfo(371168a55a5b4ad5).(int sound_obj_index, vectorcxx . . $ vector# *virtual_pos, vectorcxx . . $ vector# *virtual_vel, float *adjusted_volume);
262
263 inline int MakeUniqueIdcxx . . $ hlsSystem#MakeUniqueId(7864480464b09eea).(int sound_obj_index);
264 inline int ValidateUniqueIdcxx . . $ hlsSystem#ValidateUniqueId(7864480464b09eea).(int hl_sound_uid);
265
266 // Forcefully ends a sound
267 void StopSoundcxx . . $ hlsSystem#StopSound(9633529ce3c4ff50).(int sound_obj_index, uint8_tcxx . . $ uint8_t# f_immediately = SKT_STOP_IMMEDIATELYcxx . . $ `sndlib/ssl_lib.h:406:9`!);
268
269 private:
270 int Play3dSoundcxx . . $ hlsSystem#Play3dSound(cef146652f000f45).(int sound_index, pos_statecxx . . $ pos_state# *cur_pos, objectcxx . . $ object# *cur_obj, int priority, float volume, int flags,
271 float offset = 0.0);
272
273 public:
274 // Include a lowel-level sound system
275 class llsSystemcxx . . $ llsSystem# *m_ll_sound_ptrcxx . . $ hlsSystem#m_ll_sound_ptr.;
276
277 hlsSystemcxx . . $ hlsSystem#hlsSystem(49f6e7a06ebc5aa8).(); // {m_f_hls_system_init = 0; m_sounds_played=0; m_master_volume = 1.0; m_pause_new = false;}
278 ~cxx . . $ hlsSystem#`~hlsSystem`(ced63f7c635d850d).hlsSystemcxx . . $ hlsSystem#() { KillSoundLibcxx . . $ hlsSystem#KillSoundLib(b45ddcbc8423892c).(true); }
279
280 bool IsActivecxx . . $ hlsSystem#IsActive(c9857a73d68e59ba).(void);
281
282 // Start and clean-up after the sound library
283 int InitSoundLibcxx . . $ hlsSystem#InitSoundLib(bc2f84f4176dee7e).(oeApplicationcxx . . $ oeApplication# *sos, char mixer_type, char quality, bool f_kill_sound_lib = false);
284 void KillSoundLibcxx . . $ hlsSystem#KillSoundLib(b45ddcbc8423892c).(bool f_kill_sound_list);
285 void SetLLSoundQuantitycxx . . $ hlsSystem#SetLLSoundQuantity(d4f767463ce0a6b3).(int n_sounds);
286 int GetLLSoundQuantitycxx . . $ hlsSystem#GetLLSoundQuantity(b126dc7c1de90089).();
287
288 bool SetLLevelTypecxx . . $ hlsSystem#SetLLevelType(c9857a73d68e59ba).(); // These are
289
290 // Pause and Resume the library
291 void PauseSoundscxx . . $ hlsSystem#PauseSounds(b45ddcbc8423892c).(bool f_all_sounds = false);
292 void ResumeSoundscxx . . $ hlsSystem#ResumeSounds(49f6e7a06ebc5aa8).();
293 void StopAllSoundscxx . . $ hlsSystem#StopAllSounds(49f6e7a06ebc5aa8).();
294
295 // Code for the beginning and ending of a frame of action
296
297 // Begin_sound_frame(listener pos/orient/velocity)
298 // SyncSounds
299 // Do sound pos updates -- IF VOLUME IS LOW AND NOT FOREVER, THEN STOP SOUND
300 // compute echo / reverb
301 // indirect/direct path sounds
302 void BeginSoundFramecxx . . $ hlsSystem#BeginSoundFrame(b45ddcbc8423892c).(bool f_in_game = true);
303
304 // Plays the deffered 3d stuff
305 void EndSoundFramecxx . . $ hlsSystem#EndSoundFrame(49f6e7a06ebc5aa8).();
306
307 // Functions that play a sound
308
309 // 3d functions (we use the sound flags in the page to determine all the cool stuff)
310 // Functions that play a 3d sound -- includes the 2d emulation of 3d sound
311 int Play3dSoundcxx . . $ hlsSystem#Play3dSound(f0f15c88243d8820).(int sound_index, pos_statecxx . . $ pos_state# *cur_pos, float volume = MAX_GAME_VOLUMEcxx . . $ `sndlib/ssl_lib.h:265:9`!, int flags = 0,
312 float offset = 0.0);
313 int Play3dSoundcxx . . $ hlsSystem#Play3dSound(7fd84bfdbf757f76).(int sound_index, objectcxx . . $ object# *cur_obj, float volume = MAX_GAME_VOLUMEcxx . . $ `sndlib/ssl_lib.h:265:9`!, int flags = 0, float offset = 0.0);
314
315 int Play3dSoundcxx . . $ hlsSystem#Play3dSound(cbd2c6aa1db9fc8a).(int sound_index, int priority, pos_statecxx . . $ pos_state# *cur_pos, float volume = MAX_GAME_VOLUMEcxx . . $ `sndlib/ssl_lib.h:265:9`!, int flags = 0,
316 float offset = 0.0);
317 int Play3dSoundcxx . . $ hlsSystem#Play3dSound(17f485224ada8dd7).(int sound_index, int priority, objectcxx . . $ object# *cur_obj, float volume = MAX_GAME_VOLUMEcxx . . $ `sndlib/ssl_lib.h:265:9`!, int flags = 0,
318 float offset = 0.0);
319
320 int PlayStreamcxx . . $ hlsSystem#PlayStream(bf4d5b0c3a7930a0).(int unique_handle, void *data, int size, int stream_format, float volume,
321 void *stream_callback(void *user_data, int handle, int *size) = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!);
322
323 // 2d functions
324 int Play2dSoundcxx . . $ hlsSystem#Play2dSound(d251026853493025).(int sound_index, float volume = MAX_GAME_VOLUMEcxx . . $ `sndlib/ssl_lib.h:265:9`! / 2, float pan = 0.0,
325 uint16_tcxx . . $ uint16_t# frequency = 22050);
326
327 int Play2dSoundcxx . . $ hlsSystem#Play2dSound(7bec394c8d81705d).(int sound_index, int priority, float volume = MAX_GAME_VOLUMEcxx . . $ `sndlib/ssl_lib.h:265:9`! / 2, float pan = 0.0,
328 uint16_tcxx . . $ uint16_t# frequency = 22050);
329
330 int Update2dSoundcxx . . $ hlsSystem#Update2dSound(29af73b9646cef78).(int hlsound_uid, float volume, float pan);
331
332 // Do nice looping stop stuff
333 void StopSoundLoopingcxx . . $ hlsSystem#StopSoundLooping(d4f767463ce0a6b3).(int hlsound_uid);
334 void StopSoundImmediatecxx . . $ hlsSystem#StopSoundImmediate(d4f767463ce0a6b3).(int hlsound_uid);
335
336 // Stop all sounds attached to an object
337 void StopObjectSoundcxx . . $ hlsSystem#StopObjectSound(d4f767463ce0a6b3).(int objhandle);
338
339 // Set the volume for all the sounds attached to an object
340 void SetVolumeObjectcxx . . $ hlsSystem#SetVolumeObject(43c79ee2f1b9aefe).(int objhandle, float volume);
341
342 // Master volume controls for sound effects
343 void SetMasterVolumecxx . . $ hlsSystem#SetMasterVolume(9364e6e7bff7660).(float volume);
344 float GetMasterVolumecxx . . $ hlsSystem#GetMasterVolume(9b8c9e39889c762c).();
345
346 // Queued sound functions
347 void Add2dSoundQueuedcxx . . $ hlsSystem#Add2dSoundQueued(504dd6028cca1fb1).(int q_num, int sound_index, float volume, float pan, uint16_tcxx . . $ uint16_t# frequency);
348 void KillQueuecxx . . $ hlsSystem#KillQueue(d4f767463ce0a6b3).(int q_num = 0);
349 void KillAllQueuescxx . . $ hlsSystem#KillAllQueues(49f6e7a06ebc5aa8).();
350
351 bool CheckAndForceSoundDataAlloccxx . . $ hlsSystem#CheckAndForceSoundDataAlloc(83c267b20bac841a).(int sound_file_index);
352 bool SetSoundQualitycxx . . $ hlsSystem#SetSoundQuality(b5fd09639b7a0261).(char quality);
353 char GetSoundQualitycxx . . $ hlsSystem#GetSoundQuality(6e9c618e4dd2eafc).(void);
354 bool SetSoundMixercxx . . $ hlsSystem#SetSoundMixer(b5fd09639b7a0261).(char mixer_type);
355 char GetSoundMixercxx . . $ hlsSystem#GetSoundMixer(6e9c618e4dd2eafc).(void);
356
357 bool IsSoundPlayingcxx . . $ hlsSystem#IsSoundPlaying(83c267b20bac841a).(int hlsound_uid);
358
359 // Midi play stuff
360 void SetMidiVolumecxx . . $ hlsSystem#SetMidiVolume(49f6e7a06ebc5aa8).();
361 void GetMidiVolumecxx . . $ hlsSystem#GetMidiVolume(49f6e7a06ebc5aa8).();
362 void PlayMidicxx . . $ hlsSystem#PlayMidi(49f6e7a06ebc5aa8).();
363 void StopMidicxx . . $ hlsSystem#StopMidi(49f6e7a06ebc5aa8).();
364 void PauseMidicxx . . $ hlsSystem#PauseMidi(49f6e7a06ebc5aa8).();
365 void ResumeMidicxx . . $ hlsSystem#ResumeMidi(49f6e7a06ebc5aa8).();
366 };
367
368 extern hlsSystemcxx . . $ hlsSystem# Sound_systemcxx . . $ Sound_system.;
369
370 //////////////////////////////////////////////////////////////////////////
371 // ENVIRONMENTAL REVERB PRESETS
372
373 #define N_ENVAUDIO_PRESETScxx . . $ `sndlib/hlsoundlib.h:373:9`! 26
374
375 #define ENVAUD_PRESET_NONEcxx . . $ `sndlib/hlsoundlib.h:375:9`! 0
376 #define ENVAUD_PRESET_PADDEDCELLcxx . . $ `sndlib/hlsoundlib.h:376:9`! 1
377 #define ENVAUD_PRESET_ROOMcxx . . $ `sndlib/hlsoundlib.h:377:9`! 2
378 #define ENVAUD_PRESET_BATHROOMcxx . . $ `sndlib/hlsoundlib.h:378:9`! 3
379 #define ENVAUD_PRESET_LIVINGROOMcxx . . $ `sndlib/hlsoundlib.h:379:9`! 4
380 #define ENVAUD_PRESET_STONEROOMcxx . . $ `sndlib/hlsoundlib.h:380:9`! 5
381 #define ENVAUD_PRESET_AUDITORIUMcxx . . $ `sndlib/hlsoundlib.h:381:9`! 6
382 #define ENVAUD_PRESET_CONCERTHALLcxx . . $ `sndlib/hlsoundlib.h:382:9`! 7
383 #define ENVAUD_PRESET_CAVEcxx . . $ `sndlib/hlsoundlib.h:383:9`! 8
384 #define ENVAUD_PRESET_ARENAcxx . . $ `sndlib/hlsoundlib.h:384:9`! 9
385 #define ENVAUD_PRESET_HANGARcxx . . $ `sndlib/hlsoundlib.h:385:9`! 10
386 #define ENVAUD_PRESET_CARPETEDHALLWAYcxx . . $ `sndlib/hlsoundlib.h:386:9`! 11
387 #define ENVAUD_PRESET_HALLWAYcxx . . $ `sndlib/hlsoundlib.h:387:9`! 12
388 #define ENVAUD_PRESET_STONECORRIDORcxx . . $ `sndlib/hlsoundlib.h:388:9`! 13
389 #define ENVAUD_PRESET_ALLEYcxx . . $ `sndlib/hlsoundlib.h:389:9`! 14
390 #define ENVAUD_PRESET_FORESTcxx . . $ `sndlib/hlsoundlib.h:390:9`! 15
391 #define ENVAUD_PRESET_CITYcxx . . $ `sndlib/hlsoundlib.h:391:9`! 16
392 #define ENVAUD_PRESET_MOUNTAINScxx . . $ `sndlib/hlsoundlib.h:392:9`! 17
393 #define ENVAUD_PRESET_QUARRYcxx . . $ `sndlib/hlsoundlib.h:393:9`! 18
394 #define ENVAUD_PRESET_PLAINcxx . . $ `sndlib/hlsoundlib.h:394:9`! 19
395 #define ENVAUD_PRESET_PARKINGLOTcxx . . $ `sndlib/hlsoundlib.h:395:9`! 20
396 #define ENVAUD_PRESET_SEWERPIPEcxx . . $ `sndlib/hlsoundlib.h:396:9`! 21
397 #define ENVAUD_PRESET_UNDERWATERcxx . . $ `sndlib/hlsoundlib.h:397:9`! 22
398 #define ENVAUD_PRESET_DRUGGEDcxx . . $ `sndlib/hlsoundlib.h:398:9`! 23
399 #define ENVAUD_PRESET_DIZZYcxx . . $ `sndlib/hlsoundlib.h:399:9`! 24
400 #define ENVAUD_PRESET_PSYCHOTICcxx . . $ `sndlib/hlsoundlib.h:400:9`! 25
401
402 #endif