| 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/ssl_lib.h $ |
| 21 | * $Revision: 57 $ |
| 22 | * $Date: 3/20/00 12:27p $ |
| 23 | * $Author: Matt $ |
| 24 | * |
| 25 | * Header for shared sound library |
| 26 | * |
| 27 | * $Log: /DescentIII/Main/lib/ssl_lib.h $ |
| 28 | * |
| 29 | * 57 3/20/00 12:27p Matt |
| 30 | * Merge of Duane's post-1.3 changes. |
| 31 | * Lower MAX_SOUNDS and MAX_SOUND_FILES for Mac. |
| 32 | * |
| 33 | * 56 10/23/99 3:24p 3dsmax |
| 34 | * |
| 35 | * 55 10/21/99 4:05p Chris |
| 36 | * Removed a bad thing |
| 37 | * |
| 38 | * 54 10/21/99 1:48p Kevin |
| 39 | * Mac Merge |
| 40 | * |
| 41 | * 53 10/08/99 4:29p Chris |
| 42 | * Added the forcefield and glass breaking override options |
| 43 | * |
| 44 | * 52 8/23/99 5:29p Samir |
| 45 | * incremental EAX 2.0 checkin |
| 46 | * |
| 47 | * 51 8/10/99 2:08p Gwar |
| 48 | * added sound support to neweditor |
| 49 | * |
| 50 | * 50 5/20/99 1:00a Samir |
| 51 | * changes in ordering of EAX and NONE mixers. |
| 52 | * |
| 53 | * 49 5/11/99 2:08a 3dsmax |
| 54 | * |
| 55 | * 48 5/11/99 2:05a 3dsmax |
| 56 | * Increased MAX_SOUNDS so we can work |
| 57 | * |
| 58 | * 47 4/30/99 12:56p Kevin |
| 59 | * Lowered values for MAX_SOUNDS, MAX_ROOMS, MAX_TEXTURES and MAX_OBJIDS. |
| 60 | * Talk to me before changing any of these again. |
| 61 | * |
| 62 | * 46 4/27/99 2:10p Samir |
| 63 | * added code to set the desired sound card given the descriptive name of |
| 64 | * a sound card. |
| 65 | * |
| 66 | * 45 4/14/99 3:43p Matt |
| 67 | * Increased the number of sounds from 700 to 750. When I lowered this |
| 68 | * number to 700 recently, I counted that we were using around 600 sounds. |
| 69 | * Either I miscounted or we added a lot of sounds in the last few days. |
| 70 | * |
| 71 | * 44 4/11/99 5:04p Matt |
| 72 | * Reduced the maximum number of sounds from 1000 to 700. Currently we're |
| 73 | * only using 607 sounds, and the new static sound remapping code doesn't |
| 74 | * require any extra space, so 700 is probably ok for now at least. |
| 75 | * |
| 76 | * 43 4/10/99 5:09p Samir |
| 77 | * beginning to add prioritization of sounds code. currently non |
| 78 | * functional, but allows me to change all calls to Play3dSound so that I |
| 79 | * can test later. |
| 80 | * |
| 81 | * 42 4/06/99 8:29p Samir |
| 82 | * added error check system. |
| 83 | * |
| 84 | * 41 3/30/99 4:44p Matt |
| 85 | * Increased max sounds from 700 to 1000 |
| 86 | * |
| 87 | * 40 3/29/99 11:01a Samir |
| 88 | * added prototypes for 3d sound environment options. |
| 89 | * |
| 90 | * 39 3/17/99 4:20p Samir |
| 91 | * added functions to pause and resume individual sounds. |
| 92 | * |
| 93 | * 38 1/14/99 6:10p Samir |
| 94 | * added DirectSound buffer duplication code. |
| 95 | * |
| 96 | * 37 1/11/99 5:51p Samir |
| 97 | * reverb on the buffer level. |
| 98 | * |
| 99 | * 36 1/08/99 6:31p Samir |
| 100 | * added reverb |
| 101 | * |
| 102 | * 35 12/23/98 11:49a Samir |
| 103 | * added EAX mixer. |
| 104 | * |
| 105 | * 34 10/28/98 3:56p Chris |
| 106 | * |
| 107 | * 33 10/28/98 3:55p Chris |
| 108 | * Resized the buffers |
| 109 | * |
| 110 | * 32 10/19/98 11:57a Chris |
| 111 | * Update the sound system to use the import volume |
| 112 | * |
| 113 | * 31 10/14/98 5:12p Samir |
| 114 | * added a null SOUND_MIXER. |
| 115 | * |
| 116 | * 30 8/10/98 5:55p Samir |
| 117 | * added element in play_info to specify streaming buffer size. |
| 118 | * |
| 119 | * 29 7/24/98 5:23p Samir |
| 120 | * moved sound variables from soundload to ssl_lib.h (and WAV file stuff) |
| 121 | * |
| 122 | * 28 7/09/98 8:34p Samir |
| 123 | * added parameter to play_information. |
| 124 | * |
| 125 | * 27 7/06/98 1:49p Samir |
| 126 | * added some error checking. |
| 127 | * |
| 128 | * 26 6/29/98 10:44p Chris |
| 129 | * Added support for SIF_ONCE_PER_OBJ |
| 130 | * |
| 131 | * 25 6/29/98 7:35p Chris |
| 132 | * Increased sound buffer size |
| 133 | * |
| 134 | * 24 6/29/98 4:15p Chris |
| 135 | * Streaming audio works |
| 136 | * |
| 137 | * 23 6/29/98 9:29a Chris |
| 138 | * Added some support for Direct Sound 3d |
| 139 | * |
| 140 | * 22 6/25/98 11:28a Chris |
| 141 | * Added some DS3d support |
| 142 | * |
| 143 | * 21 6/24/98 6:43p Chris |
| 144 | * Furthered the endless work on the sound system |
| 145 | * |
| 146 | * 20 6/22/98 12:00p Chris |
| 147 | * Working on sound system to make it in a nice shape. |
| 148 | * |
| 149 | * 19 6/19/98 3:09p Chris |
| 150 | * Improved IsSoundPlaying |
| 151 | * |
| 152 | * 18 6/19/98 3:03p Chris |
| 153 | * Made CheckAndForceSoundDataAlloc a SoundSystem function - useful for |
| 154 | * multiple mixers. Added IsSoundPlaying to the high level sound lib. |
| 155 | * |
| 156 | * 17 6/17/98 7:04p Chris |
| 157 | * Added support for 8bit stream data to be played by our 16bit sound |
| 158 | * mixer |
| 159 | * |
| 160 | * 16 6/17/98 4:39p Chris |
| 161 | * Added the playing of 8bit samples with the 16 bit sound mixer |
| 162 | * |
| 163 | * 15 6/16/98 4:46p Chris |
| 164 | * Revision 2 of the stream audio stuff |
| 165 | * |
| 166 | * 14 6/16/98 3:48p Chris |
| 167 | * Updated the sound system and added the start of sound streaming |
| 168 | * |
| 169 | * 13 2/15/98 7:12p Chris |
| 170 | * More improvements to the sound lib |
| 171 | * |
| 172 | * 12 2/04/98 6:09p Matt |
| 173 | * Changed object room number to indicate a terrain cell via a flag. Got |
| 174 | * rid of the object flag which used to indicate terrain. |
| 175 | * |
| 176 | * 11 1/06/98 2:12p Chris |
| 177 | * Added muffled sounds v.1 and made 3d sounds keep their roomnum. |
| 178 | * |
| 179 | * 10 1/05/98 3:54p Chris |
| 180 | * Added ambient and explosion sounds |
| 181 | * |
| 182 | * 9 1/02/98 5:32p Chris |
| 183 | * More radical changes to the sound system |
| 184 | * |
| 185 | * 8 12/31/97 2:58a Chris |
| 186 | * Another major revision to the SoundLib. This cleaned up the code after |
| 187 | * removing the direct sound secondary buffers. |
| 188 | * |
| 189 | * 7 12/30/97 2:15p Chris |
| 190 | * Adding further support for software 3d stuff |
| 191 | * |
| 192 | * 6 12/29/97 4:50p Chris |
| 193 | * Added SPF_NO_UPDATE |
| 194 | * |
| 195 | * 5 12/22/97 6:19p Chris |
| 196 | * Working on new mixer functionality |
| 197 | * |
| 198 | * 4 12/18/97 12:26p Chris |
| 199 | * Incremental new lib improvements |
| 200 | * |
| 201 | * 3 12/10/97 4:47p Chris |
| 202 | * Revision 1.0 of new sound library (no hardware -- uses primary buffer |
| 203 | * streaming) |
| 204 | * |
| 205 | * 2 11/21/97 1:10p Chris |
| 206 | * Incremental Improvements |
| 207 | * |
| 208 | * 18 6/11/97 2:31p Samir |
| 209 | * Incorporated changes in gameos to new system |
| 210 | * |
| 211 | * 17 5/22/97 5:15p Chris |
| 212 | * |
| 213 | * 16 5/05/97 5:41a Chris |
| 214 | * Changed an include for MacMAN! |
| 215 | * |
| 216 | * 15 4/29/97 8:03a Chris |
| 217 | * Improved the sound code. High-level sound now |
| 218 | * fully uses the flags in the sound page and it |
| 219 | * resulted in a simpilier coding interface :) |
| 220 | * |
| 221 | * 14 4/28/97 11:21a Chris |
| 222 | * Incremental improvements is the sound system |
| 223 | * |
| 224 | * 13 4/24/97 4:19a Chris |
| 225 | * Modified the pos_state struct to be more compact. |
| 226 | * |
| 227 | * 12 4/24/97 3:25a Chris |
| 228 | * // Added some more support for 3d sounds |
| 229 | * |
| 230 | * 11 4/03/97 8:37p Chris |
| 231 | * Added the Main_OS object pass in the sound library |
| 232 | * initialization code. |
| 233 | * |
| 234 | * 10 4/01/97 2:13p Jason |
| 235 | * changes for sound page functionality |
| 236 | * |
| 237 | * 9 4/01/97 10:00a Chris |
| 238 | * |
| 239 | * 8 3/17/97 5:12p Chris |
| 240 | * Allowed new sound code to be demo'ed. |
| 241 | * |
| 242 | * 7 3/14/97 12:10p Chris |
| 243 | * Made a nice C++ abstract type for the low-level. It should make the |
| 244 | * MacMan very joyful. :) |
| 245 | * |
| 246 | * 6 2/07/97 5:48p Matt |
| 247 | * Renamed vector.h to vecmat.h to fix DevStudio problem |
| 248 | * |
| 249 | * $NoKeywords: $ |
| 250 | */ |
| 251 | |
| 252 | #ifndef __SSL_LIB_H__ |
| 253 | #define __SSL_LIB_H__ |
| 254 | |
| 255 | #include "vecmat.h" |
| 256 | |
| 257 | #ifndef NEWEDITOR |
| 258 | #include "manage.h" |
| 259 | #else |
| 260 | #include "..\neweditor\ned_TableFile.h" |
| 261 | #endif |
| 262 | |
| 263 | class oeApplication; // reference to oeApplication class. |
| 264 | |
| 265 | #define MAX_GAME_VOLUME 1.0f // helps against clipping |
| 266 | |
| 267 | // Size of streaming buffers |
| 268 | #define STREAM_BUFFER_SIZE 4096 //(4 * 1024) |
| 269 | |
| 270 | // object information needed by the sound code. Calling code should copy data into here & pass to sound |
| 271 | struct pos_state { |
| 272 | vector *position; // Where in the world is this object |
| 273 | matrix *orient; |
| 274 | vector *velocity; |
| 275 | int roomnum; |
| 276 | }; |
| 277 | |
| 278 | // #define MAX_EFFECT_OFFSETS 5 |
| 279 | |
| 280 | // sound priority values. |
| 281 | #define SND_PRIORITY_CRITICAL 5 // usually streams have this priority, bumps off any other sounds. |
| 282 | #define SND_PRIORITY_HIGHEST 4 |
| 283 | #define SND_PRIORITY_HIGH 3 |
| 284 | #define SND_PRIORITY_NORMAL 2 |
| 285 | #define SND_PRIORITY_LOW 1 |
| 286 | #define SND_PRIORITY_LOWEST 0 |
| 287 | |
| 288 | struct play_information { |
| 289 | |
| 290 | void *(*m_stream_cback)(void *user_data, int handle, int *size); // Streaming callback |
| 291 | void *m_stream_data; // passed in |
| 292 | int m_stream_size; // passed in |
| 293 | int m_stream_handle; // passed in |
| 294 | int m_stream_bufsize; // passed in |
| 295 | void *user_data; // this is passed to the stream callback by the caller that defined this. |
| 296 | |
| 297 | uint8_t sample_skip_interval; // Allows us to skip samples (i.e. simulate lower sampling rates) |
| 298 | uint8_t priority; // priority of sound. |
| 299 | uint16_t m_stream_format; // passed in |
| 300 | |
| 301 | // internal data. |
| 302 | int m_samples_played; |
| 303 | |
| 304 | float samples_per_22khz_sample; // passed in |
| 305 | float left_volume; |
| 306 | float right_volume; |
| 307 | |
| 308 | float m_ticks; |
| 309 | }; |
| 310 | |
| 311 | struct sound_file_info { |
| 312 | char name[PAGENAME_LEN]; |
| 313 | char used; |
| 314 | int use_count; // how many buffers does this sound take up. |
| 315 | |
| 316 | uint8_t *sample_8bit; // 8bit sound data |
| 317 | int16_t *sample_16bit; // 16bit sound data |
| 318 | |
| 319 | int sample_length; // Length of sound in samples |
| 320 | int np_sample_length; // non-padded |
| 321 | |
| 322 | }; |
| 323 | |
| 324 | struct sound_info { |
| 325 | char name[PAGENAME_LEN]; |
| 326 | char used; |
| 327 | |
| 328 | int sample_index; |
| 329 | |
| 330 | int loop_start; // Start byte of repeated loop for looping samples |
| 331 | int loop_end; // End byte of repeating loop for looping samples |
| 332 | uint32_t flags; // 2d/3d, variable frequency |
| 333 | float max_distance; // Maximum distance in which a sound is heard |
| 334 | float min_distance; // Sound gets no louder at min_distance |
| 335 | int inner_cone_angle; // Angle in which sound is played at full base volume |
| 336 | int outer_cone_angle; // Angle in which sound is at its lowest base volume |
| 337 | float outer_cone_volume; // A sounds lowest base volume level |
| 338 | float import_volume; // Volume multiplier |
| 339 | }; |
| 340 | |
| 341 | // Supported sound mixers |
| 342 | #define SOUND_MIXER_SOFTWARE_16 0 |
| 343 | #define SOUND_MIXER_DS_16 1 |
| 344 | #define SOUND_MIXER_DS_8 2 |
| 345 | #define SOUND_MIXER_DS3D_16 3 |
| 346 | #define SOUND_MIXER_AUREAL 4 // Unused, outdated 3D sound technology |
| 347 | #define SOUND_MIXER_CREATIVE_EAX 6 // switched because launcher uses 5 as NONE. |
| 348 | #define SOUND_MIXER_NONE 5 |
| 349 | |
| 350 | // Support sound qualities |
| 351 | #define SQT_NORMAL 0 |
| 352 | #define SQT_HIGH 1 |
| 353 | // Parameters of the sound library |
| 354 | #define SLF_USE_3D 1 // Use 3d effects |
| 355 | #define SLF_DELTA_FREQ 2 // Use frequency shifts (i.e. water effects) |
| 356 | #define SLF_USE_16_BIT 4 // Use 16bit samples (else 8bit) |
| 357 | #define SLF_USE_22_KHZ 8 // Use 22khz (else 44khz) |
| 358 | #define SLF_PAUSED 16 // Sound library is currently paused |
| 359 | #define SLF_FULL_3D 32 // Full 3d hardware support |
| 360 | #define SLF_MOST_3D 64 // No fully static 3d -- i.e. cockpit type stuff (use 2d instead) |
| 361 | #define SLF_LIGHT_3D 128 // Dynamically updating 3d sounds if sound is longer than a given threshold |
| 362 | #define SLF_GOOD_2D 256 // all linked sounds update position |
| 363 | #define SLF_OK_2D 512 // if a sound is longer than a threshold, it updates |
| 364 | |
| 365 | // Sound Properties Flags |
| 366 | #define SPF_LOOPED 1 // Sound is looped |
| 367 | #define SPF_FIXED_FREQ 2 // No doppler shift |
| 368 | #define SPF_OBJ_UPDATE 4 // Sound updates with attached object movements |
| 369 | #define SPF_FOREVER 8 // Always plays in high-level, this flag should be ignored in low-level |
| 370 | #define SPF_PLAYS_EXCLUSIVELY 16 |
| 371 | #define SPF_PLAYS_ONCE 32 |
| 372 | #define SPF_USE_CONE 64 |
| 373 | #define SPF_LISTENER_UPDATE 128 // Sound updates with listener movements |
| 374 | #define SPF_ONCE_PER_OBJ 256 |
| 375 | |
| 376 | // Sound Instance flags (Move this out of here) |
| 377 | #define SIF_UNUSED 0 // Not a valid sound item |
| 378 | #define SIF_PLAYING_2D 1 // Sound is currently playing |
| 379 | #define SIF_PLAYING_3D 2 |
| 380 | #define SIF_OBJ_UPDATE 4 |
| 381 | #define SIF_TOO_FAR 8 // We will play it, but it currently too far away(stop sound in low-level) |
| 382 | #define SIF_NO_3D_EFFECTS 16 |
| 383 | #define SIF_LOOPING 32 |
| 384 | #define SIF_STREAMING_8_M 64 |
| 385 | #define SIF_STREAMING_16_M 128 |
| 386 | #define SIF_STREAMING_8_S 256 |
| 387 | #define SIF_STREAMING_16_S 512 |
| 388 | #define SIF_STREAMING (64 | 128 | 256 | 512) |
| 389 | |
| 390 | // What is the sound cone linked to (and mask to make it else to look at the important bits) |
| 391 | #define SPFT_CONE_LINK_MASK 0x00000300 |
| 392 | #define SPFT_CONE_LINK_OBJECT 0x00000000 |
| 393 | #define SPFT_CONE_LINK_TURRET1 0x00000100 |
| 394 | #define SPFT_CONE_LINK_TURRET2 0x00000200 |
| 395 | #define SPFT_CONE_LINK_TURRET3 0x00000300 |
| 396 | |
| 397 | // Direction of the sound cone relative to its link (and mask to make it else to look at the important bits) |
| 398 | #define SPFT_CONE_DIR_MASK 0x00000C00 |
| 399 | #define SPFT_CONE_DIR_FORWARD 0x00000000 |
| 400 | #define SPFT_CONE_DIR_BACKWARD 0x00000400 |
| 401 | #define SPFT_CONE_DIR_UPWARD 0x00000800 |
| 402 | #define SPFT_CONE_DIR_DOWNWARD 0x00000C00 |
| 403 | |
| 404 | // Sound kill types |
| 405 | #define SKT_STOP_AFTER_LOOP 0 // Allows a looping sample to play until the end of the sample |
| 406 | #define SKT_STOP_IMMEDIATELY 1 // Stops and cleans up after a sound (For StopAllSounds) |
| 407 | #define SKT_HOLD_UNTIL_STOP 2 // Hold until sound stops. |
| 408 | |
| 409 | // Sound Library Internal Error Codes |
| 410 | #define SSL_OK 0 |
| 411 | #define SSL_ERROR_GENERIC (-1) |
| 412 | #define SSL_ERROR_SAMPLE_NODATA (-2) |
| 413 | #define SSL_ERROR_STREAMMIXER (-3) |
| 414 | |
| 415 | // Sound Status |
| 416 | #define SSF_UNUSED 0 |
| 417 | #define SSF_PLAY_NORMAL 1 |
| 418 | #define SSF_PLAY_LOOPING 2 |
| 419 | #define SSF_PAUSED 4 |
| 420 | #define SSF_PLAY_STREAMING 8 |
| 421 | #define SSF_BUFFERED_LOOP 64 |
| 422 | #define SSF_BUFFERED_STRM 128 |
| 423 | |
| 424 | #define SBT_PRIMARY 0 |
| 425 | #define SBT_2D 1 |
| 426 | #define SBT_3D 2 |
| 427 | |
| 428 | // looping methods |
| 429 | #define DSLOOP_SMART_METHOD 0 |
| 430 | #define DSLOOP_BUFFER_METHOD 1 |
| 431 | #define DSLOOP_STREAM_METHOD 2 |
| 432 | |
| 433 | #define DSBUFLOOP_INIT_STEP (-1) |
| 434 | #define DSBUFLOOP_LOOP_STEP 0 |
| 435 | #define DSBUFLOOP_FINISH_STEP 1 |
| 436 | |
| 437 | // used to time threads. |
| 438 | |
| 439 | // This is the update rate at which to call sound_mixer::DoFrame() |
| 440 | // (sleep this amount each frame of the thread) |
| 441 | #define DSPB_TICK_INTERVAL .01 // Primary buffer update rate (in seconds) |
| 442 | #define DSPB_TICK_MILLISECONDS (DSPB_TICK_INTERVAL * 1000) |
| 443 | |
| 444 | |
| 445 | // structure to get and set environment values |
| 446 | #define ENV3DVALF_DOPPLER 1 |
| 447 | #define ENV3DVALF_GEOMETRY 2 |
| 448 | |
| 449 | struct t3dEnvironmentValues { |
| 450 | int flags; // use flags above |
| 451 | |
| 452 | float doppler_scalar; // values from 0.0f to ???? (1.0f = normal) |
| 453 | }; |
| 454 | |
| 455 | struct t3dEnvironmentToggles { |
| 456 | int flags; // use flags above |
| 457 | int supported; // returns flag values to inform caller of supported features (doppler, ie.) |
| 458 | |
| 459 | bool doppler; // state of doppler effects |
| 460 | bool geometry; // support hardware geometry |
| 461 | }; |
| 462 | |
| 463 | ///////////////////////////////////////////////////////////////////////////////// |
| 464 | // Looping constants |
| 465 | |
| 466 | class llsGeometry; |
| 467 | |
| 468 | class llsSystem { |
| 469 | protected: |
| 470 | llsGeometry *m_geometry; // geometry object. |
| 471 | int m_lib_error_code; // library error code |
| 472 | char m_error_text[512]; // text for error. |
| 473 | |
| 474 | protected: |
| 475 | void SetError(int code) { m_lib_error_code = code; }; |
| 476 | void ErrorText(const char *fmt, ...); // error text function called inside library. a stack is kept of errors |
| 477 | virtual void CheckForErrors(); // called by sound library every frame to reset error count. |
| 478 | |
| 479 | // Public functions |
| 480 | public: |
| 481 | llsSystem(); |
| 482 | virtual ~llsSystem() = default; |
| 483 | |
| 484 | // may be called before init (must be to be valid, the card passed here will be initialized in InitSoundLib) |
| 485 | virtual void SetSoundCard(const char *name) = 0; |
| 486 | |
| 487 | // Starts the sound library, maybe have it send back some information -- 3d support? |
| 488 | virtual int InitSoundLib(char mixer_type, oeApplication *sos, uint8_t max_sounds_played) = 0; |
| 489 | // Cleans up after the Sound Library |
| 490 | virtual void DestroySoundLib() = 0; |
| 491 | |
| 492 | // Locks and unlocks sounds (used when changing play_info data) |
| 493 | virtual bool LockSound(int sound_uid) = 0; |
| 494 | virtual bool UnlockSound(int sound_uid) = 0; |
| 495 | |
| 496 | virtual bool SetSoundQuality(char quality) = 0; |
| 497 | virtual char GetSoundQuality() = 0; |
| 498 | virtual bool SetSoundMixer(char mixer_type) = 0; |
| 499 | virtual char GetSoundMixer() = 0; |
| 500 | |
| 501 | // Plays a 2d sound |
| 502 | virtual int PlaySound2d(play_information *play_info, int sound_index, float volume, float pan, bool f_looped) = 0; |
| 503 | virtual int PlayStream(play_information *play_info) = 0; |
| 504 | |
| 505 | virtual void SetListener(pos_state *cur_pos) = 0; |
| 506 | virtual int PlaySound3d(play_information *play_info, int sound_index, pos_state *cur_pos, float master_volume, |
| 507 | bool f_looped, float reverb = 0.5f) = 0; //, uint16_t frequency) |
| 508 | virtual void AdjustSound(int sound_uid, float f_volume, float f_pan, uint16_t frequency) = 0; |
| 509 | virtual void AdjustSound(int sound_uid, pos_state *cur_pos, float adjusted_volume, float reverb = 0.5f) = 0; |
| 510 | |
| 511 | virtual void StopAllSounds() = 0; |
| 512 | |
| 513 | // Checks if a sound is playing (removes finished sound); |
| 514 | virtual bool IsSoundInstancePlaying(int sound_uid) = 0; |
| 515 | virtual int IsSoundPlaying(int sound_index) = 0; |
| 516 | |
| 517 | // virtual void AdjustSound(int sound_uid, play_information *play_info) = 0; |
| 518 | |
| 519 | // Stops 2d and 3d sounds |
| 520 | virtual void StopSound(int sound_uid, uint8_t f_immediately = SKT_STOP_IMMEDIATELY) = 0; |
| 521 | |
| 522 | // Pause all sounds/resume all sounds |
| 523 | virtual void PauseSounds() = 0; |
| 524 | virtual void ResumeSounds() = 0; |
| 525 | virtual void PauseSound(int sound_uid) = 0; |
| 526 | virtual void ResumeSound(int sound_uid) = 0; |
| 527 | |
| 528 | virtual bool CheckAndForceSoundDataAlloc(int sound_file_index) = 0; |
| 529 | |
| 530 | // Begin sound frame |
| 531 | virtual void SoundStartFrame() = 0; |
| 532 | |
| 533 | // End sound frame |
| 534 | virtual void SoundEndFrame() = 0; |
| 535 | |
| 536 | // Returns current error code |
| 537 | int GetLastError() { |
| 538 | int code = m_lib_error_code; |
| 539 | m_lib_error_code = 0; |
| 540 | return code; |
| 541 | }; |
| 542 | |
| 543 | // environmental sound interface |
| 544 | // volume modifier (0-1), damping(0-1), 1 = complete, 0 = none |
| 545 | // decay 0.1 to 100 seconds, how long it takes for a sound to die. |
| 546 | virtual bool SetGlobalReverbProperties(float volume, float damping, float decay) = 0; |
| 547 | |
| 548 | // set special parameters for the 3d environment. |
| 549 | // of strcuture passed, you must set the appropriate 'flags' value for values you wish to modify |
| 550 | virtual void SetEnvironmentValues(const t3dEnvironmentValues *env) = 0; |
| 551 | |
| 552 | // get special parameters for the 3d environment. |
| 553 | // of strcuture passed, you must set the appropriate 'flags' value for values you wish to modify |
| 554 | virtual void GetEnvironmentValues(t3dEnvironmentValues *env) = 0; |
| 555 | |
| 556 | // enable special parameters for the 3d environment. |
| 557 | // of strcuture passed, you must set the appropriate 'flags' value for values you wish to modify |
| 558 | virtual void SetEnvironmentToggles(const t3dEnvironmentToggles *env) = 0; |
| 559 | |
| 560 | // get states of special parameters for the 3d environment. |
| 561 | // of strcuture passed, you must set the appropriate 'flags' value for values you wish to modify |
| 562 | virtual void GetEnvironmentToggles(t3dEnvironmentToggles *env) = 0; |
| 563 | |
| 564 | // returns interface to sound geometry manipulation if available. |
| 565 | virtual llsGeometry *GetGeometryInterface() { return m_geometry; }; |
| 566 | ///////////////////////////////////////////////////////////////////////////////// |
| 567 | // set auxillary 3d sound properties |
| 568 | virtual bool SoundPropertySupport() const { return false; }; |
| 569 | |
| 570 | // sound obstruction from 0 to 1.0 (1.0 = fully obstructed) |
| 571 | virtual void SetSoundProperties(int sound_uid, float obstruction){}; |
| 572 | }; |
| 573 | |
| 574 | // TAKEN FROM SNDLIB SOUNDLOAD.CPP TO SEPARATE CODE REQUIRED BY THE LOWLEVEL SYSTEM AND THE |
| 575 | // HIGH LEVEL SYSTEM - Samir |
| 576 | |
| 577 | #ifndef NEWEDITOR |
| 578 | #define MAX_SOUNDS 1000 |
| 579 | #define MAX_SOUND_FILES 1000 |
| 580 | extern sound_info Sounds[MAX_SOUNDS]; |
| 581 | #else |
| 582 | #include "..\neweditor\ned_Sound.h" |
| 583 | #endif |
| 584 | |
| 585 | extern sound_file_info SoundFiles[MAX_SOUND_FILES]; |
| 586 | |
| 587 | // loads a sound from a wavefile. |
| 588 | char SoundLoadWaveFile(const char *filename, float percent_volume, int sound_file_index, bool f_high_quality, |
| 589 | bool f_load_sample_data, int *e_type = nullptr); |
| 590 | |
| 591 | void SoundLoadFree(int sound_file_index); |
| 592 | |
| 593 | #endif |