Rise
The Vieneo Province
Loading...
Searching...
No Matches
Sound.cpp
Go to the documentation of this file.
1#include "Sound.h"
2#include "WiperAudio.h"
3#include "RainAirAudio.h"
4#include "OwnedAudioStream.h"
6#include "RcsAudio.h"
7#include "bass_fx.h"
8#include "GameClass.h"
10#include "MathUtilities.h"
11
12#include <algorithm>
13#include <cmath>
14#include <cstring>
15#include <filesystem>
16
17namespace
18{
19 HSTREAM CreateFileSound(int soundEnum, const char* path, int& error)
20 {
21 const HSTREAM stream = BASS_StreamCreateFile(FALSE, path, 0, 0, 0);
22 error = BASS_ErrorGetCode();
23 return stream;
24 }
25
26 constexpr float OutdoorEngineReferenceDistanceKm = 0.1f;
27 constexpr float DistantJetMaxAudibleDistanceKmAtOneAtmosphere = 50.0f;
28 constexpr float RocketRippingMaxAudibleDistanceKmAtOneAtmosphere = 80.0f;
29 constexpr float RocketRippingThresholdNewtons = 513000.0f;
30 constexpr float RocketRippingRecordingThrustNewtons = 7607000.0f;
31 constexpr float RocketRippingRecordingDistanceKm = 4.4f;
32 constexpr float RocketRippingThrustExponent = 4.0f;
33
34 bool IsInterfaceSound(SOUNDS soundEnum)
35 {
36 // Settings tests, GUI feedback and toast notifications have no world location.
37 return soundEnum >= SOUND_TEST && soundEnum <= SOUND_NEWSFLASH;
38 }
39
40 bool IsInvalidFloat(float value)
41 {
42 return _isnan(value) || isinf(value);
43 }
44
45 float GetAtmosphericSoundPressureGain(float relativePressure)
46 {
47 if (relativePressure <= 0.0f || IsInvalidFloat(relativePressure))
48 return 0.0f;
49
50 // staticDensity is pressure relative to Vieneo sea level. Convert it to
51 // Earth-atmosphere units and approximate constant-power sound pressure
52 // with sqrt(density). This assumes comparable gas and temperature.
53 const float pressureInAtmospheres = relativePressure * SeaLevelPressureMb / OneAtmosphereMb;
54 return sqrtf(RiseMath::Max(pressureInAtmospheres, 0.0f));
55 }
56
57 float GetOutdoorEngineDistanceGain(float distanceKm)
58 {
59 if (distanceKm <= OutdoorEngineReferenceDistanceKm)
60 return 1.0f;
61
62 // Sound pressure falls approximately in proportion to 1 / distance in
63 // the free field. Preserve the close-pass mix inside 100 m, then use the
64 // same geometric spreading for both outdoor engine layers.
65 return OutdoorEngineReferenceDistanceKm / distanceKm;
66 }
67}
68
70{
71 game = gameptr;
72
73 const DWORD bassVersion = BASS_GetVersion();
74 const DWORD fxVersion = BASS_FX_GetVersion();
75 char versionMessage[128];
76 sprintf_s(versionMessage, sizeof versionMessage, "Audio runtimes: BASS %lu.%lu.%lu.%lu; BASS_FX %lu.%lu.%lu.%lu",
77 bassVersion >> 24, (bassVersion >> 16) & 255, (bassVersion >> 8) & 255, bassVersion & 255,
78 fxVersion >> 24, (fxVersion >> 16) & 255, (fxVersion >> 8) & 255, fxVersion & 255);
79 Trace(versionMessage);
80
81 if (HIWORD(fxVersion) != BASSVERSION)
82 {
83 char msg[99];
84 sprintf_s(msg, sizeof msg, "FX version does not match BASS version: %i", BASSVERSION);
86 }
87
88 Init();
89}
90
92{
93 deviceNames.clear();
94 deviceGuids.clear();
95 deviceBassDevices.clear();
96
97 bool hasDefaultDevice = false;
98 int defaultBassDevice = -1;
99 int count = 0; // the device counter, 0 is no sound
100 BASS_DEVICEINFO info;
101 while (BASS_GetDeviceInfo(count, &info))
102 {
103 const bool isDefaultDevice = (info.flags & BASS_DEVICE_DEFAULT) && info.name && strcmp(info.name, "Default") == 0;
104
105 if (isDefaultDevice)
106 deviceNames.emplace_back("Default");
107 else if (info.flags & BASS_DEVICE_ENABLED)
108 deviceNames.emplace_back(info.name);
109 else
110 deviceNames.emplace_back("DISCONNECTED");
111
112 if (isDefaultDevice)
113 {
114 deviceGuids.emplace_back(MYGUID_DEFAULT);
115 deviceBassDevices.emplace_back(-1);
116 hasDefaultDevice = true;
117 }
118 else if (info.driver)
119 {
120 WCHAR guidText[64];
121 swprintf_s(guidText, 64, L"%S", &info.driver[17]);
122 CLSID clsid;
123 if (CLSIDFromString(guidText, &clsid) == NOERROR)
124 deviceGuids.emplace_back(clsid);
125 else
126 deviceGuids.emplace_back(MYGUID_NULL);
127 }
128 else
129 deviceGuids.emplace_back(MYGUID_NULL);
130
131 if (!isDefaultDevice)
132 deviceBassDevices.emplace_back(count);
133 if (info.flags & BASS_DEVICE_DEFAULT)
134 defaultBassDevice = count;
135
136 count++;
137 }
138
139 if (deviceNames.empty())
140 {
141 deviceNames.emplace_back("No Sound");
142 deviceGuids.emplace_back(MYGUID_NULL);
143 deviceBassDevices.emplace_back(0);
144 }
145
146 if (!hasDefaultDevice && defaultBassDevice > 0)
147 {
148 const size_t defaultDeviceIndex = deviceNames.size() > 1 ? 1 : deviceNames.size();
149 deviceNames.insert(deviceNames.begin() + defaultDeviceIndex, "Default");
150 deviceGuids.insert(deviceGuids.begin() + defaultDeviceIndex, MYGUID_DEFAULT);
151 deviceBassDevices.insert(deviceBassDevices.begin() + defaultDeviceIndex, -1);
152 }
153}
154
155int Sound::GetConfigSelectionIndex(const SoundConfig* deviceConfig) const
156{
157 if (!deviceConfig)
158 return 0;
159
160 for (size_t i = 0; i < deviceGuids.size(); i++)
161 {
162 if (deviceGuids.at(i) == deviceConfig->guid)
163 return static_cast<int>(i);
164 }
165
166 if (deviceConfig->bassDevice)
167 {
168 for (size_t i = 0; i < deviceBassDevices.size(); i++)
169 {
170 if (deviceBassDevices.at(i) == deviceConfig->bassDevice)
171 return static_cast<int>(i);
172 }
173 }
174
175 return 0;
176}
177
179{
180 issuedWarning = false;
181
182 radio = NULL;
183
184 for (short t = 0; t < SOUND_ENUMERATION; t++)
185 {
186 sound_stream[t] = NULL;
187 sound_streamFx[t] = NULL;
188 sound_device[t] = 0;
189 sound_config[t] = nullptr;
190 }
191
192 EnumDevices();
193
194 Trace("Loading legacy sound driver...");
196 Trace("Loading comms sound driver...");
198 Trace("Loading VMU sound driver...");
200 Trace("Loading radio sound driver...");
202}
203
204void Sound::InitDevice(SoundConfig* deviceConfig) // passed in -1
205{
206 if (deviceConfig->guid == MYGUID_NULL)
207 {
208 ReleaseConfigSounds(deviceConfig);
209 deviceConfig->bassDevice = 0;
210 return;
211 }
212
213 const bool useDefaultDevice = deviceConfig->guid == MYGUID_DEFAULT;
214 int bassDevice = -1;
215 std::string deviceName = "Default";
216
217 if (useDefaultDevice)
218 {
219 const int defaultIndex = GetConfigSelectionIndex(deviceConfig);
220 if (defaultIndex >= 0 && defaultIndex < static_cast<int>(deviceBassDevices.size()))
221 {
222 bassDevice = deviceBassDevices.at(defaultIndex);
223 deviceName = deviceNames.at(defaultIndex);
224 }
225 }
226 else
227 {
228 // find the bassDevice from the list of deviceGuids
229 for (UINT i = 0; i < deviceGuids.size(); i++)
230 {
231 if (deviceGuids.at(i) == deviceConfig->guid)
232 {
233 bassDevice = deviceBassDevices.at(i);
234 deviceName = deviceNames.at(i);
235 break;
236 }
237 }
238
239 // didn't find it, what do we do? kill it?
240 if (bassDevice == -1)
241 {
242 WCHAR guidText[64];
243 StringFromGUID2(deviceConfig->guid, guidText, 64);
244 char msg[99];
245 sprintf_s(msg, sizeof msg, "Could not locate previous configuration: %S", guidText);
246 Trace(msg, Logger::Level::Error); // should be warn but we want it to send to server
247
248 if (!issuedWarning)
249 {
250 game->ToggleFullScreen(false);
251 MessageBox(Rendering::ClientWindow(), L"Could not find one of your sound devices!", L"Initialize Sound Device", MB_ICONWARNING | MB_OK);
252 issuedWarning = true;
253 }
254
255 deviceConfig->bassDevice = 0;
256 return;
257 }
258 }
259
260 const int initDevice = useDefaultDevice ? -1 : bassDevice;
261 if (!BASS_Init(initDevice, 44100, BASS_DEVICE_STEREO, Rendering::ClientWindow(), nullptr))
262 {
263 if (BASS_ErrorGetCode() != BASS_ERROR_ALREADY) // to handle the whole -1 as default vs. true device numbers > 0
264 {
265 char msg[199];
266 sprintf_s(msg, sizeof msg, "BASS_Init failed (%i) on device: %s", BASS_ErrorGetCode(), deviceName.c_str());
267 Trace(msg, Logger::Level::Error); // should be warn but we want it to send to the server
268
269 sprintf_s(msg, sizeof msg, "Could not initialize your sound device: %s", deviceName.c_str());
270 game->ToggleFullScreen(false);
271 MessageBoxA(Rendering::ClientWindow(), msg, "Sound Device Failed", MB_ICONWARNING | MB_OK);
272
273 ReleaseConfigSounds(deviceConfig);
274 deviceConfig->bassDevice = 0; // added this 02-20-2020 to keep it from trying to load sounds!
275 return;
276 }
277 }
278
279 if (useDefaultDevice)
280 {
281 if (bassDevice <= 0)
282 bassDevice = BASS_GetDevice();
283
284 if (bassDevice <= 0) // failed
285 {
286 Trace("Could not find a default sound device!", Logger::Level::Debug);
287
288 game->ToggleFullScreen(false);
289 MessageBox(Rendering::ClientWindow(), L"Could not find a default sound device!", L"Initialize Sound Device", MB_ICONWARNING | MB_OK);
290
291 ReleaseConfigSounds(deviceConfig);
292 deviceConfig->bassDevice = 0;
293 }
294 else
295 {
296 deviceConfig->bassDevice = static_cast<char>(bassDevice);
297 }
298 }
299 else
300 {
301 deviceConfig->bassDevice = static_cast<char>(bassDevice);
302 }
303}
304
306{
307 if (!config)
308 return;
309
310 const char configDevice = config->bassDevice;
311 if (configDevice && currentSoundDevice != configDevice)
312 {
313 BASS_SetDevice(configDevice);
314 currentSoundDevice = configDevice;
315 }
316
317 for (int i = 0; i < SOUND_ENUMERATION; i++)
318 {
319 if (sound_config[i] != config)
320 continue;
321
323 {
324 BASS_SetDevice(sound_device[i]);
326 }
327
328 if (sound_stream[i])
329 {
330 BASS_ChannelStop(sound_stream[i]);
331 if (!FreeStream(sound_stream[i]))
332 {
333 char msg[99];
334 sprintf_s(msg, sizeof msg, "ReleaseConfigSounds BASS_StreamFree(%i): %i", i, BASS_ErrorGetCode());
336 }
337 sound_stream[i] = NULL;
338 }
339
340 if (sound_streamFx[i])
341 {
342 BASS_ChannelStop(sound_streamFx[i]);
343 if (!FreeStream(sound_streamFx[i]))
344 {
345 char msg[99];
346 sprintf_s(msg, sizeof msg, "ReleaseConfigSounds BASS_StreamFreeFx(%i): %i", i, BASS_ErrorGetCode());
348 }
349 sound_streamFx[i] = NULL;
350 }
351
352 sound_device[i] = 0;
353 sound_config[i] = nullptr;
354 sound_fromOutside[i] = false;
355 sound_partOfHull[i] = false;
356 sound_debug[i] = false;
357 sound_fxEnabled[i] = false;
358 }
359
360 if (config == &game->config.soundConfigLegacy && g_pSoundIntro)
361 {
362 BASS_ChannelStop(g_pSoundIntro);
363 if (!BASS_StreamFree(g_pSoundIntro))
364 {
365 char msg[99];
366 sprintf_s(msg, sizeof msg, "ReleaseConfigSounds BASS_StreamFree(g_pSoundIntro): %i", BASS_ErrorGetCode());
368 }
369 g_pSoundIntro = NULL;
370 hsync = NULL;
371 }
372
373 if (config == &game->config.soundConfigComms && comms)
374 {
375 BASS_ChannelStop(comms);
377 comms = NULL;
378 }
379
380 if (config == &game->config.soundConfigRadio && radio)
381 {
383 radio = NULL;
384 g_bRadioPlaying = false;
386 }
387
389}
390
392{
393 bleedAirGain = 0.f;
396 earPops.Reset();
397 Trace("Shutting down BASS...");
398
399 std::vector<int> freedDevices;
400 for (size_t i = 0; i < deviceBassDevices.size(); i++)
401 {
402 const int bassDevice = deviceBassDevices.at(i);
403 if (bassDevice <= 0 || std::find(freedDevices.begin(), freedDevices.end(), bassDevice) != freedDevices.end())
404 continue;
405
406 BASS_SetDevice(bassDevice);
407 if (!BASS_Free() && BASS_ErrorGetCode() != BASS_ERROR_INIT)
408 {
409 char msg[99];
410 sprintf_s(msg, sizeof msg, "BASS_Free(%i): %i", bassDevice, BASS_ErrorGetCode());
412 }
413 freedDevices.emplace_back(bassDevice);
414 }
415
416 deviceNames.clear();
417 deviceGuids.clear();
418 deviceBassDevices.clear();
419 g_pSoundIntro = NULL;
420 hsync = NULL;
421}
422
423void Sound::Trace(const char* msg, Logger::Level level) const
424{
425 char newmsg[999];
426 sprintf_s(newmsg, 999, "SOUND: %s", msg);
427 game->logger->Log(newmsg, level);
428}
429
430void Sound::PlayAudioData(unsigned char* data, size_t length)
431{
432 game->logger->AddToCallStack("Sound::PlayAudioData copying received audio");
433 if (!data || length == 0)
434 {
435 Trace("Rejected empty communications audio", Logger::Warn);
436 return;
437 }
439 return;
440
442 {
443 BASS_SetDevice(game->config.soundConfigComms.bassDevice);
445 }
446
447 if (comms)
449
450 int streamError = 0;
451 comms = OwnedAudioStream::Create(data, length, 0, streamError);
452 if (comms == 0)
453 {
454 char msg[99];
455 sprintf_s(msg, sizeof msg, "PlayAudioData stream creation failed: %i (%zu bytes)", streamError, length);
457 return;
458 }
459
460 const float modVolume = game->viewscreen->camera ? (game->viewscreen->camera->attenuate) : 1.0f;
461 if (!BASS_ChannelSetAttribute(comms, BASS_ATTRIB_VOL, game->config.soundConfigComms.volume * globalAttenuate * modVolume))
462 {
463 char msg[99];
464 sprintf_s(msg, sizeof msg, "PlayAudioData BASS_ChannelSetAttribute() vol %.1f failed: %i", game->config.soundConfigComms.volume * globalAttenuate * modVolume, BASS_ErrorGetCode());
465 // BASS_ERROR_ILLPARAM is 20
467 return;
468 }
469
470#pragma region Digital Signal Processing
471 const HFX setFx1 = BASS_ChannelSetFX(comms, BASS_FX_BFX_BQF, 5);
472 if (setFx1 == 0)
473 {
474 char msg[99];
475 sprintf_s(msg, sizeof msg, "BASS_ChannelSetFX1 error: %i", BASS_ErrorGetCode());
477 }
478
479 BASS_BFX_BQF highPass;
480 highPass.lFilter = BASS_BFX_BQF_HIGHPASS;
481 highPass.fCenter = 400;
482 highPass.fGain = 0;
483 highPass.fBandwidth = 1;
484 highPass.fQ = 0;
485 highPass.fS = 0;
486 highPass.lChannel = BASS_BFX_CHANALL;
487 if (!BASS_FXSetParameters(setFx1, &highPass))
488 {
489 char msg[99];
490 sprintf_s(msg, sizeof msg, "BASS_FXSetParameters1 error: %i", BASS_ErrorGetCode());
492 }
493
494 HFX setFx2 = BASS_ChannelSetFX(comms, BASS_FX_BFX_BQF, 6);
495 if (setFx2 == 0)
496 {
497 char msg[99];
498 sprintf_s(msg, sizeof msg, "BASS_ChannelSetFX2 error: %i", BASS_ErrorGetCode());
500 }
501
502 BASS_BFX_BQF lowPass;
503 lowPass.lFilter = BASS_BFX_BQF_LOWPASS;
504 lowPass.fCenter = 2000;
505 lowPass.lChannel = BASS_BFX_CHANALL;
506 lowPass.fGain = 0;
507 lowPass.fBandwidth = 1;
508 lowPass.fQ = 0;
509 lowPass.fS = 0;
510 if (!BASS_FXSetParameters(setFx2, &lowPass))
511 {
512 char msg[99];
513 sprintf_s(msg, sizeof msg, "BASS_FXSetParameters2 error: %i", BASS_ErrorGetCode());
515 }
516#pragma endregion
517
519 game->logger->AddToCallStack("Sound::PlayAudioData starting owned audio stream");
520 if (!BASS_ChannelPlay(comms, true))
521 {
522 char msg[99];
523 sprintf_s(msg, sizeof msg, "PlayAudioData BASS_ChannelPlay error: %i", BASS_ErrorGetCode());
525 }
526
527 char playbackMessage[160];
528 std::snprintf(playbackMessage, sizeof playbackMessage, "Comms stream %lu owns %zu bytes, duration %.3fs",
529 comms, length, BASS_ChannelBytes2Seconds(comms, BASS_ChannelGetLength(comms, BASS_POS_BYTE)));
530 Trace(playbackMessage);
531 radioAutoMute = 0.25f;
532 if (game->viewscreen->camera)
534}
535
536void Sound::GlobalAttenuate(float prmGaTimeToFadeOut, float prmGaTimeToHold, float prmGaTimeToFadeIn, SOUNDS soundEnum, float prmExTimeToFadeIn, float prmExTimeToHold, float prmExTimeToFadeOut, float volumeAdj)
537{
538 gaTimer = 0.0f;
539
540 // time to fade out, time to hold, time to fade back in, sound to exclude, time to fade in, time to hold, time to fade out
541 gaTimeToFadeOut = prmGaTimeToFadeOut;
542 gaTimeToHold = prmGaTimeToHold;
543 gaTimeToFadeIn = prmGaTimeToFadeIn;
544 gaVolumeAdj = volumeAdj;
545 excludeFromGlobalAttenuate = soundEnum;
546 exTimeToFadeIn = prmExTimeToFadeIn;
547 exTimeToHold = prmExTimeToHold;
548 exTimeToFadeOut = prmExTimeToFadeOut;
549}
550
551void Sound::ChangeVolume(SoundConfig* config, float modVolume)
552{
553 for (int i = 0; i < SOUND_ENUMERATION; i++)
554 {
555 if (sound_config[i] == config)
556 {
557 ChangeVolume(static_cast<SOUNDS>(i), modVolume);
558 }
559 }
560
561 // intro music
562 if (config == &game->config.soundConfigLegacy && g_pSoundIntro && config->bassDevice)
563 {
564 if (!BASS_ChannelSetAttribute(g_pSoundIntro, BASS_ATTRIB_VOL, game->config.soundConfigLegacy.volume * globalAttenuate * modVolume * 0.5f))
565 {
566 char msg[99];
567 sprintf_s(msg, sizeof msg, "ChangeVolume BASS_ChannelSetAttribute(g_pSoundIntro) vol %.1f failed: %i", game->config.soundConfigLegacy.volume * globalAttenuate * modVolume, BASS_ErrorGetCode());
569 }
570 }
571
572 // comms
573 if (config == &game->config.soundConfigComms && comms && config->bassDevice)
574 {
575 if (!BASS_ChannelSetAttribute(comms, BASS_ATTRIB_VOL, game->config.soundConfigComms.volume * globalAttenuate * modVolume))
576 {
577 char msg[99];
578 sprintf_s(msg, sizeof msg, "ChangeVolume BASS_ChannelSetAttribute(comms) vol %.1f failed: %i", game->config.soundConfigComms.volume * globalAttenuate * modVolume, BASS_ErrorGetCode());
580 }
581 }
582
583 // radio
584 if (config == &game->config.soundConfigRadio && radio && config->bassDevice)
585 {
586 if (!BASS_ChannelSetAttribute(radio, BASS_ATTRIB_VOL, game->config.soundConfigRadio.volume * globalAttenuate * modVolume * radioAutoMute))
587 {
588 char msg[99];
589 sprintf_s(msg, sizeof msg, "ChangeVolume BASS_ChannelSetAttribute(radio) vol %.1f failed: %i", game->config.soundConfigRadio.volume * globalAttenuate * modVolume, BASS_ErrorGetCode());
591 }
592 }
593}
594
596{
597 // Wind at the external microphone belongs to the listener. Its hull flag
598 // only prevents duplicate pressure attenuation. Bypass noise belongs to the
599 // engine but deliberately retains its existing airborne pressure treatment.
600 return !IsInterfaceSound(soundEnum) && soundEnum != SOUND_WIND_MIC &&
601 (sound_partOfHull[soundEnum] || soundEnum == SOUND_HIGHBYPASS || soundEnum == SOUND_RAINAIRRUSH);
602}
603
604bool Sound::UpdateSoundMix(SOUNDS soundEnum, HSTREAM streamToPlay, float modVolume)
605{
606 char msg[256];
607 const bool interfaceSound = IsInterfaceSound(soundEnum);
608 const bool fromOutside = sound_fromOutside[soundEnum];
609 const bool partOfHull = sound_partOfHull[soundEnum];
610 float volume = sound_volume[soundEnum];
611 float pan = sound_pan[soundEnum];
612
613#pragma region Pan
614
615 if (!interfaceSound && IsVehicleAttachedSound(soundEnum) &&
617 {
618 const auto& view = *game->viewscreen;
619 RiseMath::Vector3 cameraFromVehicle = view.camera->position;
620 RiseMath::Matrix bodyToCameraFrame;
621 RiseMath::MatrixIdentity(&bodyToCameraFrame);
622 if (view.ptrCockpit->UsesParentExternalCameras() && playerships[0].inarray < MAX_SCAN)
623 {
624 cameraFromVehicle -= playerships[0].dockoffset;
625 RiseMath::Matrix childOrientation, parentOrientation;
626 RiseMath::MatrixRotationQuaternion(&childOrientation, &playerships[0].orientation);
627 RiseMath::MatrixInverse(&childOrientation, nullptr, &childOrientation);
628 RiseMath::MatrixRotationQuaternion(&parentOrientation, &playerships[playerships[0].inarray].orientation);
629 bodyToCameraFrame = childOrientation * parentOrientation;
630 }
631 const float yaw = view.camera->currentPan + game->GUI->player[ourcockpit.ourplyrC].smoothhdg;
632 const float referenceDistanceKm = soundEnum >= SOUND_HORNMAMMOTH_START && soundEnum <= SOUND_HORNMAMMOTH_END
634 auto spatial = VehicleSoundSpatial::Calculate(cameraFromVehicle,
635 yaw, -view.camera->currentTilt, view.rolltilt, referenceDistanceKm);
636 if ((soundEnum >= SOUND_COCKPITENGINELEFT && soundEnum <= SOUND_COCKPITENGINECENTER) ||
637 soundEnum == SOUND_HIGHBYPASS)
638 {
639 const auto& engines = ourcockpit.engineSounds;
640 std::array<float, EngineAudio::SlotCount> weights{};
641 for (int engine = 0; engine < engines.count; ++engine)
642 weights[EngineAudio::SlotForEngine(engines.count, engine)] =
644 const int slot = soundEnum == SOUND_HIGHBYPASS ? -1 : soundEnum - SOUND_COCKPITENGINELEFT;
645 spatial = EngineAudio::Calculate(engines, slot, cameraFromVehicle,
646 yaw, -view.camera->currentTilt, view.rolltilt, bodyToCameraFrame, weights);
647 }
648 else if (soundEnum == SOUND_THRUST)
649 {
651 {view.rcsThrustOutputX, view.rcsThrustOutputY, view.rcsThrustOutputZ},
654 yaw, -view.camera->currentTilt, view.rolltilt, bodyToCameraFrame);
655 // This mix includes thrust level; the stored volume is the cockpit mix.
656 volume = 1.f;
657 }
658 volume *= spatial.gain;
659 pan = spatial.pan;
660 }
661
662 if (!interfaceSound && game->viewscreen->camera && !game->viewscreen->camera->outside && fromOutside)
663 pan *= ourcockpit.panFactor;
664
665 if (pan > 2.0f)
666 pan -= 4.0f;
667 else if (pan < -2.0f)
668 pan += 4.0f;
669
670 // when sound is behind us it is attenuated by ear lobe ... pinna shadow effect ...
671 // pan is in [-2..2], with ±2 = behind, ±1 = side, 0 = front
672 if (!interfaceSound && fabs(pan) > 1.0f)
673 {
674 float t = fabs(pan) - 1.0f; // 0 at side, 1 at rear
675 // Bell-shaped attenuation, strongest at 0.5 (135°)
676 float panAtt = 1.0f - 0.3f * sinf(t * RiseMath::Pi);
677 volume *= panAtt;
678 pan = (pan > 0 ? 2.0f - pan : -2.0f - pan);
679 }
680
681 if (!BASS_ChannelSetAttribute(streamToPlay, BASS_ATTRIB_PAN, pan))
682 {
683 if (soundEnum <= SOUND_AURALUNITOKAY)
684 sprintf_s(msg, sizeof msg, "PlayEx BASS_ChannelSetAttribute(%i) pan %.1f failed: %i - type %i", soundEnum, pan, BASS_ErrorGetCode(), playerships[0].type);
685 else
686 sprintf_s(msg, sizeof msg, "PlayEx BASS_ChannelSetAttribute(%i) pan %.1f failed: %i", soundEnum, pan, BASS_ErrorGetCode());
688
689 if (BASS_ErrorGetCode() == BASS_ERROR_HANDLE)
690 {
691 sprintf_s(msg, sizeof msg, "-> path: %s dword: %x %x %x", sound_path[soundEnum].c_str(), sound_stream[soundEnum], sound_streamFx[soundEnum], streamToPlay);
693 }
694 return false;
695 }
696
697#pragma endregion
698
699#pragma region Volume
700
701
702 if (!interfaceSound)
703 {
704 volume *= modVolume;
705 if (soundEnum == SOUND_THRUST && (!game->viewscreen->camera || !game->viewscreen->camera->outside))
706 volume *= RcsAudio::CockpitGain;
707 // if the sound is from outside and the camera is from inside or vice-versa then we apply glass EQ ... cockpit attenuation
708 // if the sound is from outside but attached to hull then we do not apply static density otherwise if it is from outside we do
709 if (game->viewscreen->camera && game->viewscreen->camera->outside != fromOutside)
710 volume *= ourcockpit.attenuate;
711
712 // scale by sound in cockpit pressure
714 volume *= 0.90f + 0.10f * game->bus->CabinPressureMb / SeaLevelPressureMb; // 10% loss from 2.6 bar to 0 bar ... realistically loss of 6% from 2.6 bar to 1 bar is what we are going for
715
716 // The complementary rush stem is already authored at Vieneo surface gain.
717 // Apply its normalized atmosphere fade exactly once in either camera.
718 if (soundEnum == SOUND_RAINAIRRUSH)
720 else if (((fromOutside && !partOfHull) || (game->viewscreen->camera && game->viewscreen->camera->outside)))
721 volume *= GetAtmosphericSoundPressureGain(game->viewscreen->ptrPropulsion->staticDensity);
722
723 // okay so this section allows us to hear the car radio on the camera that is mounted on the side of the car ... very short range attenuation
725 volume *= game->viewscreen->camera->attenuate;
726
727 if (soundEnum != excludeFromGlobalAttenuate)
728 volume *= globalAttenuate;
729 }
730
731 // this is the realtime adjustment based on the sound configuration sliders in the UI
732 volume *= sound_config[soundEnum]->volume;
733
734 // Cabin ambience and startup are internal-only. Keep playback advancing while
735 // muted outside so entering the cockpit never restarts the startup recording.
736 if ((soundEnum == SOUND_COCKPITAMBIENT || soundEnum == SOUND_COCKPITSTART) &&
738 volume = 0.0f;
739
740 if (volume > 1.0f)
741 {
742 sprintf_s(msg, sizeof msg, "PlayEx BASS_ChannelSetAttribute(%i) clamped volume: %.1f", soundEnum, volume);
744 volume = 1.0f;
745 }
746 else if (volume < 0.0f)
747 {
748 sprintf_s(msg, sizeof msg, "PlayEx BASS_ChannelSetAttribute(%i) clamped volume: %.1f", soundEnum, volume);
750 volume = 0.0f;
751 }
752
753 if (!BASS_ChannelSetAttribute(streamToPlay, BASS_ATTRIB_VOL, volume))
754 {
755 sprintf_s(msg, sizeof msg, "PlayEx BASS_ChannelSetAttribute(%i) vol %.1f soundConfigVol %.1f globalAtt %.1f failed: %i", soundEnum, volume, sound_config[soundEnum]->volume, globalAttenuate, BASS_ErrorGetCode());
756 // BASS_ERROR_ILLPARAM is 20
758 return false;
759 }
760
761#pragma endregion
762
763 return true;
764}
765
767{
769 for (int i = 0; i < SOUND_ENUMERATION; ++i)
770 {
771 const auto sound = static_cast<SOUNDS>(i);
772 if (IsVehicleAttachedSound(sound) &&
773 (BASS_ChannelIsActive(sound_stream[i]) == BASS_ACTIVE_PLAYING ||
774 BASS_ChannelIsActive(sound_streamFx[i]) == BASS_ACTIVE_PLAYING))
775 ChangeVolume(sound, 1.f);
776 }
777}
778
779void Sound::ChangeVolume(SOUNDS soundEnum, float modVolume)
780{
781 if (sound_stream[soundEnum])
782 {
783 const HSTREAM stream = GlassFX(soundEnum);
784 if (stream)
785 UpdateSoundMix(soundEnum, stream, modVolume);
786 }
787}
788
796
797float Sound::GetLength(SOUNDS soundEnum) const
798{
799 return sound_length[soundEnum];
800}
801
802float Sound::Play(SOUNDS soundEnum, float volume)
803{
804 PlayEx(soundEnum, false, volume);
805 return sound_length[soundEnum];
806}
807
809{
810 Trace("Sound::Reset");
811
812 Close();
813 Init();
814
816 {
817 for (short i = 0; i < SOUND_APTRIMCLACKER; i++)
818 LoadSounds(i);
819 }
820 else
821 {
822 for (short i = 0; i < SOUND_ENUMERATION; i++)
823 LoadSounds(i);
824 ChangeCockpit(false);
825 g_bRadioPlaying = false;
826 }
827}
828
829HSTREAM Sound::GlassFX(SOUNDS soundEnum)
830{
831 if (IsInterfaceSound(soundEnum) || sound_config[soundEnum] != &game->config.soundConfigLegacy)
832 return sound_stream[soundEnum];
833
834 // glass EQ
835 if (game->viewscreen->camera && game->viewscreen->camera->outside != sound_fromOutside[soundEnum]) // so if camera outside is true and sound is from inside
836 {
837 // exempt list
838 if (soundEnum == SOUND_COCKPITSTART || soundEnum == SOUND_COCKPITAMBIENT ||
839 soundEnum == SOUND_COCKPITLAND || soundEnum == SOUND_COCKPITLEVEL ||
840 soundEnum == SOUND_HOLIDAY ||
841 (soundEnum >= SOUND_DOCKANNOUNCE1 && soundEnum <= SOUND_DOCKCHIME) || // Docks
842 soundEnum == SOUND_DOCK || soundEnum == SOUND_UNDOCK ||
843 soundEnum == SOUND_FLAPMOTOR ||
844 soundEnum == SOUND_DOOROPEN || soundEnum == SOUND_DOORCLOSE ||
845 soundEnum == SOUND_GEARRETRACT || soundEnum == SOUND_GEAREXTEND ||
846 soundEnum == SOUND_PRESSUREDUMP ||
847 soundEnum == SOUND_DIHV ||
848 (soundEnum >= SOUND_WDEATH1 && soundEnum <= SOUND_WLAND2) ||
849 soundEnum == SOUND_GROUNDSCRAPELOOP || soundEnum == SOUND_GROUNDSCRAPESTOP ||
850 soundEnum == SOUND_ROADNOISELOOP ||
851 (soundEnum >= SOUND_HEARTBEAT && soundEnum <= SOUND_HOLIDAY2019) ||
852 (soundEnum >= SOUND_EXPLODEINT1 && soundEnum <= SOUND_EXPLODEINT3) ||
853 soundEnum == SOUND_EXPLODERING)
854 return sound_stream[soundEnum]; // exempt list ... we need to go through all of them loaded on the legacy device ...
855
856 if (sound_rate[soundEnum] < 44100)
857 {
858 if (!sound_debug[soundEnum])
859 {
860 sound_debug[soundEnum] = true;
861 char msg[99];
862 sprintf_s(msg, sizeof msg, "Sound Glass FX Sample (%i), \"%s\") LOW rate: %.0f", soundEnum, sound_path[soundEnum].c_str(), sound_rate[soundEnum]);
864 }
865 return sound_stream[soundEnum]; // ineligible
866 }
867
868 if (!sound_fxShelf[soundEnum] || !sound_streamFx[soundEnum])
869 {
870 // create secondary streams
871 size_t fileSize = GetFileSizeBytes(sound_path[soundEnum].c_str());
872 if (fileSize == 0)
873 {
874 char msg[99];
875 sprintf_s(msg, sizeof msg, "GetFileSizeBytes1(%i), \"%s\"): %zu", soundEnum, sound_path[soundEnum].c_str(), fileSize);
877 return NULL;
878 }
879
880 bool mem = false;// (fileSize <= 1048576); // TRUE if ≤1 MB, else FALSE
881 sound_streamFx[soundEnum] = BASS_StreamCreateFile(mem, sound_path[soundEnum].c_str(), 0, 0, 0);
882 if (!sound_streamFx[soundEnum])
883 {
884 char msg[99];
885 sprintf_s(msg, sizeof msg, "BASS_StreamCreateFile(%i), \"%s\"): %i", soundEnum, sound_path[soundEnum].c_str(), BASS_ErrorGetCode());
887 return NULL;
888 }
889
890 // 1) High-shelf
891 sound_fxShelf[soundEnum] = BASS_ChannelSetFX(sound_streamFx[soundEnum], BASS_FX_BFX_BQF, 2);
892 BASS_BFX_BQF shelfParams = {};
893 shelfParams.fCenter = RiseMath::Min(ourcockpit.shelfFreq, sound_rate[soundEnum] / 2 - 1);
894 shelfParams.fGain = ourcockpit.shelfGain;
895 shelfParams.fS = ourcockpit.shelfSlope;
896 shelfParams.lFilter = BASS_BFX_BQF_HIGHSHELF;
897 shelfParams.lChannel = BASS_BFX_CHANALL;
898 if (!BASS_FXSetParameters(sound_fxShelf[soundEnum], &shelfParams))
899 {
900 char msg[99];
901 sprintf_s(msg, sizeof msg, "GlassFX BASS_FXSetParameters(%i) BASS_BFX_BQF_HIGHSHELF: %i", soundEnum, BASS_ErrorGetCode());
903 }
904
905 // 2) Low-pass
906 sound_fxLP[soundEnum] = BASS_ChannelSetFX(sound_streamFx[soundEnum], BASS_FX_BFX_BQF, 3);
907 BASS_BFX_BQF lpParams = {};
908 lpParams.fCenter = RiseMath::Min(ourcockpit.lpFreq, sound_rate[soundEnum] / 2 - 1);
909 lpParams.fBandwidth = ourcockpit.lpSlope;
910 lpParams.lFilter = BASS_BFX_BQF_LOWPASS;
911 lpParams.lChannel = BASS_BFX_CHANALL;
912 if (!BASS_FXSetParameters(sound_fxLP[soundEnum], &lpParams))
913 {
914 char msg[99];
915 sprintf_s(msg, sizeof msg, "GlassFX BASS_FXSetParameters(%i) BASS_BFX_BQF_LOWPASS: %i", soundEnum, BASS_ErrorGetCode());
917 }
918
919 // 3) Mid-frequency notch
920 sound_fxNotch[soundEnum] = BASS_ChannelSetFX(sound_streamFx[soundEnum], BASS_FX_BFX_BQF, 4);
921 BASS_BFX_BQF notchParams = {};
922 notchParams.fCenter = ourcockpit.notchFreq;
923 notchParams.fGain = ourcockpit.notchGain;
924 notchParams.fBandwidth = 1.0f;
925 notchParams.lFilter = BASS_BFX_BQF_NOTCH;
926 notchParams.lChannel = BASS_BFX_CHANALL;
927 if (!BASS_FXSetParameters(sound_fxNotch[soundEnum], &notchParams))
928 {
929 char msg[99];
930 sprintf_s(msg, sizeof msg, "GlassFX BASS_FXSetParameters(%i) BASS_BFX_BQF_NOTCH: %i", soundEnum, BASS_ErrorGetCode());
932 }
933 }
934
935 if (!sound_fxEnabled[soundEnum])
936 {
937 if (BASS_ChannelIsActive(sound_stream[soundEnum]) == BASS_ACTIVE_PLAYING)
938 {
939 BASS_ChannelPause(sound_stream[soundEnum]);
940 BASS_ChannelSetPosition(sound_streamFx[soundEnum], BASS_ChannelGetPosition(sound_stream[soundEnum], BASS_POS_BYTE), BASS_POS_BYTE);
941 ApplyEarMuffle(sound_streamFx[soundEnum]);
942 BASS_ChannelPlay(sound_streamFx[soundEnum], false);
943
944 float oldValue;
945 BASS_ChannelGetAttribute(sound_streamFx[soundEnum], BASS_ATTRIB_VOL, &oldValue);
946 BASS_ChannelSetAttribute(sound_stream[soundEnum], BASS_ATTRIB_VOL, oldValue);
947 BASS_ChannelGetAttribute(sound_streamFx[soundEnum], BASS_ATTRIB_PAN, &oldValue);
948 BASS_ChannelSetAttribute(sound_stream[soundEnum], BASS_ATTRIB_PAN, oldValue);
949 BASS_ChannelGetAttribute(sound_streamFx[soundEnum], BASS_ATTRIB_FREQ, &oldValue);
950 BASS_ChannelSetAttribute(sound_stream[soundEnum], BASS_ATTRIB_FREQ, oldValue);
951 }
952 sound_fxEnabled[soundEnum] = true;
953 }
954
955 return sound_streamFx[soundEnum];
956 }
957
958 if (sound_fxEnabled[soundEnum])
959 {
960 if (BASS_ChannelIsActive(sound_streamFx[soundEnum]) == BASS_ACTIVE_PLAYING)
961 {
962 BASS_ChannelPause(sound_streamFx[soundEnum]);
963 BASS_ChannelSetPosition(sound_stream[soundEnum], BASS_ChannelGetPosition(sound_streamFx[soundEnum], BASS_POS_BYTE), BASS_POS_BYTE);
964 ApplyEarMuffle(sound_stream[soundEnum]);
965 BASS_ChannelPlay(sound_stream[soundEnum], false);
966
967 float oldValue;
968 BASS_ChannelGetAttribute(sound_stream[soundEnum], BASS_ATTRIB_VOL, &oldValue);
969 BASS_ChannelSetAttribute(sound_streamFx[soundEnum], BASS_ATTRIB_VOL, oldValue);
970 BASS_ChannelGetAttribute(sound_stream[soundEnum], BASS_ATTRIB_PAN, &oldValue);
971 BASS_ChannelSetAttribute(sound_streamFx[soundEnum], BASS_ATTRIB_PAN, oldValue);
972 BASS_ChannelGetAttribute(sound_stream[soundEnum], BASS_ATTRIB_FREQ, &oldValue);
973 BASS_ChannelSetAttribute(sound_streamFx[soundEnum], BASS_ATTRIB_FREQ, oldValue);
974 }
975 sound_fxEnabled[soundEnum] = false;
976 }
977
978 return sound_stream[soundEnum];
979}
980
981// <param>volume</param>0 (silent) to 1 (full)
982// <param>frequencyMod</param>0 = original rate (when the channel was created) to X times
983// <param>pan</param>-1 (full left) to +1 (full right), 0 = centre
984/*
985 *so we have sounds like the VMU that emanate from in the cockpit and are not connected to the hull (false, false) this is the default
986we have sounds like the touchdown that come from in the vehicle and are connected to the hull (false, true)?
987we have sounds like thunder that come from outside the cockpit (true, false)
988are there sounds that are bulk of sound from outside that are connected to the hull? yes the engines (true, true)
989
990could be louderOutside and
991
992fromOutside applies Atmospheric FX ...
993fromOutside and !partOfHull gets attenuated by static density ... all !fromOutside sounds when observed from camera.outside are also attenuated by static density
994fromOutside != camera.outside gets attenuated by ourcockpit.attenuation
995fromOutside != camera.outside computer, comms, and radio can be heard faintly from outside the vehicle through camera attenuate
996
997so only change I can see is like the RCS thrust is currently true true ... the bulk of the noise is outside the cockpit so I think that makes sense if we look at it thatway
998
999Q: Is the bulk of the sound pressure outside the vehicle? like engines, thrust, etc? Environmental effects like thunder ... sonic boom from other ships
1000A: fromOutside == true
1001
1002Q: Is the sound audible in the cockpit in space (like the thrusters, engines, bay doors)
1003A: partOfHull == true
1004
1005*/
1006void Sound::PlayEx(SOUNDS soundEnum, bool loop, float volume, float frequencyMod, float pan, bool restart, bool fromOutside, bool partOfHull)
1007{
1008 char msg[256];
1009 const int soundIndex = static_cast<int>(soundEnum);
1010 static bool invalidSoundEnumReported = false;
1011 if (soundIndex < 0 || soundIndex >= SOUND_ENUMERATION)
1012 {
1013 if (!invalidSoundEnumReported)
1014 {
1015 invalidSoundEnumReported = true;
1016 sprintf_s(msg, sizeof msg, "PlayEx rejected invalid sound index %i", soundIndex);
1018 }
1019 return;
1020 }
1021 invalidSoundEnumReported = false;
1022
1023 static bool invalidParametersReported[SOUND_ENUMERATION] = {};
1024 if (IsInvalidFloat(volume) || IsInvalidFloat(frequencyMod) || IsInvalidFloat(pan))
1025 {
1026 if (!invalidParametersReported[soundIndex])
1027 {
1028 invalidParametersReported[soundIndex] = true;
1029 sprintf_s(msg, sizeof msg, "PlayEx rejected non-finite parameters for sound %i: volume %.3f frequency %.3f pan %.3f",
1030 soundIndex, volume, frequencyMod, pan);
1032 }
1033 return;
1034 }
1035 invalidParametersReported[soundIndex] = false;
1036
1037 if (!sound_device[soundEnum] || !sound_stream[soundEnum])
1038 return;
1039
1040 if (currentSoundDevice != sound_device[soundEnum])
1041 {
1042 if (!BASS_SetDevice(sound_device[soundEnum]))
1043 {
1044 sprintf_s(msg, sizeof msg, "PlayEx BASS_SetDevice sound %i device %i: %i", soundEnum, sound_device[soundEnum], BASS_ErrorGetCode());
1046 }
1047 currentSoundDevice = sound_device[soundEnum];
1048 }
1049
1050 const bool interfaceSound = IsInterfaceSound(soundEnum);
1051 sound_partOfHull[soundEnum] = partOfHull;
1052
1053#pragma region FX
1054
1055 // Atmospheric FX
1056 if (!interfaceSound && fromOutside && !sound_fromOutside[soundEnum])
1057 {
1058 if (!sound_streamFx[soundEnum])
1059 {
1060 if (sound_rate[soundEnum] < 44100)
1061 {
1062 char msg[99];
1063 sprintf_s(msg, sizeof msg, "Sound Atmospheric FX Sample (%i), \"%s\") LOW rate: %.0f", soundEnum, sound_path[soundEnum].c_str(), sound_rate[soundEnum]);
1065 }
1066
1067 // create secondary streams
1068 size_t fileSize = GetFileSizeBytes(sound_path[soundEnum].c_str());
1069 if (fileSize == 0)
1070 {
1071 char msg[99];
1072 sprintf_s(msg, sizeof msg, "GetFileSizeBytes2(%i), \"%s\"): %zu", soundEnum, sound_path[soundEnum].c_str(), fileSize);
1074 return;
1075 }
1076
1077 bool mem = false;// (fileSize <= 1048576); // TRUE if ≤1 MB, else FALSE
1078 sound_streamFx[soundEnum] = BASS_StreamCreateFile(mem, sound_path[soundEnum].c_str(), 0, 0, 0);
1079 if (!sound_streamFx[soundEnum])
1080 {
1081 char msg[99];
1082 sprintf_s(msg, sizeof msg, "BASS_StreamCreateFile(%i), \"%s\"): %i", soundEnum, sound_path[soundEnum].c_str(), BASS_ErrorGetCode());
1084 return;
1085 }
1086 }
1087
1088 // High-shelf
1089 DWORD fxShelf = BASS_ChannelSetFX(sound_stream[soundEnum], BASS_FX_BFX_BQF, 0);
1090 BASS_BFX_BQF shelfParams = {};
1091 shelfParams.fCenter = 2000.0f; // Hz
1092 shelfParams.fGain = -6.0f; // dB
1093 shelfParams.fBandwidth = 0.7f;
1094 shelfParams.lFilter = BASS_BFX_BQF_HIGHSHELF;
1095 BASS_FXSetParameters(fxShelf, &shelfParams);
1096 fxShelf = BASS_ChannelSetFX(sound_streamFx[soundEnum], BASS_FX_BFX_BQF, 0);
1097 BASS_FXSetParameters(fxShelf, &shelfParams);
1098
1099 // Low-pass
1100 DWORD fxLP = BASS_ChannelSetFX(sound_stream[soundEnum], BASS_FX_BFX_BQF, 1);
1101 BASS_BFX_BQF lp = {};
1102 lp.fCenter = 4000.0f; // Hz;
1103 lp.fGain = 0.0f;
1104 lp.fBandwidth = 2; // 12 dB/oct (=2), 24 (=4);
1105 lp.lFilter = BASS_BFX_BQF_LOWPASS;
1106 BASS_FXSetParameters(fxLP, &lp);
1107 fxLP = BASS_ChannelSetFX(sound_streamFx[soundEnum], BASS_FX_BFX_BQF, 1);
1108 BASS_FXSetParameters(fxLP, &lp);
1109
1110 sound_fromOutside[soundEnum] = true;
1111 }
1112
1113 HSTREAM streamToPlay = GlassFX(soundEnum);
1114 static bool caughtOne = false;
1115 if (!streamToPlay)
1116 {
1117 if (!caughtOne)
1118 {
1119 caughtOne = true;
1120 sprintf_s(msg, sizeof msg, "PlayEx streamToPlay NULL se%i fo%i ph%i sfo%i sph%i cam%i sd%i sfx%i", soundEnum, fromOutside, partOfHull, sound_fromOutside[soundEnum], sound_partOfHull[soundEnum], game->viewscreen->camera && game->viewscreen->camera->outside, sound_debug[soundEnum], sound_fxEnabled[soundEnum]);
1122 }
1123 return;
1124 }
1125 caughtOne = false;
1126
1127#pragma endregion
1128
1129 if (loop)
1130 {
1131 if (!BASS_ChannelFlags(sound_stream[soundEnum], BASS_SAMPLE_LOOP, BASS_SAMPLE_LOOP))
1132 {
1133 sprintf_s(msg, sizeof msg, "PlayEx BASS_ChannelFlags(%i) failed: %i", soundEnum, BASS_ErrorGetCode());
1135 return;
1136 }
1137 if (sound_streamFx[soundEnum] && !BASS_ChannelFlags(sound_streamFx[soundEnum], BASS_SAMPLE_LOOP, BASS_SAMPLE_LOOP))
1138 {
1139 sprintf_s(msg, sizeof msg, "PlayEx BASS_ChannelFlags(%i) failed: %i", soundEnum, BASS_ErrorGetCode());
1141 return;
1142 }
1143 }
1144
1145 // Retain the source mix so camera updates never compound distance attenuation.
1146 sound_volume[soundEnum] = volume;
1147 sound_pan[soundEnum] = pan;
1148 if (!UpdateSoundMix(soundEnum, streamToPlay, 1.f))
1149 return;
1150
1151#pragma region Frequency
1152
1153 const float frequency = Clamp(sound_rate[soundEnum] * frequencyMod, minrate, maxrate);
1154 if (!BASS_ChannelSetAttribute(streamToPlay, BASS_ATTRIB_FREQ, frequency))
1155 {
1156 sprintf_s(msg, sizeof msg, "PlayEx BASS_ChannelSetAttribute(%i) freq %.1f failed: %i", soundEnum, frequency, BASS_ErrorGetCode());
1158 sprintf_s(msg, sizeof msg, "--- minrate %.1f original %.1f maxrate %.1f mod %.1f", minrate, sound_rate[soundEnum], maxrate, frequencyMod);
1160 return;
1161 }
1162
1163#pragma endregion
1164
1165 if (!interfaceSound)
1166 ApplyEarMuffle(streamToPlay);
1167
1168 if (!BASS_ChannelPlay(streamToPlay, !loop && restart))
1169 {
1170 const int error = BASS_ErrorGetCode();
1171 if (error == BASS_ERROR_UNKNOWN || error == BASS_ERROR_BUFLOST)
1172 {
1173 sprintf_s(msg, sizeof msg, "PlayEx BASS_ChannelPlay (%i) error %i!", soundEnum, error);
1176 // I think at least in that case it was the thunder ... downgrading from FATAL
1177 Trace("Resetting...", Logger::Level::Error);
1178 Reset();
1179 Trace("Playing again...", Logger::Level::Error);
1180 PlayEx(soundEnum, loop, volume, frequencyMod, pan, restart);
1181 }
1182 else if (error == BASS_ERROR_START)
1183 {
1184 // this one is odd ... BASS_Start is automatically called from BASS_Init and we never call BASS_Pause or BASS_Stop
1185 BASS_Start();
1186 BASS_ChannelPlay(streamToPlay, !loop && restart);
1187 }
1188 }
1189
1190 // lower volume on the radio when there is a VMU or avionics sound
1191 if (sound_config[soundEnum] == &game->config.soundConfigComputer)
1192 {
1193 radioAutoMute = 0.25f;
1195 }
1196}
1197
1198void CALLBACK Sound::MetaData(HSYNC, DWORD, DWORD, void* user)
1199{
1200 Sound* s = static_cast<Sound*>(user);
1201
1202 s->Trace("Sound::MetaData received!");
1203 s->game->logger->AddToCallStack("Sound::MetaData");
1204
1205 // get the broadcast name and bitrate
1206 const char* icy = BASS_ChannelGetTags(s->radio, BASS_TAG_META);
1207 if (icy)
1208 {
1209 if (strcmp(s->metadata, icy) != 0)
1210 {
1211 strcpy_s(s->metadata, sizeof metadata, icy);
1212 char msg[999];
1213 sscanf_s(s->metadata, "StreamTitle='%[^']", msg, static_cast<unsigned>(sizeof(msg)));
1214 if (strlen(msg) > 76)
1215 {
1216 msg[74] = msg[75] = msg[76] = '.';
1217 msg[77] = 0;
1218 }
1219 if (strcmp(msg, s->oldtitle) != 0)
1220 {
1221 strcpy_s(ourcockpit.radioplaying, sizeof(ourcockpit.radioplaying), msg);
1223
1224 strcpy_s(s->oldtitle, sizeof(oldtitle), msg);
1225
1227 if (s->stationIdentification >= 7) // 12 songs? 48 minutes ... should be 30 minutes
1228 {
1229 s->celebrity++;
1230 if (s->celebrity > 2)
1231 s->celebrity = 0;
1232 s->Play(static_cast<SOUNDS>(SOUND_STATIONIDLL + s->celebrity));
1233 s->stationIdentification = 0;
1234 }
1235 }
1236 }
1237 }
1238 else
1239 {
1240 char msg[999];
1241 sprintf_s(msg, sizeof msg, "MetaData BASS_ChannelGetTags error %i!", BASS_ErrorGetCode());
1242 s->Trace(msg, Logger::Level::Error);
1243 }
1244}
1245
1246void CALLBACK Sound::AdvanceStage(HSYNC, DWORD, DWORD, void* user)
1247{
1248 Sound* s = static_cast<Sound*>(user);
1249
1250 char msg[99];
1251 sprintf_s(msg, sizeof msg, "Sound::AdvanceStage loopintro %i musicstage: %i", s->loopintro, s->musicstage);
1252 s->game->logger->Log(msg);
1253
1254 if (s->loopintro && s->g_pSoundIntro) // got to sync position, set back to loop
1255 {
1256 // reset position
1257 // ReSharper disable once CppDefaultCaseNotHandledInSwitchStatement
1258 // ReSharper disable once CppIncompleteSwitchStatement
1259 switch (s->musicstage)
1260 {
1262#ifndef NEWINTRO
1263 if (!BASS_ChannelSetPosition(s->g_pSoundIntro, BASS_ChannelSeconds2Bytes(s->g_pSoundIntro, 12.034f), BASS_POS_BYTE)) // back to start of stage 1
1264 {
1265 sprintf_s(msg, sizeof msg, "Sound::AdvanceStage BASS_ChannelSetPos %i: %i", s->musicstage, BASS_ErrorGetCode());
1267 }
1268 break;
1269#endif
1271#ifndef NEWINTRO
1272 if (!BASS_ChannelSetPosition(s->g_pSoundIntro, BASS_ChannelSeconds2Bytes(s->g_pSoundIntro, 36.068f), BASS_POS_BYTE)) // 42.103
1273#else
1274 if (!BASS_ChannelSetPosition(s->g_pSoundIntro, BASS_ChannelSeconds2Bytes(s->g_pSoundIntro, 16.670f), BASS_POS_BYTE))
1275#endif
1276 {
1277 sprintf_s(msg, sizeof msg, "Sound::AdvanceStage BASS_ChannelSetPos %i: %i", s->musicstage, BASS_ErrorGetCode());
1279 }
1280 break;
1282#ifndef NEWINTRO
1283 if (!BASS_ChannelSetPosition(s->g_pSoundIntro, BASS_ChannelSeconds2Bytes(s->g_pSoundIntro, 126.437f), BASS_POS_BYTE))
1284 {
1285 sprintf_s(msg, sizeof msg, "Sound::AdvanceStage BASS_ChannelSetPos %i: %i", s->musicstage, BASS_ErrorGetCode());
1287 }
1288#else
1289 s->loopintro = false;
1290#endif
1291 break;
1293 if (s->g_pSoundIntro)
1294 {
1295 s->game->logger->Log("Calling BASS_ChannelRemoveSync STATUS_GAME!");
1296 //if (s->hsync && !BASS_ChannelRemoveSync(s->g_pSoundIntro, s->hsync))
1297 //{
1298 // sprintf_s(msg, sizeof msg, "Sound::AdvanceStage BASS_ChannelRemoveSync %i: %i", s->musicstage, BASS_ErrorGetCode());
1299 // s->game->logger->Log(msg, Logger::Level::Error);
1300 //}
1301 s->hsync = NULL;
1302 if (!BASS_StreamFree(s->g_pSoundIntro))
1303 {
1304 sprintf_s(msg, sizeof msg, "Sound::AdvanceStage BASS_StreamFree %i: %i", s->musicstage, BASS_ErrorGetCode());
1306 break;
1307 }
1308 s->g_pSoundIntro = NULL; // BASS_StreamFree does NOT NULL the g_pSoundIntro!
1309 }
1310 break;
1311 }
1312 }
1313 else // got to sync position, continuing (set new sync position)
1314 {
1315#ifndef NEWINTRO
1316 s->game->logger->Log("Calling BASS_ChannelRemoveSync!");
1317 if (s->g_pSoundIntro && !BASS_ChannelRemoveSync(s->g_pSoundIntro, s->hsync))
1318 {
1319 sprintf_s(msg, sizeof(msg), "BASS_ChannelRemoveSync %i: %i", s->musicstage, BASS_ErrorGetCode());
1321 }
1322 s->hsync = NULL;
1324 {
1325 if (s->g_pSoundIntro)
1326 {
1327 if (!BASS_StreamFree(s->g_pSoundIntro))
1328 {
1329 sprintf_s(msg, sizeof msg, "Sound::AdvanceStage BASS_StreamFree %i: %i", s->musicstage, BASS_ErrorGetCode());
1331 return;
1332 }
1333 s->g_pSoundIntro = NULL; // BASS_StreamFree does NOT NULL the g_pSoundIntro!
1334 }
1335 return;
1336 }
1337#endif
1338 s->musicstage = static_cast<GameState>(s->musicstage + 1); // was 1, now 2
1339 if (s->musicstage == GameState::STATUS_CREATE) // music doesn't change here
1340 s->musicstage = static_cast<GameState>(s->musicstage + 1);
1341 sprintf_s(msg, sizeof msg, "NOW Sound::AdvanceStage loopintro %i musicstage: %i", s->loopintro, s->musicstage);
1342 s->game->logger->Log(msg);
1343
1344 // ReSharper disable once CppDefaultCaseNotHandledInSwitchStatement
1345 // ReSharper disable once CppIncompleteSwitchStatement
1346 switch (s->musicstage)
1347 {
1348 // This is where we set the triggers/cues ... when these are hit then we get to AdvanceStage
1349 // Only one that isn't here is the very first trigger set in LoadSounds()
1351 if (s->g_pSoundIntro)
1352 {
1353 s->hsync = BASS_ChannelSetSync(s->g_pSoundIntro,
1354 BASS_SYNC_POS | BASS_SYNC_MIXTIME,
1355#ifndef NEWINTRO
1356 BASS_ChannelSeconds2Bytes(s->g_pSoundIntro, 48.074f),
1357#else
1358 BASS_ChannelSeconds2Bytes(s->g_pSoundIntro, 33.366f),
1359#endif
1360 & Sound::AdvanceStage, s); // 54.109
1361 // set sync on next loopable part
1362 s->loopintro = true;
1363 }
1364 break;
1366 if (s->g_pSoundIntro)
1367 {
1368#ifndef NEWINTRO
1369 s->hsync = BASS_ChannelSetSync(s->g_pSoundIntro,
1370 BASS_SYNC_POS | BASS_SYNC_MIXTIME,
1371 BASS_ChannelSeconds2Bytes(s->g_pSoundIntro, 138.437f),
1373#else
1374 s->hsync = BASS_ChannelSetSync(s->g_pSoundIntro,
1375 BASS_SYNC_POS | BASS_SYNC_MIXTIME,
1376 BASS_ChannelSeconds2Bytes(s->g_pSoundIntro, 116.849f), // we can release to the game after this point
1378 BASS_ChannelSetPosition(s->g_pSoundIntro, BASS_ChannelSeconds2Bytes(s->g_pSoundIntro, 83.452f), BASS_POS_BYTE);
1379 s->loopintro = false;
1380#endif
1381 }
1382 break;
1384 if (s->g_pSoundIntro)
1385 {
1386 s->hsync = BASS_ChannelSetSync(s->g_pSoundIntro,
1387 BASS_SYNC_END,
1388 0,
1390 }
1391 break;
1392#ifdef NEWINTRO
1393 case 5:
1394 if (s->g_pSoundIntro)
1395 {
1396 s->game->logger->Log("Calling BASS_ChannelRemoveSync Case 5!");
1397 //if (s->hsync && !BASS_ChannelRemoveSync(s->g_pSoundIntro, s->hsync))
1398 //{
1399 // sprintf_s(msg, sizeof(msg), "BASS_ChannelRemoveSync %i: %i", s->musicstage, BASS_ErrorGetCode());
1400 // s->game->logger->Log(msg, Logger::Level::Error);
1401 //}
1402 s->hsync = NULL;
1403 s->game->logger->Log("Calling BASS_StreamFree g_pSoundIntro!");
1404 if (!BASS_StreamFree(s->g_pSoundIntro))
1405 {
1406 sprintf_s(msg, sizeof msg, "Sound::AdvanceStage BASS_StreamFree %i: %i", s->musicstage, BASS_ErrorGetCode());
1408 return;
1409 }
1410 s->g_pSoundIntro = NULL; // BASS_StreamFree does NOT NULL the g_pSoundIntro!
1411 }
1412 break;
1413#endif
1414 }
1415
1416 if (s->g_pSoundIntro && !s->hsync)
1417 {
1418 sprintf_s(msg, sizeof(msg), "BASS_ChannelSetSync %i: %i", s->musicstage, BASS_ErrorGetCode());
1420 }
1421 }
1422}
1423
1424size_t Sound::GetFileSizeBytes(const char* str)
1425{
1426 try
1427 {
1428 return static_cast<size_t>(std::filesystem::file_size(str));
1429 }
1430 catch (std::filesystem::filesystem_error&) {
1431 return 0;
1432 }
1433}
1434
1435void Sound::LoadSound(int soundEnum, SoundConfig* newDevice)
1436{
1437 if (newDevice == nullptr)
1438 newDevice = &game->config.soundConfigLegacy;
1439
1440 if (!newDevice->bassDevice)
1441 return;
1442
1443 const char oldSoundDevice = sound_device[soundEnum];
1444 sound_config[soundEnum] = newDevice;
1445 sound_device[soundEnum] = newDevice->bassDevice;
1446
1447 // if it already has a stream then we need to release it
1448 if (sound_stream[soundEnum])
1449 {
1450 if (currentSoundDevice != oldSoundDevice)
1451 {
1452 BASS_SetDevice(oldSoundDevice);
1453 currentSoundDevice = oldSoundDevice;
1454 }
1455
1456 BASS_ChannelStop(sound_stream[soundEnum]);
1457 if (!FreeStream(sound_stream[soundEnum]))
1458 {
1459 char msg[99];
1460 sprintf_s(msg, sizeof msg, "BASS_StreamFree(%i): %i", soundEnum, BASS_ErrorGetCode());
1462 }
1463 sound_stream[soundEnum] = NULL; // BASS_SampleFree does NOT NULL the sound_stream[soundEnum]!
1464 if (sound_streamFx[soundEnum])
1465 {
1466 BASS_ChannelStop(sound_streamFx[soundEnum]);
1467 if (!FreeStream(sound_streamFx[soundEnum]))
1468 {
1469 char msg[99];
1470 sprintf_s(msg, sizeof msg, "BASS_StreamFree(%i): %i", soundEnum, BASS_ErrorGetCode());
1472 }
1473 sound_streamFx[soundEnum] = NULL; // BASS_SampleFree does NOT NULL the sound_stream[soundEnum]!
1474 sound_fromOutside[soundEnum] = false; // allows reload of streamFx
1475 sound_partOfHull[soundEnum] = false;
1476 sound_debug[soundEnum] = false;
1477 sound_fxEnabled[soundEnum] = false;
1478 }
1479 }
1480
1481 // doesn't have a new sound device?
1482 if (!sound_device[soundEnum])
1483 return;
1484
1485 // filename is blank, lazy loading
1486 if (sound_path[soundEnum].empty())
1487 return;
1488
1489 if (currentSoundDevice != sound_device[soundEnum])
1490 {
1491 BASS_SetDevice(sound_device[soundEnum]);
1492 currentSoundDevice = sound_device[soundEnum];
1493 }
1494
1495 size_t fileSize = GetFileSizeBytes(sound_path[soundEnum].c_str());
1496 if (fileSize == 0)
1497 {
1498 char msg[99];
1499 sprintf_s(msg, sizeof msg, "GetFileSizeBytes3(%i), \"%s\"): %zu", soundEnum, sound_path[soundEnum].c_str(), fileSize);
1501 }
1502
1503 int streamError = BASS_OK;
1504 sound_stream[soundEnum] = CreateFileSound(soundEnum, sound_path[soundEnum].c_str(), streamError);
1505 if (!sound_stream[soundEnum])
1506 {
1507 char msg[99];
1508 sprintf_s(msg, sizeof msg, "CreateFileSound(%i), \"%s\"): %i", soundEnum, sound_path[soundEnum].c_str(), streamError);
1510 sound_device[soundEnum] = 0;
1511 sound_config[soundEnum] = nullptr;
1512 }
1513 else
1514 {
1515 WCHAR wstr[MAX_PATH];
1516 swprintf_s(wstr, MAX_PATH, L"%S", sound_path[soundEnum].c_str());
1517 game->TouchFile(wstr);
1518
1519 BASS_CHANNELINFO info;
1520 if (BASS_ChannelGetInfo(sound_stream[soundEnum], &info))
1521 {
1522 sound_rate[soundEnum] = static_cast<float>(info.freq);
1523 }
1524 else
1525 {
1526 char msg[99];
1527 sprintf_s(msg, sizeof msg, "BASS_ChannelGetInfo(%i), \"%s\"): %i", soundEnum, sound_path[soundEnum].c_str(), BASS_ErrorGetCode());
1529 }
1530
1531 const QWORD length = BASS_ChannelGetLength(sound_stream[soundEnum], BASS_POS_BYTE);
1532 sound_length[soundEnum] = static_cast<float>(BASS_ChannelBytes2Seconds(sound_stream[soundEnum], length));
1533 }
1534}
1535
1536void Sound::LoadCockpitSound(SOUNDS soundEnum, const char* path, bool force, SoundConfig* device)
1537{
1538 if (device == nullptr)
1539 device = &game->config.soundConfigLegacy;
1540
1541 if (!device->bassDevice)
1542 return;
1543
1544 sound_length[soundEnum] = 0.0f; // Null or missing replacement must not retain the previous voice duration.
1545 char oldsounddevice = sound_device[soundEnum];
1546 sound_config[soundEnum] = device;
1547 sound_device[soundEnum] = device->bassDevice;
1548
1549 if (sound_stream[soundEnum]) // had an old one
1550 {
1551 //if (sound_device[soundEnum] == oldsounddevice && path != nullptr && !force)
1552 // return;
1553
1554 if (currentSoundDevice != oldsounddevice)
1555 {
1556 BASS_SetDevice(oldsounddevice);
1557 currentSoundDevice = oldsounddevice;
1558 }
1559
1560 BASS_ChannelStop(sound_stream[soundEnum]);
1561 if (!FreeStream(sound_stream[soundEnum]))
1562 {
1563 char msg[99];
1564 sprintf_s(msg, sizeof msg, "BASS_StreamFree(%i): %i", soundEnum, BASS_ErrorGetCode());
1566 }
1567
1568 sound_stream[soundEnum] = NULL; // BASS_SampleFree does NOT NULL the sound_stream[soundEnum]!
1569 }
1570
1571 bool hadFxChannel = false;
1572 sound_fromOutside[soundEnum] = false;
1573 sound_partOfHull[soundEnum] = false;
1574 sound_fxEnabled[soundEnum] = false;
1575 if (sound_streamFx[soundEnum]) // had an old one
1576 {
1577 BASS_ChannelStop(sound_streamFx[soundEnum]);
1578 if (!FreeStream(sound_streamFx[soundEnum]))
1579 {
1580 char msg[99];
1581 sprintf_s(msg, sizeof msg, "BASS_StreamFree(%i): %i", soundEnum, BASS_ErrorGetCode());
1583 }
1584
1585 sound_streamFx[soundEnum] = NULL; // BASS_SampleFree does NOT NULL the sound_stream[soundEnum]!
1586 hadFxChannel = true;
1587 }
1588
1589 if (path == nullptr)
1590 sound_path[soundEnum] = "";
1591 else
1592 sound_path[soundEnum] = path;
1593
1594 if (!sound_device[soundEnum] || path == nullptr)
1595 return;
1596
1597 if (currentSoundDevice != sound_device[soundEnum])
1598 {
1599 BASS_SetDevice(sound_device[soundEnum]);
1600 currentSoundDevice = sound_device[soundEnum];
1601 }
1602
1603 size_t fileSize = GetFileSizeBytes(path);
1604 if (fileSize == 0)
1605 {
1606 char msg[99];
1607 sprintf_s(msg, sizeof msg, "GetFileSizeBytes4(%i), \"%s\"): %zu", soundEnum, path, fileSize);
1609 }
1610
1611 int streamError = BASS_OK;
1612 sound_stream[soundEnum] = CreateFileSound(soundEnum, path, streamError);
1613 if (hadFxChannel)
1614 {
1615 int fxError = BASS_OK;
1616 sound_streamFx[soundEnum] = CreateFileSound(soundEnum, path, fxError);
1617 if (!sound_streamFx[soundEnum])
1618 {
1619 char msg[99];
1620 sprintf_s(msg, sizeof msg, "CreateFileSound FX(%i), \"%s\"): %i", soundEnum, path, fxError);
1622 }
1623 if (sound_rate[soundEnum] < 44100)
1624 {
1625 char msg[99];
1626 sprintf_s(msg, sizeof msg, "Sound Sample HAD FX Channel on replace (%i), \"%s\") LOW rate: %.0f", soundEnum, sound_path[soundEnum].c_str(), sound_rate[soundEnum]);
1628 }
1629 }
1630 if (!sound_stream[soundEnum])
1631 {
1632 char msg[99];
1633 sprintf_s(msg, sizeof msg, "CreateFileSound(%i), \"%s\"): %i", soundEnum, path, streamError);
1635 sound_device[soundEnum] = 0;
1636 sound_config[soundEnum] = nullptr;
1637 }
1638 else
1639 {
1640 WCHAR wstr[MAX_PATH];
1641 swprintf_s(wstr, MAX_PATH, L"%S", path);
1642 game->TouchFile(wstr);
1643
1644 BASS_CHANNELINFO info;
1645 if (BASS_ChannelGetInfo(sound_stream[soundEnum], &info))
1646 {
1647 sound_rate[soundEnum] = static_cast<float>(info.freq);
1648 }
1649 else
1650 {
1651 char msg[99];
1652 sprintf_s(msg, sizeof msg, "BASS_ChannelGetInfo(%i), \"%s\"): %i", soundEnum, path, BASS_ErrorGetCode());
1654 }
1655
1656 const QWORD length = BASS_ChannelGetLength(sound_stream[soundEnum], BASS_POS_BYTE);
1657 sound_length[soundEnum] = static_cast<float>(BASS_ChannelBytes2Seconds(sound_stream[soundEnum], length));
1658 }
1659}
1660
1662{
1663 earMuffleChannels.Remove(stream);
1664 return BASS_StreamFree(stream);
1665}
1666
1671
1672void Sound::ApplyEarMuffle(HSTREAM stream)
1673{
1674 if (!earMuffleChannels.Apply(stream))
1675 {
1676 if (!earMuffleWarning)
1677 Trace("Ear pressure EQ unavailable on a game sound channel", Logger::Level::Warn);
1678 earMuffleWarning = true;
1679 }
1680}
1681
1683{
1684 const float amount = earPressure.Muffle();
1685 bool failed = !earMuffleChannels.SetAmount(amount);
1686 if (amount > 0.0f && !failed)
1687 {
1688 // Catch sources already playing when pressure starts changing. New sources
1689 // are also registered before playback, including radio/comms and glass FX.
1690 for (int i = 0; i < SOUND_ENUMERATION; ++i)
1691 {
1692 if (IsInterfaceSound(static_cast<SOUNDS>(i)))
1693 continue;
1694 for (const HSTREAM stream : {sound_stream[i], sound_streamFx[i]})
1695 {
1696 if (stream && BASS_ChannelIsActive(stream) != BASS_ACTIVE_STOPPED &&
1697 !earMuffleChannels.Apply(stream))
1698 failed = true;
1699 }
1700 }
1701 for (const HSTREAM stream : {radio, comms})
1702 {
1703 if (stream && BASS_ChannelIsActive(stream) != BASS_ACTIVE_STOPPED &&
1704 !earMuffleChannels.Apply(stream))
1705 failed = true;
1706 }
1707 }
1708 if (failed)
1709 {
1711 if (!earMuffleWarning)
1712 Trace("Ear pressure EQ unavailable on a game sound channel", Logger::Level::Warn);
1713 }
1714 earMuffleWarning = failed;
1715}
1716
1717void Sound::FrameMoveEarPressure(float elapsedTime)
1718{
1719 const bool active = game->displaystage == GameState::STATUS_GAME && !dead &&
1721 const bool internalCamera = active && game->viewscreen->camera && !game->viewscreen->camera->outside;
1722 bool popped = false;
1724 if (active)
1725 {
1726 const auto& player = game->GUI->player[game->GUI->ourplayerC];
1727 // CabinPressureMb also follows ambient pressure in unpressurized vehicles.
1728 // Camera position and cabin-vs-outside PressureDiffMb are not ear pressure.
1729 popped = earPressure.Update(true, player.serial, game->bus->CabinPressureMb,
1730 player.age, player.sex, elapsedTime, &pop);
1731 }
1732 else
1734 const auto playback = earPops.Update(internalCamera && std::isfinite(game->bus->CabinPressureMb) &&
1735 game->bus->CabinPressureMb >= 0.0f, active ? game->GUI->player[game->GUI->ourplayerC].serial : 0,
1736 elapsedTime, popped);
1737 if (playback.stop)
1738 {
1739 // Cancel both sounding and pending ears on camera/lifecycle changes.
1743 }
1744 if (internalCamera)
1745 UpdateEarMuffle(); // A pop keeps the filter at its pre-pop strength for this frame.
1746 else
1748 if (popped)
1749 {
1750 char msg[512];
1751 sprintf_s(msg, sizeof msg,
1752 "EARPOP altitudeM=%.3f cabinMb=%.3f ambientMb=%.3f middleMb=%.3f "
1753 "deltaMb=%+.3f thresholdMb=%.3f sincePreviousS=%.3f frameS=%.4f groundVehicle=%i internalCamera=%i",
1754 playerships[0].mslKm * 1000.0f, pop.pressureMb, game->bus->StaticAirPressureMb,
1756 pop.secondsSincePreviousPop, elapsedTime, playerships[0].groundvehicle ? 1 : 0, internalCamera ? 1 : 0);
1757 Trace(msg); // Info writes to the local trace without sending a debug/error report.
1758 }
1759 for (int i = 0; i < playback.count; ++i)
1760 {
1761 const auto& voice = playback.voices[i];
1762 // Each ear uses a different stream. The leading pop starts through the held
1763 // filter and the trailing pop follows during the existing 0.35-second release.
1764 PlayEx(static_cast<SOUNDS>(SOUND_EARPOP1 + voice.variant), false, 0.75f, voice.pitch, voice.pan);
1765 char msg[256];
1766 sprintf_s(msg, sizeof msg, "EARPOP_PLAY ear=%s variant=%i pan=%+.1f pitch=%.3f delayS=%.4f elapsedS=%.4f",
1767 voice.pan < 0 ? "left" : "right", voice.variant + 1, voice.pan, voice.pitch,
1768 voice.delaySeconds, voice.elapsedSeconds);
1769 Trace(msg);
1770 }
1771}
1772
1774{
1775 if (BASS_ChannelIsActive(comms) == BASS_ACTIVE_PLAYING)
1776 return;
1777
1778 ChangeVolume(&game->config.soundConfigLegacy, 0.5f); // intro music is at 0.5
1779}
1780
1782{
1783 const bool active = game->displaystage == GameState::STATUS_GAME && g_bEnabled && !dead
1784 && !playerships[0].isSimulator;
1785 if (!active || GetForegroundWindow() != Rendering::ClientWindow())
1787
1788 float volumes[4] = {}, pans[4] = {};
1789 bool attached[4] = {};
1790 if (active)
1791 for (int slot = 0; slot < MAX_SCAN; ++slot)
1792 {
1793 const auto& vehicle = playerships[slot];
1794 if (!vehicle.active || !(vehicle.hornPressed || vehicle.crashHornFault)
1795 || vehicle.isSimulator || !vehicle.groundvehicle || (slot != 0 && !vehicle.visible)) continue;
1796 const int kind = vehicle.type == VehicleType::T27 ? 1
1797 : vehicle.type == VehicleType::T120 || vehicle.type == VehicleType::T121 ? 2
1798 : strncmp(vehicle.hullname, "ECTO ", 5) == 0 ? 3 : 0;
1799 const float distance = slot == 0 ? 0.f : vehicle.distance;
1800 if (distance < 0.f || distance >= 1.f) continue;
1801 const float volume = 1.f - sqrtf(distance);
1802 if (volume <= volumes[kind]) continue;
1803 volumes[kind] = volume;
1804 attached[kind] = slot == 0;
1805 const auto relative = vehicle.position - playerships[0].position;
1806 RiseMath::Vector3 local;
1807 RiseMath::Vec3TransformNormal(&local, &relative, &playerships[0].matrixInvOrientation);
1808 pans[kind] = slot == 0 ? headPanScalar : Clamp(local.x / RiseMath::Max(distance, .0001f), -1.f, 1.f) + headPanScalar;
1809 }
1810 // Match the existing sound engine's one voice per sound kind: the loudest
1811 // vehicle supplies spatial parameters, and the last requester releases it.
1812 for (int kind = 0; kind < 4; ++kind)
1813 {
1814 const auto start = static_cast<SOUNDS>(SOUND_HORNCAR_START + kind * 3);
1815 const auto loop = static_cast<SOUNDS>(start + 1);
1816 const auto end = static_cast<SOUNDS>(start + 2);
1817 auto& playback = hornPlayback[kind];
1818 if (!active)
1819 {
1820 Stop(start); Stop(loop); Stop(end);
1821 playback = {};
1822 hornVolume[kind] = hornPan[kind] = 0.f;
1823 hornAttached[kind] = false;
1824 continue;
1825 }
1826 const bool requested = volumes[kind] > 0.f;
1827 if (requested)
1828 {
1829 hornVolume[kind] = volumes[kind];
1830 hornPan[kind] = pans[kind];
1831 hornAttached[kind] = attached[kind];
1832 }
1833 const auto previous = playback.phase;
1834 const auto previousSound = previous == VehicleHorn::Phase::Start ? start
1835 : previous == VehicleHorn::Phase::Loop ? loop : end;
1836 const bool finished = BASS_ChannelIsActive(sound_stream[previousSound]) != BASS_ACTIVE_PLAYING
1837 && BASS_ChannelIsActive(sound_streamFx[previousSound]) != BASS_ACTIVE_PLAYING;
1838 const auto phase = playback.Update(requested, finished);
1839 const bool changed = phase != previous;
1840 if (changed) { Stop(start); Stop(loop); Stop(end); }
1841 if (phase == VehicleHorn::Phase::Idle) continue;
1842 const auto sound = phase == VehicleHorn::Phase::Start ? start
1843 : phase == VehicleHorn::Phase::Loop ? loop : end;
1844 PlayEx(sound, phase == VehicleHorn::Phase::Loop, hornVolume[kind], 1.f,
1845 hornPan[kind], changed, true, hornAttached[kind]);
1846 }
1847}
1848
1849void Sound::FrameMoveWipers(float elapsedTime)
1850{
1851 const auto& wipers = playerships[0].wipers;
1852 const float phase = wipers.phase;
1853 const bool active = game->displaystage == GameState::STATUS_GAME && g_bEnabled
1854 && !dead && !playerships[0].isSimulator;
1855 // Share the loader's validated blade detection with rain clearing. A second
1856 // geometry check here used a different travel threshold and could mute blades.
1857 const bool animated = active && game->viewscreen->hasAnimatedWipers;
1858 // Pneumatic protection shares this sound slot but has no blade animation.
1859 // Use the same supply state as the glass and CAS, at the recording's own pitch.
1860 if (active && !animated && elapsedTime > 0.f && std::isfinite(elapsedTime))
1861 {
1862 // Authored audio transition, not a change to the rain-air supply model.
1863 // Ramp from the current gain so reversing the switch never jumps in volume.
1864 const float step = elapsedTime / 1.5f;
1865 const float target = game->bus->RainAirStatus == RainAir::State::Active ? 1.f : 0.f;
1866 bleedAirGain += std::clamp(target - bleedAirGain, -step, step);
1867 if (bleedAirGain > 0.f)
1868 {
1869 PlayEx(SOUND_WINDSHIELDWIPERS, true, bleedAirGain, 1.f, headPanScalar, false, true, true);
1870 PlayEx(SOUND_RAINAIRRUSH, true, bleedAirGain, 1.f, headPanScalar, false, true, false);
1871 return;
1872 }
1873 }
1874 else
1875 bleedAirGain = 0.f; // No fade tail may survive simulator entry or inactive playback.
1877 const bool moving = active && animated && elapsedTime > 0.f && wipers.moving;
1878 if (!moving)
1879 {
1881 return;
1882 }
1883
1884 const auto sound = SOUND_WINDSHIELDWIPERS;
1885 const bool wasPlaying = BASS_ChannelIsActive(sound_stream[sound]) == BASS_ACTIVE_PLAYING
1886 || BASS_ChannelIsActive(sound_streamFx[sound]) == BASS_ACTIVE_PLAYING;
1887 // One recording is a complete out-and-back stroke. Share the animation's
1888 // cycle rate; PlayEx applies the existing exterior/hull and glass FX path.
1889 const float rate = WiperAudio::PlaybackRate(sound_length[sound], wipers.rate);
1890 if (rate <= 0.f) return; // missing/disabled audio must not affect the blades
1891 PlayEx(sound, true, 1.f, rate, headPanScalar, false, true, true);
1892 const HSTREAM stream = sound_fxEnabled[sound] ? sound_streamFx[sound] : sound_stream[sound];
1893 if (stream && !WiperAudio::Synchronize(stream, phase, sound_length[sound],
1894 wipers.rate, !wasPlaying))
1895 {
1896 Stop(sound);
1897 Trace("Could not synchronize windshield wiper audio", Logger::Level::Warn);
1898 }
1899}
1900
1901void Sound::FrameMove(float elapsedTime)
1902{
1903 if (dead)
1905 else
1906 FrameMoveCabinAnnouncements(elapsedTime);
1907
1908 headPanScalar = -RiseMath::ToDegree(game->viewscreen->camera->currentPan) / 90.0f; // -1 is left to +1 is right
1909 if (IsInvalidFloat(headPanScalar))
1910 {
1911 Trace("Sound::FrameMove reset non-finite headPanScalar", Logger::Level::Warn);
1912 headPanScalar = 0.0f;
1913 }
1914
1915 FrameMoveAAC();
1916 FrameMoveDelayedEffects(elapsedTime);
1917 FrameMoveDopplerEffects(elapsedTime);
1918
1919 // Follow the current condition even after a cockpit reload or audio reset.
1920 // PlayEx preserves the position of an already running loop.
1921 // Zero Vne means no configured limit (for example, the E-10), not zero safe speed.
1922 // Match the VMU power cutoff; this continuous warning runs outside its voice queue.
1923 if (!IsInvalidFloat(ourcockpit.power) && ourcockpit.power > 0.75f &&
1924 playerships[0].reference != REF_INANOTHER && playerships[0].mslKm != -1.f &&
1925 !IsInvalidFloat(game->bus->IndicatedAirspeedKms) && !IsInvalidFloat(game->bus->ComputedVneKms) &&
1927 PlayEx(SOUND_OVERSPEED, true, 1.f, 1.f, 0.f, false);
1928 else
1930
1931
1932#pragma region Ambient Cockpit Sound
1933
1934 const float BaseGain = 0.45f;
1935 const float BasePitch = 0.875f;
1936
1937 // Stronger modulation (you had 0.4f — this makes it VERY audible)
1938 const float SlowDriftGain = 0.12f;
1939
1940 // More separated frequencies (faster noticeable beating)
1941 const float SlowDriftF1 = 0.08f; // ~8.3s period
1942 const float SlowDriftF2 = 0.14f; // ~4.7s period
1943
1944 // Pitch coupling
1945 const float PitchPerGain = 0.15f;
1946
1947 const float PressGainScale = 0.06f; // up to ~6% gain swing from press system
1948 const float PressPitchScale = 0.03f; // up to ~3% pitch swing from press system
1949
1950 const float ThrustGainScale = 0.05f; // up to ~5% gain swing from thrust
1951 const float ThrustPitchScale = 0.02f; // up to ~2% pitch swing from thrust
1952
1953 // --- Combined slow drift with gentle HVAC load easing ---
1954 float waveform = 2.0f * RiseMath::Pi * static_cast<float>(Rendering::ClientTime());
1955 float raw = sinf(waveform * SlowDriftF1 + 0.9f) * 0.65f + sinf(waveform * SlowDriftF2) * 0.35f;
1956
1957 // Gentle nonlinear ease curve (keeps transitions smoother, feels like fan PID)
1958 float eased = raw * fabsf(raw); // preserves sign, smooths extremes
1959
1960 float slow = eased * SlowDriftGain;
1961
1962
1963 // 2) Pressurization effect (only strong when you're actually working the cabin)
1964 float pressNorm = 0.0f;
1965 if (game->bus->PressureDiffMb > 1.0f)
1966 {
1967 // -1..+1 based on diff / design diff; clamp to avoid insanity
1968 float n = game->bus->PressureDiffMb / 0.322f;
1969 if (n < -1.0f) n = -1.0f;
1970 if (n > 1.0f) n = 1.0f;
1971 pressNorm = n;
1972 }
1973
1974 // 3) Thrust effect (avionics fans / bleed / electrical bus hum)
1975 float thrust01 = game->bus->EngineThrustOutput[0];
1976 if (thrust01 < 0.0f) thrust01 = 0.0f;
1977 if (thrust01 > 1.0f) thrust01 = 1.0f;
1978
1979 // Combine contributions
1980 float pressGain = pressNorm * PressGainScale;
1981 float pressPitch = pressNorm * PressPitchScale;
1982
1983 float thrustGain = thrust01 * ThrustGainScale;
1984 float thrustPitch = thrust01 * ThrustPitchScale;
1985
1986 // Final output
1987 float gain = BaseGain * (1.0f + slow + pressGain + thrustGain);
1988 float pitch = BasePitch * (1.0f + slow * PitchPerGain + pressPitch + thrustPitch);
1989
1990 PlayEx(SOUND_COCKPITAMBIENT, true, gain * (playerships[0].isSimulator ? 1.0f : ourcockpit.power), pitch * (playerships[0].isSimulator ? 1.0f : ourcockpit.power));
1991
1992#pragma endregion
1993
1994
1995 if (radioAutoMute < 1.0f)
1996 {
1997 bool playing = false;
1998
1999 // ATC or GPS
2000 if (comms)
2001 playing |= BASS_ChannelIsActive(comms) == BASS_ACTIVE_PLAYING;
2002
2003 // VMU
2004 playing |= game->bus->vmuHold > 0;
2005
2006 // any looped avionics
2007 playing |= BASS_ChannelIsActive(sound_stream[SOUND_OVERSPEED]) == BASS_ACTIVE_PLAYING;
2008 playing |= BASS_ChannelIsActive(sound_stream[SOUND_APTRIMCLACKER]) == BASS_ACTIVE_PLAYING;
2009 playing |= BASS_ChannelIsActive(sound_stream[SOUND_PROXIMITY]) == BASS_ACTIVE_PLAYING;
2010 playing |= BASS_ChannelIsActive(sound_stream[SOUND_OUTERMARKER]) == BASS_ACTIVE_PLAYING;
2011 playing |= BASS_ChannelIsActive(sound_stream[SOUND_MIDDLEMARKER]) == BASS_ACTIVE_PLAYING;
2012 playing |= BASS_ChannelIsActive(sound_stream[SOUND_INNERMARKER]) == BASS_ACTIVE_PLAYING;
2013
2014 // other one-shot avionics
2015 playing |= BASS_ChannelIsActive(sound_stream[SOUND_AOA]) == BASS_ACTIVE_PLAYING;
2016 playing |= BASS_ChannelIsActive(sound_stream[SOUND_APCAVALRY]) == BASS_ACTIVE_PLAYING;
2017 playing |= BASS_ChannelIsActive(sound_stream[SOUND_APCCHORD]) == BASS_ACTIVE_PLAYING;
2018 playing |= BASS_ChannelIsActive(sound_stream[SOUND_CYCLETARGET]) == BASS_ACTIVE_PLAYING;
2019 playing |= BASS_ChannelIsActive(sound_stream[SOUND_MIDWAYTARGET]) == BASS_ACTIVE_PLAYING;
2020 playing |= BASS_ChannelIsActive(sound_stream[SOUND_MASTERWARNING]) == BASS_ACTIVE_PLAYING;
2021 playing |= BASS_ChannelIsActive(sound_stream[SOUND_MASTERCAUTION]) == BASS_ACTIVE_PLAYING;
2022
2023 if (!playing)
2024 {
2025 radioAutoMute = 1.0f;
2027 }
2028 }
2029}
2030
2032{
2033 game->logger->AddToCallStack("EnvironmentalSounds");
2034
2035 PlotType newambtype;
2036 char newambtype2;
2037 float newAmbientVolume;
2038
2039 // @todo run doppler calculation on these
2040
2042 // mining, farming, and industrial for now
2043 if ((gridarray[31][31].type == PlotType::UserMining || gridarray[31][31].type == PlotType::UserFarming || gridarray[31][31].type == PlotType::UserRefinery ||
2044 gridarray[31][31].type == PlotType::DeoisIndustrial || gridarray[31][31].type == PlotType::NorthPole)
2045 && gridarray[31][31].powered)
2046 newambtype = gridarray[31][31].type;
2047 else
2048 newambtype = PlotType::NotZoned;
2049 // At Deois (300 m MSL), 2.494x Earth's air density makes 19.8 m/s load-equivalent to Earth's 70 mph.
2050 constexpr float easWindThresholdKms = 0.020f; // Rounded to 20 m/s (72 km/h) for sustained wind or gusts.
2051 // Includes the applied gust before vehicle velocity is added to calculate airspeed.
2052 const float gustWindSpeedKms = RiseMath::Vec3Length(&game->viewscreen->ptrPropulsion->localWindVector);
2053 if (gridarray[31][31].IsDeois() &&
2054 (game->viewscreen->ptrWeather->GetPrecip() > 14.0f ||
2055 game->viewscreen->ptrWeather->GetWindspeedKms() >= easWindThresholdKms ||
2056 gustWindSpeedKms >= easWindThresholdKms))
2057 newambtype2 = 1; // Weather alerts take priority over beach ambience.
2058 else if ((gridarray[31][31].pri_transition != 0 || gridarray[31][31].sec_transition != 0) &&
2059 (gridarray[31][31].pri_landform == 1 || gridarray[31][31].sec_landform == 1 || gridarray[31][31].ter_landform == 1))
2060 newambtype2 = 6; // beach
2061 else
2062 newambtype2 = 0;
2063
2064 RiseMath::Vector3 ul, ll, lr, ur;
2065 switch (gridarray[31][31].zone)
2066 {
2067 case 3: // south east
2068 ul = insidearray[31][31][2];
2069 ur = insidearray[31 + 1][31][1];
2070 ll = insidearray[31][31 + 1][0];
2071 lr = gridarray[31 + 1][31 + 1].position;
2072 break;
2073 case 4: // south west
2074 ul = insidearray[31][31][1];
2075 ur = insidearray[31][31][2];
2076 ll = gridarray[31][31 + 1].position;
2077 lr = insidearray[31][31 + 1][0];
2078 break;
2079 case 2: // north east
2080 ul = insidearray[31][31][0];
2081 ur = gridarray[31 + 1][31].position;
2082 ll = insidearray[31][31][2];
2083 lr = insidearray[31 + 1][31][1];
2084 break;
2085 case 1: // north west
2086 ul = gridarray[31][31].position;
2087 ll = insidearray[31][31][1];
2088 ur = insidearray[31][31][0];
2089 lr = insidearray[31][31][2];
2090 break;
2091 case 0:
2092 ul = gridarray[31][31].position;
2093 ur = gridarray[32][31].position;
2094 lr = gridarray[32][32].position;
2095 ll = gridarray[31][32].position;
2096 break;
2097 }
2098
2099 result += (ul + ll + ur + lr) * 0.25f; // center
2100 float f_temp = RiseMath::Vec3Length(&result);
2101 if (gridarray[31][31].zone == 0 && f_temp < 1.0f) // 1km away
2102 {
2103 newAmbientVolume = powf(f_temp, 2.0f); // 0 close 1 far away
2104 newAmbientVolume = 1.0f - newAmbientVolume;
2105 }
2106 else if (gridarray[31][31].zone != 0 && f_temp < 0.5f) // 1km away
2107 {
2108 f_temp *= 2.0f; // scale it to 0-1
2109 newAmbientVolume = powf(f_temp, 2.0f); // 0 close 1 far away
2110 newAmbientVolume = 1.0f - newAmbientVolume;
2111 }
2112 else if (newambtype == PlotType::NotZoned)
2113 newAmbientVolume = Clamp(1.0f - f_AGL, 0, 1);
2114 else
2115 newAmbientVolume = 0.0f;
2116
2117 if (newambtype != ambtype1 || newambtype2 != ambtype2 || fabsf(newAmbientVolume - oldAmbientVolume) >= MIN_VOL_DELTA)
2118 {
2119 if (newambtype == PlotType::UserMining)
2120 PlayEx(SOUND_MINING, true, newAmbientVolume, 1, 0, false, true);
2121 else
2123 if (newambtype == PlotType::UserFarming)
2124 PlayEx(SOUND_FARMING, true, newAmbientVolume, 1, 0, false, true);
2125 else
2127 if (newambtype == PlotType::UserRefinery)
2128 PlayEx(SOUND_REFINERY, true, newAmbientVolume, 1, 0, false, true);
2129 else
2131 if (newambtype == PlotType::DeoisIndustrial)
2132 PlayEx(SOUND_INDUSTRIAL, true, newAmbientVolume, 1, 0, false, true);
2133 else
2135 if (newambtype == PlotType::NorthPole && game->GUI->tm_time.tm_mon == 11 && game->GUI->tm_time.tm_mday >= 11 && game->GUI->tm_time.tm_mday <= 25) // Dec 11-25
2136 PlayEx(SOUND_SILVERBELLS, true, newAmbientVolume, 1, 0, false, true);
2137 else
2139 if (newambtype == PlotType::NotZoned)
2140 PlayEx(SOUND_OPENAIR, true, newAmbientVolume, 1, 0, false, true);
2141 else
2143
2144 if (newambtype2 == 6)
2145 PlayEx(SOUND_SHORE, true, newAmbientVolume, 1, 0, false, true);
2146 else
2148 if (newambtype2 == 1)
2149 PlayEx(SOUND_EAS, true, newAmbientVolume, 1, 0, false, true);
2150 else
2151 Stop(SOUND_EAS);
2152
2153 ambtype1 = newambtype;
2154 ambtype2 = newambtype2;
2155 oldAmbientVolume = newAmbientVolume;
2156 }
2157}
2158
2159void Sound::LoadSounds(short instage)
2160{
2162 {
2163 // set legacy
2164 if (!BASS_SetDevice(game->config.soundConfigLegacy.bassDevice))
2165 {
2166 Trace("BASS_SetDevice failed on LoadSounds() legacy device", Logger::Level::Error);
2167 }
2168
2169#ifndef NEWINTRO
2170 game->TouchFile(L"Sounds\\ambience.ogg");
2171
2172 g_pSoundIntro = BASS_StreamCreateFile(false, "Sounds\\ambience.ogg", 0, 0, BASS_STREAM_PRESCAN);
2173 if (!g_pSoundIntro)
2174 {
2175 char msg[99];
2176 sprintf_s(msg, sizeof msg, "LoadSounds BASS_StreamCreateFile error: %i", BASS_ErrorGetCode());
2178 }
2179#else
2180 game->TouchFile(L"Sounds\\goth.ogg");
2181
2182 g_pSoundIntro = BASS_StreamCreateFile(false, "Sounds\\goth.ogg", 0, 0, BASS_STREAM_PRESCAN);
2183 if (!g_pSoundIntro)
2184 {
2185 char msg[99];
2186 sprintf_s(msg, sizeof msg, "LoadSounds BASS_StreamCreateFile error: %i", BASS_ErrorGetCode());
2188 }
2189#endif
2190
2191 if (!BASS_ChannelSetAttribute(g_pSoundIntro, BASS_ATTRIB_VOL, game->config.soundConfigLegacy.volume * globalAttenuate * 0.5f))
2192 {
2193 char msg[99];
2194 sprintf_s(msg, sizeof msg, "LoadSounds BASS_ChannelSetAttribute error: %i", BASS_ErrorGetCode());
2196 }
2197
2198 if (!BASS_ChannelPlay(g_pSoundIntro, true))
2199 {
2200 char msg[99];
2201 sprintf_s(msg, sizeof msg, "LoadSounds BASS_ChannelPlay error: %i", BASS_ErrorGetCode());
2203 }
2204
2205#ifndef NEWINTRO
2206 hsync = BASS_ChannelSetSync(g_pSoundIntro, BASS_SYNC_POS | BASS_SYNC_MIXTIME, BASS_ChannelSeconds2Bytes(g_pSoundIntro, 24.061f), AdvanceStage, this);
2207 if (!hsync)
2208 {
2209 char msg[99];
2210 sprintf_s(msg, sizeof msg, "LoadSounds BASS_ChannelSetSync error: %i", BASS_ErrorGetCode());
2212 }
2213#else
2214 if (g_pSoundIntro)
2215 hsync = BASS_ChannelSetSync(g_pSoundIntro, BASS_SYNC_POS | BASS_SYNC_MIXTIME, BASS_ChannelSeconds2Bytes(g_pSoundIntro, 10.970f), AdvanceStage, this); // 16.670f - 5.7 second fade
2216 if (!hsync)
2217 {
2218 char msg[99];
2219 sprintf_s(msg, sizeof msg, "LoadSounds BASS_ChannelSetSync error: %i", BASS_ErrorGetCode());
2221 }
2222#endif
2223 }
2224
2225 if (instage < SOUND_THUNDER_NEAR)
2226 return; // these are all the cockpit-specific sounds
2227
2228 if ((instage >= SOUND_HORNCAR_START && instage <= SOUND_ECTO1_END) || (instage >= SOUND_EARPOP1 && instage <= SOUND_EARPOP3))
2229 LoadSound(instage);
2230 else if (instage == SOUND_SPEAKERPOP || instage == SOUND_EXPLODE2) // explode2 is sinkerhit which is EM burst
2232 else if (instage < SOUND_APTRIMCLACKER)
2233 LoadSound(instage);
2234 else if (instage < SOUND_DOCKANNOUNCE1)
2236 else if (instage < SOUND_RADIOCUT1)
2237 LoadSound(instage);
2238 else if (instage <= SOUND_RADIOCARRIER11)
2240}
2241
2243{
2244 char msg[99];
2245 sprintf_s(msg, sizeof msg, "LegacySoundRequestUniverse x%.0f y%.0f z%.0f w%.0f %i", datapacket.f_x, datapacket.f_y, datapacket.f_z, datapacket.f_w, datapacket.array);
2246 Trace(msg);
2247
2248 if (datapacket.array == 0)
2249 {
2250 Trace("Should not be getting LegacySoundRequestUniverse calls with our slot!", Logger::Error);
2251 return;
2252 }
2253
2254 if (datapacket.array >= MAX_SCAN)
2255 {
2256 Trace("LegacySoundRequestUniverse called with out-of-bounds array value!", Logger::Error);
2257 return;
2258 }
2259
2260 if (!playerships[datapacket.array].active || !playerships[datapacket.array].visible)
2261 {
2262 Trace("LegacySoundRequestUniverse got a call for a vehicle that was not visible or was not active!", Logger::Warn);
2263 return;
2264 }
2265
2266 if (datapacket.f_x == 0.0f) // car noises
2267 {
2268 if (datapacket.f_y == 4.0f) // reverse off
2270 else if (playerships[0].reference <= REF_BUILDING) // doppler calculate distance
2271 {
2272 if (playerships[datapacket.array].reference < REF_INANOTHER)
2273 {
2274 RiseMath::Vector3 source, dest;
2275 source = playerships[datapacket.array].position;
2276 if (playerships[0].reference == REF_INANOTHER)
2278 else
2279 dest = playerships[0].position;
2280
2281 RiseMath::Vector3 result = dest - source; // has to be "dest - source" otherwise the sounds get flipped!
2282
2283 // we said a kilometer in clear still conditions
2284 float tfal = sqrtf(playerships[datapacket.array].distance / 1.0f); // 0 up close, 1 at 1.6km, .7 at .8km (instead of .5)
2285 if (tfal > 1.0f)
2286 tfal = 1.0f;
2287 float newvolume = 1.0f - tfal; // 1 up close, .3 at .8km (instead of .5), 0 at distance
2288
2289 float closing = -playerships[datapacket.array].closurerate; // 10 - 5 is 5 // this was backwards 12/24/2023 with car alarm flying away
2290 if (_isnan(closing) || isinf(closing))
2291 {
2292 Trace("playerships[datapacket.array].closurerate is NAN", Logger::Debug);
2293 closing = 0.0f;
2294 }
2296 if (_isnan(closing) || isinf(closing))
2297 {
2298 Trace("game->viewscreen->ptrPropulsion->speedOfSoundKms is NAN", Logger::Debug);
2299 closing = 0.0f;
2300 }
2301 closing++;
2302
2304 float bear1;
2305 if (result.z != 0.0f)
2306 {
2307 bear1 = RiseMath::ToDegree(atanf(result.x / result.z));
2308 float mark1 = RiseMath::ToDegree(atanf(result.y / result.z));
2309 float f_temp = sqrtf(mark1 * mark1 + bear1 * bear1);
2310 if (f_temp > 180.0f)
2311 {
2312 f_temp = 180.0f / f_temp;
2313 bear1 *= f_temp;
2314 }
2315 if (result.z > 0.0f) // Behind us
2316 {
2317 if (bear1 > 0.0f)
2318 bear1 -= 180.0f;
2319 else
2320 bear1 += 180.0f;
2321 }
2322 }
2323 else // directly above or below
2324 {
2325 bear1 = 0.0f;
2326 }
2327 float pan = bear1 / 90.0f; // -90 is -1, -180 is -2
2328 if (std::isnan(pan))
2329 {
2330 pan = 0.0f;
2331 Trace("We are getting a NAN pan from LegacySoundRequestUniverse", Logger::Level::Debug);
2332 }
2333
2334 if (datapacket.f_y == 0.0f) // horn
2335 {
2336 if (_strcmpi(playerships[datapacket.array].hullname, "PARADE1") == 0)
2338 else if (playerships[datapacket.array].police)
2339 PlayEx(SOUND_POLICECHIRP, false, newvolume, closing, pan + headPanScalar, false, true); // sound is coming from left -1 ... I am looking left -1 ... -1 --1 -1+1 0
2340 // Vehicle horns use ordered start/stop events, not one-shot sound packets.
2341 }
2342 else if (datapacket.f_y == 1.0f) // brakes on
2343 PlayEx(playerships[datapacket.array].type == VehicleType::T120 || playerships[datapacket.array].type == VehicleType::T121 ? SOUND_AIRBRAKEON : SOUND_AIRBRAKEONMAMMOTH, false, newvolume, closing, pan + headPanScalar, false, true);
2344 else if (datapacket.f_y == 2.0f) // brakes off
2345 PlayEx(playerships[datapacket.array].type == VehicleType::T120 || playerships[datapacket.array].type == VehicleType::T121 ? SOUND_AIRBRAKEOFF : SOUND_AIRBRAKEOFFMAMMOTH, false, newvolume, closing, pan + headPanScalar, false, true);
2346 else if (datapacket.f_y == 3.0f) // reverse on
2348 else if (datapacket.f_y == 5.0f) // alarm on
2349 {
2351 playerships[datapacket.array].alarm = true;
2352 }
2353 else if (datapacket.f_y == 6.0f) // alarm off
2354 {
2356 playerships[datapacket.array].alarm = false;
2357 PlayEx(SOUND_ALARMCHIRP, false, newvolume, closing, pan + headPanScalar, false, true);
2358 }
2359 }
2360 }
2361 }
2362 else if (datapacket.f_x == 1.0f) // sonic boom
2363 {
2364 const RiseMath::Vector3 source = playerships[datapacket.array].position;
2365
2366 RiseMath::Vector3 dest;
2367 if (playerships[0].reference == REF_INANOTHER)
2369 else if (playerships[0].reference <= REF_BUILDING)
2370 dest = playerships[0].position;
2371 else
2372 dest.x = dest.y = dest.z = 0.0f;
2373
2374 RiseMath::Vector3 result = dest - source; // has to be "dest - source" otherwise the sounds get flipped!
2375 float distance = RiseMath::Vec3Length(&result);
2376
2377 if (distance < 50.0f) // 30-50 km limit
2378 {
2379 float f_temp = distance / 50.0f; // 0 is close, 1 is far
2380 f_temp = 1.0f - f_temp; // 1 is close, 0 is far
2381 f_temp = powf(f_temp, 3.0f); // steeper tail-off
2382
2383 Trace("Sonic boom detected!");
2384
2385 if (f_temp < 1.0f)
2386 {
2387 const float delay = distance / SeaLevelSpeedOfSoundKms;
2388 AddDelayedSound(SOUND_SONICBOOM, delay, f_temp, 1, true);
2389 }
2390 }
2391 }
2392 else if (datapacket.f_x == 2.0f) // sea monster
2393 {
2394 const RiseMath::Vector3 source = playerships[datapacket.array].position;
2395
2396 RiseMath::Vector3 dest;
2397 if (playerships[0].reference == REF_INANOTHER)
2399 else if (playerships[0].reference <= REF_BUILDING)
2400 dest = playerships[0].position;
2401 else
2402 dest.x = dest.y = dest.z = 0.0f;
2403
2404 RiseMath::Vector3 result = dest - source; // has to be "dest - source" otherwise the sounds get flipped!
2405 float distance = RiseMath::Vec3Length(&result);
2406
2407 if (distance < 10.0f) // 10 km limit
2408 {
2409 float f_temp = distance / 10.0f; // 0 is close, 1 is far
2410 f_temp = 1.0f - f_temp; // 1 is close, 0 is far
2411 //f_temp = powf(f_temp, 3.0f); // steeper tail-off
2412
2413 Trace("Sea monster call detected!");
2414
2415 if (f_temp < 1.0f)
2416 {
2417 const float delay = distance / SeaLevelSpeedOfSoundKms;
2418 AddDelayedSound(SOUND_HOLIDAY2026, delay, f_temp, 1, true);
2419 }
2420 }
2421 }
2422}
2423
2425{
2426 game->logger->AddToCallStack("Sound::FrameMoveAAC");
2427
2429 return;
2430
2432 {
2433 BASS_SetDevice(game->config.soundConfigRadio.bassDevice);
2435 }
2436
2438 {
2439 g_bRadioPlaying = false;
2441 radio = NULL; // BASS_StreamFree does NOT NULL the radio!
2442 currentRadioDevice = -2;
2443 }
2444
2445 // we have it know if radio is supposed to be on, correct channel is selected, how to handle volume
2447 {
2448 DWORD channelStatus = BASS_ChannelIsActive(radio);
2449 if (channelStatus != BASS_ACTIVE_PLAYING)
2450 {
2452 if (!BASS_ChannelPlay(radio, FALSE))
2453 {
2454 const int error = BASS_ErrorGetCode();
2455 if (error == BASS_ERROR_HANDLE || error == BASS_ERROR_UNKNOWN)
2456 channelStatus = BASS_ACTIVE_STOPPED;
2457 else
2458 channelStatus = BASS_ACTIVE_PLAYING;
2459 }
2460 else
2461 channelStatus = BASS_ACTIVE_PLAYING;
2462 }
2463
2464 // was playing, no station change, station has good reception
2465 if (oldstation == game->bus->station && channelStatus)
2466 return;
2467
2468 // either was not on, changed station, or lost the station
2469 if (oldstation == game->bus->station && (!radio || !channelStatus))
2470 {
2471 char msg[99];
2472 sprintf_s(msg, sizeof msg, "FrameMoveAAC Lost stream or stream ended... reconnecting... station %i", game->bus->station);
2474 }
2475 else if (oldstation != game->bus->station && radio && channelStatus)
2476 {
2477 Trace("FrameMoveAAC Changed radio stations...");
2478 stationIdentification = rand() % 12 - 1; // -1 because we will get a new metadata right away // 0-30 minutes
2479 celebrity = rand() % 3;
2480 ourcockpit.radioplaying[0] = 0;
2481 }
2482
2483 if (oldstation != game->bus->station)
2484 {
2485 switch (game->bus->station)
2486 {
2487 case 1:
2488 LoadCustomSound(SOUND_STATIONIDLL, "Sounds\\Radio\\stationid1ll.mp3", &game->config.soundConfigRadio);
2489 LoadCustomSound(SOUND_STATIONIDWM, "Sounds\\Radio\\stationid1wm.mp3", &game->config.soundConfigRadio);
2490 LoadCustomSound(SOUND_STATIONIDCK, "Sounds\\Radio\\stationid1ck.mp3", &game->config.soundConfigRadio);
2491 break;
2492 case 2:
2493 LoadCustomSound(SOUND_STATIONIDLL, "Sounds\\Radio\\stationid2ll.mp3", &game->config.soundConfigRadio);
2494 LoadCustomSound(SOUND_STATIONIDWM, "Sounds\\Radio\\stationid2wm.mp3", &game->config.soundConfigRadio);
2495 LoadCustomSound(SOUND_STATIONIDCK, "Sounds\\Radio\\stationid2ck.mp3", &game->config.soundConfigRadio);
2496 break;
2497 case 3:
2498 LoadCustomSound(SOUND_STATIONIDLL, "Sounds\\Radio\\stationid3ll.mp3", &game->config.soundConfigRadio);
2499 LoadCustomSound(SOUND_STATIONIDWM, "Sounds\\Radio\\stationid3wm.mp3", &game->config.soundConfigRadio);
2500 LoadCustomSound(SOUND_STATIONIDCK, "Sounds\\Radio\\stationid3ck.mp3", &game->config.soundConfigRadio);
2501 break;
2502 case 4:
2503 LoadCustomSound(SOUND_STATIONIDLL, "Sounds\\Radio\\stationid4ll.mp3", &game->config.soundConfigRadio);
2504 LoadCustomSound(SOUND_STATIONIDWM, "Sounds\\Radio\\stationid4wm.mp3", &game->config.soundConfigRadio);
2505 LoadCustomSound(SOUND_STATIONIDCK, "Sounds\\Radio\\stationid4ck.mp3", &game->config.soundConfigRadio);
2506 break;
2507 case 5:
2508 LoadCustomSound(SOUND_STATIONIDLL, "Sounds\\Radio\\stationid5ll.mp3", &game->config.soundConfigRadio);
2509 LoadCustomSound(SOUND_STATIONIDWM, "Sounds\\Radio\\stationid5wm.mp3", &game->config.soundConfigRadio);
2510 LoadCustomSound(SOUND_STATIONIDCK, "Sounds\\Radio\\stationid5ck.mp3", &game->config.soundConfigRadio);
2511 break;
2512 }
2513 }
2514
2515 if (oldstation != game->bus->station || !radio || !channelStatus)
2516 {
2517 g_bRadioPlaying = false;
2518 FreeStream(radio); // close old stream
2519 radio = NULL; // BASS_StreamFree does NOT NULL the radio!
2520 if (game->bus->station > 0 && game->bus->station < 6 && stationUrls[game->bus->station][0])
2521 {
2522 radio = BASS_StreamCreateURL(stationUrls[game->bus->station], 0, BASS_STREAM_STATUS, nullptr, nullptr);
2524 {
2525 if (!BASS_ChannelStop(g_pSoundIntro))
2526 {
2527 char msg[99];
2528 sprintf_s(msg, sizeof msg, "FrameMoveAAC BASS_ChannelStop(g_pSoundIntro) failed: %i", BASS_ErrorGetCode());
2530 }
2531 }
2532 }
2533 }
2534
2535 if (!radio)
2536 {
2537 const int hr = BASS_ErrorGetCode();
2538 char msg[99];
2539 sprintf_s(msg, sizeof msg, "FrameMoveAAC BASS_StreamCreateURL failed (%i) for station: %i", hr, game->bus->station);
2541 ourcockpit.radioPower = false;
2543 }
2544 else if (!g_bRadioPlaying)
2545 {
2547 if (!BASS_ChannelPlay(radio, FALSE))
2548 {
2549 char msg[99];
2550 sprintf_s(msg, sizeof msg, "FrameMoveAAC BASS_ChannelPlay error: %i", BASS_ErrorGetCode());
2552 }
2553
2554 g_bRadioPlaying = true;
2557
2558 const float modVolume = game->viewscreen->camera->attenuate;
2559 BASS_ChannelSetAttribute(radio, BASS_ATTRIB_VOL, game->config.soundConfigRadio.volume * globalAttenuate * modVolume * radioAutoMute);
2560
2561 BASS_ChannelSetSync(radio, BASS_SYNC_MIXTIME | BASS_SYNC_META, NULL, MetaData, this);
2562 }
2563 }
2564 else
2565 {
2566 if (g_bRadioPlaying)
2567 {
2568 FreeStream(radio); // close old stream
2569 radio = NULL; // freeing the stream does NOT set this to null!
2570 g_bRadioPlaying = false;
2571 }
2572 }
2573
2574 game->logger->AddToCallStack("Sound::FrameMoveAAC DONE");
2575}
2576
2577void Sound::FrameMoveDelayedEffects(float elapsedTime)
2578{
2579 game->logger->AddToCallStack("Sound::FrameMoveDelayedEffects");
2580
2581 // Discard pending lightning audio even when simulator entry skips a cockpit reload.
2582 if (playerships[0].isSimulator)
2583 delayedeffects.erase(std::remove_if(delayedeffects.begin(), delayedeffects.end(), [](const auto& effect)
2584 {
2585 return (effect.soundEnum >= SOUND_THUNDER_NEAR && effect.soundEnum <= SOUND_THUNDER_FAR5)
2586 || effect.soundEnum == SOUND_SPEAKERPOP;
2587 }), delayedeffects.end());
2588 // End simulator lightning audio reset.
2589
2590 // Clear the handprint's one-shot audio and ducking on simulator entry.
2591 if (playerships[0].isSimulator)
2592 {
2595 {
2597 globalAttenuate = 1.0f;
2598 gaTimer = 0.0f;
2599 ChangeVolume();
2600 }
2601 }
2602 // End simulator handprint audio reset.
2603
2605 {
2606 // gaVolumeAdj 0.8 instead of default 1.0
2607 // invVol 0.2 instead of 0
2608 const float invVolumeAdj = 1.0f - gaVolumeAdj;
2609 const float oldGlobalAttenuate = globalAttenuate;
2610 gaTimer += elapsedTime;
2612 globalAttenuate = 1.0f - invVolumeAdj * gaTimer / gaTimeToFadeOut;
2614 globalAttenuate = invVolumeAdj;
2617 else
2618 globalAttenuate = 1.0f;
2619 // @todo this should probably just be checked in places where we set it!
2621 {
2622 char msg[199];
2623 sprintf_s(msg, sizeof msg, "FrameMoveDelayedEffects globalAttenuate clamped volume: %.1f (%.1f, %.1f)", globalAttenuate, gaTimer, invVolumeAdj);
2625 globalAttenuate = Clamp(globalAttenuate, 0.0f, 1.0f);
2626 }
2627
2628
2629 const float oldExcludedSoundVolume = sound_volume[excludeFromGlobalAttenuate];
2630 float newExcludedSoundVolume = oldExcludedSoundVolume;
2631 if (gaTimer < exTimeToFadeIn)
2632 newExcludedSoundVolume = gaVolumeAdj * gaTimer / exTimeToFadeIn;
2633 else if (gaTimer < exTimeToFadeIn + exTimeToHold)
2634 newExcludedSoundVolume = gaVolumeAdj;
2636 newExcludedSoundVolume = gaVolumeAdj - gaVolumeAdj * (gaTimer - exTimeToFadeIn - exTimeToHold) / exTimeToFadeOut;
2637 else
2638 {
2639 newExcludedSoundVolume = 0.0f;
2642 }
2643
2644 if (fabsf(oldGlobalAttenuate - globalAttenuate) >= MIN_VOL_DELTA ||
2645 (excludeFromGlobalAttenuate != SOUND_NONE && fabsf(oldExcludedSoundVolume - newExcludedSoundVolume) >= MIN_VOL_DELTA))
2646 {
2648 sound_volume[excludeFromGlobalAttenuate] = newExcludedSoundVolume;
2649 ChangeVolume();
2650 }
2651 }
2652
2653 for (size_t t = 0; t < delayedeffects.size(); t++)
2654 {
2655 // can't make a simplified accessor because it is then a value not a ref
2656 delayedeffects.at(t).delay -= elapsedTime;
2657 if (delayedeffects.at(t).delay <= 0.0f)
2658 {
2659 char msg[199];
2660 sprintf_s(msg, sizeof msg, "FrameMoveDelayedEffects now playing %i at volume %.1f and freq %.1f (from outside %i)", delayedeffects.at(t).soundEnum, delayedeffects.at(t).volume, delayedeffects.at(t).freq, delayedeffects.at(t).fromOutside);
2661 Trace(msg);
2662
2663 PlayEx(delayedeffects.at(t).soundEnum, false, delayedeffects.at(t).volume, delayedeffects.at(t).freq, 0, true, delayedeffects.at(t).fromOutside);
2664 if (delayedeffects.at(t).soundEnum == SOUND_SHOCKWAVE)
2665 {
2666 GlobalAttenuate(0.5f, 1.5f, 6.0f, SOUND_EXPLODERING, 0.5f, 1.5f, 6.0f, delayedeffects[t].volume);
2667 PlayEx(SOUND_EXPLODERING, true, 0.0f);
2668 }
2669 delayedeffects.erase(delayedeffects.begin() + t);
2670 break;
2671 }
2672 }
2673
2674 SOUNDS oldSoundEnum = SOUND_NONE;
2675 int oldArray = -1;
2676 float oldVolume = 0, oldPan = 0, oldFreqMod = 0;
2677 for (size_t t = 0; t < loopingeffects.size(); t++)
2678 {
2679 if (loopingeffects.at(t).soundEnum != oldSoundEnum && oldSoundEnum != -1)
2680 {
2681 if (oldVolume > 0) // so backup beeper?
2682 PlayEx(oldSoundEnum, true, oldVolume, oldFreqMod, oldPan + headPanScalar, false, oldArray != 0, oldArray == 0);
2683 else
2684 Stop(oldSoundEnum);
2685 oldVolume = 0;
2686 }
2687 oldSoundEnum = loopingeffects.at(t).soundEnum;
2688
2689 if (playerships[0].reference >= REF_DOCKENUMCPOC || // in space
2690 playerships[loopingeffects.at(t).array].vehicleId != loopingeffects.at(t).vehicleId || // vehicle in that slot changed
2691 !playerships[loopingeffects.at(t).array].active || // vehicle is gone from scanner
2692 !playerships[loopingeffects.at(t).array].visible || // vehicle is gone from scanner
2693 playerships[loopingeffects.at(t).array].reference > 0) // we can't hear them
2694 {
2695 Stop(loopingeffects.at(t).soundEnum);
2696 loopingeffects.erase(loopingeffects.begin() + t);
2697 break;
2698 }
2699
2700 RiseMath::Vector3 source, sourceVel;
2702 {
2703 source = playerships[playerships[loopingeffects.at(t).array].inarray].position;
2704 sourceVel = playerships[playerships[loopingeffects.at(t).array].inarray].velocity;
2705 }
2706 else
2707 {
2708 source = playerships[loopingeffects.at(t).array].position;
2709 sourceVel = playerships[loopingeffects.at(t).array].velocity;
2710 }
2711
2712 RiseMath::Vector3 dest, destVel;
2713 if (playerships[0].reference == REF_INANOTHER)
2714 {
2717 }
2718 else
2719 {
2720 dest = playerships[0].position;
2721 destVel = playerships[0].velocity;
2722 }
2723
2724 RiseMath::Vector3 result = dest - source; // has to be "dest - source" otherwise the sounds get flipped!
2725 const RiseMath::Vector3 resultVel = sourceVel - destVel;
2726 float f_temp = RiseMath::Vec3Length(&result);
2727 //if (f_temp < 0.5f) /// @ref http://www.emmco.org/Documents/Siren%20abstract.pdf
2728 {
2729 // we said a kilometer in clear still conditions
2730 float newVolume = sqrtf(f_temp / 1.0f);
2731 if (newVolume > 1.0f)
2732 newVolume = 1.0f;
2733 newVolume = 1.0f - newVolume;
2734 if (newVolume < oldVolume)
2735 continue;
2736 oldVolume = newVolume;
2737 oldArray = loopingeffects.at(t).array;
2738
2739 oldFreqMod = RiseMath::Vec3Length(&resultVel);
2741 oldFreqMod++; // if 0 vel, it should be 1 times the speed, at 1X sound it should be double speed
2742
2744 float bear1;
2745 if (result.z != 0.0f)
2746 {
2747 bear1 = RiseMath::ToDegree(atanf(result.x / result.z));
2748 const float mark1 = RiseMath::ToDegree(atanf(result.y / result.z));
2749 f_temp = sqrtf(mark1 * mark1 + bear1 * bear1);
2750 if (f_temp > 180.0f)
2751 {
2752 f_temp = 180.0f / f_temp;
2753 bear1 *= f_temp;
2754 }
2755 if (result.z > 0.0f) // Behind us
2756 {
2757 if (bear1 > 0.0f)
2758 bear1 -= 180.0f;
2759 else
2760 bear1 += 180.0f;
2761 }
2762 }
2763 else // directly above or below
2764 {
2765 bear1 = 0.0f;
2766 }
2767 oldPan = -bear1 / 90; // -90 is -1, -179 is -2, +90 is +1, 179 would be +2
2768 if (_isnan(oldPan))
2769 Trace("We are getting a NAN oldPan from FrameMoveDelayedEffects", Logger::Level::Debug);
2770 }
2771 }
2772
2773 if (oldVolume > 0)
2774 PlayEx(oldSoundEnum, true, oldVolume, oldFreqMod, oldPan + headPanScalar, false, oldArray != 0, oldArray == 0);
2775 else if (oldSoundEnum != -1)
2776 Stop(oldSoundEnum);
2777
2778 game->logger->AddToCallStack("Sound::FrameMoveDelayedEffects DONE");
2779}
2780
2781void Sound::FrameMoveDopplerEffects(float elapsedTime)
2782{
2783 game->logger->AddToCallStack("Sound::FrameMoveDopplerEffects");
2784
2785 auto resetDopplerEffects = [this]()
2786 {
2789 oldvolume = 0.0f;
2790 oldFrequencyMod = 1.0f;
2791 oldPan = 0.0f;
2792 oldvolume2 = 0.0f;
2793 oldFrequencyMod2 = 1.0f;
2794 oldPan2 = 0.0f;
2795 };
2796
2797 if (IsInvalidFloat(elapsedTime) || elapsedTime < 0.0f)
2798 {
2799 char msg[99];
2800 sprintf_s(msg, sizeof msg, "FrameMoveDopplerEffects skipped invalid elapsedTime %.3f", elapsedTime);
2802 resetDopplerEffects();
2803 game->logger->AddToCallStack("Sound::FrameMoveDopplerEffects DONE");
2804 return;
2805 }
2806
2807 const float speedOfSoundKms = game->viewscreen->ptrPropulsion->speedOfSoundKms;
2808 if (speedOfSoundKms <= 0.0f || IsInvalidFloat(speedOfSoundKms))
2809 {
2810 char msg[99];
2811 sprintf_s(msg, sizeof msg, "FrameMoveDopplerEffects skipped invalid speedOfSoundKms %.6f", speedOfSoundKms);
2813 resetDopplerEffects();
2814 game->logger->AddToCallStack("Sound::FrameMoveDopplerEffects DONE");
2815 return;
2816 }
2817
2818 const float atmosphericSoundPressureGain =
2819 GetAtmosphericSoundPressureGain(game->viewscreen->ptrPropulsion->staticDensity);
2820 const float distantJetMaxAudibleDistanceKm =
2821 DistantJetMaxAudibleDistanceKmAtOneAtmosphere * atmosphericSoundPressureGain;
2822 const float rocketRippingMaxAudibleDistanceKm =
2823 RocketRippingMaxAudibleDistanceKmAtOneAtmosphere * atmosphericSoundPressureGain;
2824
2825 if (IsInvalidFloat(oldvolume) || IsInvalidFloat(oldFrequencyMod) || IsInvalidFloat(oldPan))
2826 {
2827 Trace("FrameMoveDopplerEffects reset non-finite doppler1 state", Logger::Level::Warn);
2828 oldvolume = 0.0f;
2829 oldFrequencyMod = 1.0f;
2830 oldPan = 0.0f;
2831 }
2832 if (IsInvalidFloat(oldvolume2) || IsInvalidFloat(oldFrequencyMod2) || IsInvalidFloat(oldPan2))
2833 {
2834 Trace("FrameMoveDopplerEffects reset non-finite doppler2 state", Logger::Level::Warn);
2835 oldvolume2 = 0.0f;
2836 oldFrequencyMod2 = 1.0f;
2837 oldPan2 = 0.0f;
2838 }
2839
2840 // Doppler, we only get data once per second...
2841 float closing1 = 1.0f, closing2 = 1.0f;
2842 float newvolume1 = 0.0f, newvolume2 = 0.0f;
2843 float pan = 0.0f, pan2 = 0.0f;
2844
2845 game->bus->DebugSoundReal = 0;
2846 game->bus->DebugSoundFake = 0;
2847 game->bus->DebugSoundBear = 0;
2848 game->bus->DebugSoundClose = 0;
2849
2850 if (playerships[0].reference < REF_DOCKENUMCPOC) // we shouldn't hear anything in dock space
2851 {
2852 RiseMath::Vector3 ourPosition, ourVelocity;
2853 if (playerships[0].reference == REF_INANOTHER)
2854 {
2855 const unsigned char parentArray = playerships[0].inarray;
2856 if (parentArray >= MAX_SCAN)
2857 {
2858 char msg[99];
2859 sprintf_s(msg, sizeof msg, "FrameMoveDopplerEffects invalid playerships[0].inarray %i", parentArray);
2861 resetDopplerEffects();
2862 game->logger->AddToCallStack("Sound::FrameMoveDopplerEffects DONE");
2863 return;
2864 }
2865
2866 ourPosition = playerships[parentArray].position;
2867 ourVelocity = playerships[parentArray].velocity - playerships[parentArray].barycentric;
2868 }
2869 else
2870 {
2871 ourPosition = playerships[0].position;
2873 }
2874
2875
2876 for (short t = 1; t < MAX_SCAN; t++)
2877 {
2878 if (playerships[t].active && playerships[t].logolight && // active and powered up
2879 (playerships[t].reference == REF_ACLMODE ||
2880 playerships[t].reference == REF_ONGROUND ||
2881 playerships[t].reference == REF_APNMODE) && // must be outside
2882 !playerships[t].isSimulator && // can't hear simulators
2883 (playerships[t].type < VehicleType::ARJ_PAX || playerships[t].type > VehicleType::ARJ_ENUM) && // not ARJ
2884 !playerships[t].groundvehicle) // not GV's
2885 {
2886 RiseMath::Vector3 realPositionDifference = ourPosition - playerships[t].position;
2887 const float realDistance = RiseMath::Vec3Length(&realPositionDifference);
2888
2889 // if he is 5km then this responds like he is at...
2890 const float delaySeconds = realDistance / speedOfSoundKms;
2891 const RiseMath::Vector3 theirVelocity = playerships[t].velocity - playerships[t].barycentric;
2892 // clamp to 8 seconds since Bill was hearing the funkiness of a vehicle 41km away going the speed of sound was backing up right on top of them
2893 // what we did is determine the lowest bill ever got to mach 1 was 16km which is 5km above the highest that we can ever visually see (9.8km elevation 1.2km cloud height)
2894 // that is a 5km difference ... Bill is getting me the SOS at 16km .305 ... that is 16 seconds to travel 5km
2895 const RiseMath::Vector3 theirSoundPosition = (playerships[t].position - theirVelocity * RiseMath::Min(delaySeconds, 8)); // back them up
2896
2897 // this new distance
2898 RiseMath::Vector3 soundPositionDifference = ourPosition - theirSoundPosition;
2899 const float soundDistance = RiseMath::Vec3Length(&soundPositionDifference);
2900
2901 RiseMath::Vec3TransformNormal(&soundPositionDifference, &soundPositionDifference, &game->viewscreen->matrixView);
2902
2903
2904 float newtons;
2905 switch (playerships[t].type)
2906 {
2907 case VehicleType::W6Manx: newtons = 1029817.0f; break;
2908 case VehicleType::E10: newtons = 2762909.0f; break;
2909 case VehicleType::E11: newtons = 3134393.0f; break;
2910 case VehicleType::P13: newtons = 1636364.0f; break;
2911 case VehicleType::T19: newtons = 246795.0f; break;
2912 case VehicleType::A4: newtons = 1388073.0f; break;
2913 default: newtons = 0.0f; break;
2914 }
2915 // @todo this is a problem because if tx ty and tz are all scalar 0-1 they are being treated equally but X is NOT as strong as Z
2916 const float thrust = newtons * sqrtf(powf(playerships[t].tx, 2.0f) + powf(playerships[t].ty, 2.0f) + powf(playerships[t].tz, 2.0f));
2917 const float fullRippingThrust = RiseMath::Max(newtons - RocketRippingThresholdNewtons, 0.0f);
2918 const float rippingThrustLevel = fullRippingThrust > 0.0f
2919 ? Clamp((thrust - RocketRippingThresholdNewtons) / fullRippingThrust, 0.0f, 1.0f)
2920 : 0.0f;
2921
2922
2923
2924 // Distant jet-engine noise can remain audible for tens of kilometers
2925 // in quiet conditions. The one-atmosphere 50 km processing limit
2926 // scales with pressure gain to keep a consistent terminal noise floor.
2927 if (soundDistance < distantJetMaxAudibleDistanceKm)
2928 {
2929 const float distanceGain = GetOutdoorEngineDistanceGain(soundDistance);
2930 const float proposedvolume = RiseMath::Min(thrust / 513000.0f, 1.0f) * distanceGain;
2931
2932 if (proposedvolume > newvolume1)
2933 {
2934 newvolume1 = proposedvolume;
2935
2936 // this new distance in 1 second
2937 RiseMath::Vector3 tempvec = (theirSoundPosition + theirVelocity) - (ourPosition + ourVelocity);
2938 closing1 = soundDistance - RiseMath::Vec3Length(&tempvec);
2939 closing1 /= speedOfSoundKms;
2940 closing1++; // if 0 vel, it should be 1 times the speed, at 1X sound it should be double speed
2941
2942 float bear1;
2943 if (soundPositionDifference.z != 0.0f)
2944 {
2945 bear1 = RiseMath::ToDegree(atanf(soundPositionDifference.x / soundPositionDifference.z));
2946 const float mark1 = RiseMath::ToDegree(atanf(soundPositionDifference.y / soundPositionDifference.z));
2947
2948 float f_temp = sqrtf(mark1 * mark1 + bear1 * bear1);
2949 if (f_temp > 180.0f)
2950 {
2951 f_temp = 180.0f / f_temp;
2952 bear1 *= f_temp;
2953 }
2954 if (soundPositionDifference.z > 0.0f) // Behind us
2955 {
2956 if (bear1 > 0.0f)
2957 bear1 -= 180.0f;
2958 else
2959 bear1 += 180.0f;
2960 }
2961 }
2962 else // directly above or below
2963 {
2964 bear1 = 0.0f;
2965 }
2966
2967 game->bus->DebugSoundReal = realDistance;
2968 game->bus->DebugSoundFake = soundDistance;
2969 game->bus->DebugSoundBear = bear1;
2970 game->bus->DebugSoundClose = closing1;
2971
2972 pan = bear1 / 90.0f; // -90 is -1, -180 is -2
2973 if (IsInvalidFloat(pan))
2974 {
2975 Trace("We are getting a non-finite pan from FrameMoveDopplerEffects", Logger::Level::Warn);
2976 pan = 0.0f;
2977 }
2978 }
2979 }
2980
2981 if (soundDistance < rocketRippingMaxAudibleDistanceKm && rippingThrustLevel > 0.0f)
2982 {
2983 // The reference recording was a 7.607 MN rocket heard from 4.4 km.
2984 // Preserve that calibration while using the same 1/r propagation as
2985 // the wash. A fourth-power thrust response makes ripping fall away
2986 // rapidly below full thrust, approximating the steep rise of jet noise.
2987 const float fullThrustSourceGain =
2988 (RocketRippingRecordingDistanceKm / OutdoorEngineReferenceDistanceKm) *
2989 (fullRippingThrust / (RocketRippingRecordingThrustNewtons - RocketRippingThresholdNewtons));
2990 const float thrustGain = powf(rippingThrustLevel, RocketRippingThrustExponent);
2991 const float distanceGain = GetOutdoorEngineDistanceGain(soundDistance);
2992 const float proposedvolume = Clamp(fullThrustSourceGain * thrustGain * distanceGain, 0.0f, 1.0f);
2993
2994 if (proposedvolume > newvolume2)
2995 {
2996 newvolume2 = proposedvolume;
2997
2998 // this new distance in 1 second
2999 RiseMath::Vector3 tempvec = (theirSoundPosition + theirVelocity) - (ourPosition + ourVelocity);
3000 closing2 = soundDistance - RiseMath::Vec3Length(&tempvec);
3001 closing2 /= speedOfSoundKms;
3002 closing2++; // if 0 vel, it should be 1 times the speed, at 1X sound it should be double speed
3003
3004 float bear1;
3005 if (soundPositionDifference.z != 0.0f)
3006 {
3007 bear1 = RiseMath::ToDegree(atanf(soundPositionDifference.x / soundPositionDifference.z));
3008 float mark1 = RiseMath::ToDegree(atanf(soundPositionDifference.y / soundPositionDifference.z));
3009 float f_temp = sqrtf(mark1 * mark1 + bear1 * bear1);
3010 if (f_temp > 180.0f)
3011 {
3012 f_temp = 180.0f / f_temp;
3013 bear1 *= f_temp;
3014 }
3015 if (soundPositionDifference.z > 0.0f) // Behind us
3016 {
3017 if (bear1 > 0.0f)
3018 bear1 -= 180.0f;
3019 else
3020 bear1 += 180.0f;
3021 }
3022 }
3023 else // directly above or below
3024 {
3025 bear1 = 0.0f;
3026 }
3027 pan2 = bear1 / 90.0f; // -90 is -1, -180 is -2
3028 if (IsInvalidFloat(pan2))
3029 {
3030 Trace("We are getting a non-finite pan2 from FrameMoveDopplerEffects", Logger::Level::Warn);
3031 pan2 = 0.0f;
3032 }
3033 }
3034 }
3035
3036 }
3037 }
3038 }
3039
3040 if (newvolume1 > 0 || oldvolume > 0)
3041 {
3042 newvolume1 = RiseMath::Min(newvolume1, 1); // max of 1
3043 float f_temp = (newvolume1 - oldvolume) * elapsedTime;
3044 float volume = Clamp(oldvolume + f_temp, 0, 1);
3045 if (IsInvalidFloat(volume))
3046 {
3047 Trace("FrameMoveDopplerEffects reset non-finite doppler1 volume", Logger::Level::Warn);
3048 volume = 0.0f;
3049 }
3050
3051 f_temp = (closing1 - oldFrequencyMod) * elapsedTime;
3052 float frequency_mod = oldFrequencyMod + f_temp;
3053 if (IsInvalidFloat(frequency_mod))
3054 {
3055 Trace("FrameMoveDopplerEffects reset non-finite doppler1 frequency", Logger::Level::Warn);
3056 frequency_mod = 1.0f;
3057 }
3058
3059 f_temp = (pan - oldPan) * elapsedTime;
3060 float finalPan = oldPan + f_temp;
3061 if (IsInvalidFloat(finalPan))
3062 {
3063 Trace("FrameMoveDopplerEffects reset non-finite doppler1 finalPan", Logger::Level::Warn);
3064 finalPan = 0.0f;
3065 }
3066
3067 PlayEx(SOUND_DOPPLER, true, volume, frequency_mod, finalPan + headPanScalar, false, true);
3068
3069 oldvolume = volume;
3070 oldFrequencyMod = frequency_mod;
3071 oldPan = finalPan;
3072 }
3073 else
3074 {
3076 oldvolume = 0;
3077 oldFrequencyMod = 1;
3078 oldPan = 0;
3079 }
3080
3081 if (newvolume2 > 0 || oldvolume2 > 0)
3082 {
3083 newvolume2 = RiseMath::Min(newvolume2, 1); // max of 1
3084 float f_temp = (newvolume2 - oldvolume2) * elapsedTime;
3085 float volume = Clamp(oldvolume2 + f_temp, 0, 1);
3086 if (IsInvalidFloat(volume))
3087 {
3088 Trace("FrameMoveDopplerEffects reset non-finite doppler2 volume", Logger::Level::Warn);
3089 volume = 0.0f;
3090 }
3091
3092 f_temp = (closing2 - oldFrequencyMod2) * elapsedTime;
3093 float frequency_mod = oldFrequencyMod2 + f_temp;
3094 if (IsInvalidFloat(frequency_mod))
3095 {
3096 Trace("FrameMoveDopplerEffects reset non-finite doppler2 frequency", Logger::Level::Warn);
3097 frequency_mod = 1.0f;
3098 }
3099
3100 f_temp = (pan2 - oldPan2) * elapsedTime;
3101 float finalPan = oldPan2 + f_temp;
3102
3103 if (IsInvalidFloat(finalPan))
3104 {
3105 Trace("FrameMoveDopplerEffects reset non-finite doppler2 finalPan", Logger::Level::Warn);
3106 finalPan = 0.0f;
3107 }
3108
3109 PlayEx(SOUND_DOPPLER2, true, volume, frequency_mod, finalPan + headPanScalar, false, true);
3110
3111 oldvolume2 = volume;
3112 oldFrequencyMod2 = frequency_mod;
3113 oldPan2 = finalPan;
3114 }
3115 else
3116 {
3118 oldvolume2 = 0;
3119 oldFrequencyMod2 = 1;
3120 oldPan2 = 0;
3121 }
3122
3123 game->logger->AddToCallStack("Sound::FrameMoveDopplerEffects DONE");
3124}
3125
3127{
3128 game->logger->AddToCallStack("Sound::PrecipWindSoundBarrier");
3129 static bool invalidRelativeWindReported = false;
3130 if (IsInvalidFloat(relativeWindTrueKms.x) || IsInvalidFloat(relativeWindTrueKms.y) || IsInvalidFloat(relativeWindTrueKms.z))
3131 {
3132 if (!invalidRelativeWindReported)
3133 {
3134 invalidRelativeWindReported = true;
3135 char msg[160];
3136 sprintf_s(msg, sizeof msg, "PrecipWindSoundBarrier rejected relative wind %.3f %.3f %.3f",
3137 relativeWindTrueKms.x, relativeWindTrueKms.y, relativeWindTrueKms.z);
3139 }
3140 relativeWindTrueKms = RiseMath::Vector3(0.0f, 0.0f, 0.0f);
3141 }
3142 else
3143 invalidRelativeWindReported = false;
3144
3145 // WIND NOISE
3146 float velocity;
3147 float densityScalar = game->viewscreen->ptrPropulsion->dynamicDensityScalar;
3148 static bool invalidDensityReported = false;
3149 if (IsInvalidFloat(densityScalar) || densityScalar < 0.0f)
3150 {
3151 if (!invalidDensityReported)
3152 {
3153 invalidDensityReported = true;
3154 char msg[128];
3155 sprintf_s(msg, sizeof msg, "PrecipWindSoundBarrier rejected density scalar %.3f", densityScalar);
3157 }
3158 densityScalar = 0.0f;
3159 }
3160 else
3161 invalidDensityReported = false;
3162
3163 // Compute indicated velocity more efficiently
3164 if (playerships[0].reference <= REF_BUILDING)
3165 {
3166 RiseMath::Vector3 vel = relativeWindTrueKms * sqrtf(densityScalar);
3167 velocity = RiseMath::Vec3Length(&vel); // proportional to IAS magnitude
3168 }
3169 else
3170 velocity = 0.0f;
3171
3172 // Normalize to reference IAS = 135 m/s
3173 float percentVelocity = RiseMath::Min(velocity / 0.135f, 1.0f);
3174
3175 // Psychoacoustic loudness (approximately cubic)
3176 float volume = powf(percentVelocity, 3.0f);
3177
3178 // Frequency rise for wind “pitch”
3179 float freq = 0.5f + percentVelocity * 0.8f; // tweak as desired
3180
3181 static bool invalidParentSlotReported = false;
3182 static bool invalidBayDoorExtentReported = false;
3183 if (playerships[0].reference == REF_INANOTHER)
3184 {
3185 const unsigned int parentSlot = playerships[0].inarray;
3186 if (parentSlot == 0 || parentSlot >= MAX_SCAN)
3187 {
3188 if (!invalidParentSlotReported)
3189 {
3190 invalidParentSlotReported = true;
3191 char msg[128];
3192 sprintf_s(msg, sizeof msg, "PrecipWindSoundBarrier rejected parent slot %u", parentSlot);
3194 }
3195 volume = 0.0f;
3196 }
3197 else
3198 {
3199 invalidParentSlotReported = false;
3200 float bayDoorExtent = playerships[parentSlot].baydoorextent;
3201 if (IsInvalidFloat(bayDoorExtent) || bayDoorExtent < 0.0f)
3202 {
3203 if (!invalidBayDoorExtentReported)
3204 {
3205 invalidBayDoorExtentReported = true;
3206 char msg[128];
3207 sprintf_s(msg, sizeof msg, "PrecipWindSoundBarrier rejected bay door extent %.3f for slot %u", bayDoorExtent, parentSlot);
3209 }
3210 bayDoorExtent = 0.0f;
3211 }
3212 else
3213 {
3214 invalidBayDoorExtentReported = false;
3215 bayDoorExtent = RiseMath::Min(bayDoorExtent, 1.0f);
3216 }
3217 volume *= sqrtf(bayDoorExtent);
3218 }
3219 }
3220 else
3221 {
3222 invalidParentSlotReported = false;
3223 invalidBayDoorExtentReported = false;
3224 }
3225
3226 // PAN we don't have to apply panFactor or pinna shadow effect here because that is handled in PlayEx!
3227 // @todo so when I was outside the car barely any wind was making the sound come from behind us ... should be above a certain threshold?
3228 // @todo that didn't do what I wanted either ... it has to be like the direction the car is from the camera?
3229 float pan = atan2f(relativeWindTrueKms.x, -relativeWindTrueKms.z) / RiseMath::HalfPi;
3230 pan += headPanScalar;
3231
3232 game->logger->AddToCallStack("Sound::PrecipWindSoundBarrier WIND");
3233 if (volume > MIN_VOL)
3234 {
3236 {
3237 PlayEx(SOUND_WIND_MIC, true, RiseMath::Min(1, volume * 3), freq, pan, false, true, true); // part of hull because we apply static density above
3239 }
3240 else
3241 {
3242 PlayEx(SOUND_WIND, true, volume, freq, pan, false, true, true); // part of hull because we apply static density above
3244 }
3245 PlayEx(SOUND_GEARWIND, true, volume * ourcockpit.gearextent, freq, headPanScalar, false, true, true); // part of hull because we apply static density above
3246 PlayEx(SOUND_FLAPWIND, true, volume * ourcockpit.flapExtent, freq, headPanScalar, false, true, true); // part of hull because we apply static density above
3247 PlayEx(SOUND_SPOILERWIND, true, volume * playerships[0].spoilersUp, freq, headPanScalar, false, true, true); // part of hull because we apply static density above
3248 }
3249 else
3250 {
3256 }
3257
3258
3259
3260#pragma region SOUND BARRIER and SONIC BOOM
3261 game->logger->AddToCallStack("Sound::PrecipWindSoundBarrier BARRIER");
3262
3263 if (oldBusMach != 0.0f)
3264 {
3265 if ((oldBusMach < 1.0f && game->bus->Mach >= 1.0f) ||
3266 (game->bus->Mach < 1.0f && oldBusMach >= 1.0f))
3267 {
3268 Command command;
3269 command.name = "AuralSoundBarrier";
3270 game->bus->commandStream.emplace_back(command);
3271 }
3272 }
3273 oldBusMach = game->bus->Mach;
3274
3275 // based on the REAL number
3277 if (game->viewscreen->ptrPropulsion->mach >= 1.0f)
3278 {
3280 {
3282 if (ourcockpit.sonicBooms > 0)
3283 {
3284 // send to everyone else
3285 SClientPacket outpacket;
3286 outpacket.type = 23; // Universe sound
3287 outpacket.f_x = 1.0f; // Sonic boom
3288 outpacket.f_y = static_cast<float>(ourcockpit.sonicBooms); // number of booms
3289 outpacket.f_z = 0.0f; // NULL
3290 outpacket.f_w = 0.0f; // NULL
3291 game->networking->SendToServer(&outpacket, sizeof(SClientPacket), true);
3292 }
3293 }
3294 }
3295 else if (passedSoundBarrierBoom)
3296 {
3297 passedSoundBarrierBoom = false;
3298 }
3299
3300#pragma endregion
3301
3302
3303#pragma region Precipitation
3304 game->logger->AddToCallStack("Sound::PrecipWindSoundBarrier PRECIP");
3305
3306 // Match visible precipitation: silent through 3, full intensity at 16.
3307 const float precipitation = game->viewscreen->ptrWeather->GetPrecip();
3308 float normPrecip = precipitation <= 3.0f ? 0.0f : (precipitation - 3.0f) / 13.0f;
3309 static bool invalidPrecipReported = false;
3310 if (IsInvalidFloat(normPrecip) || normPrecip < 0.0f || normPrecip > 1.0f)
3311 {
3312 if (!invalidPrecipReported)
3313 {
3314 invalidPrecipReported = true;
3315 char msg[128];
3316 sprintf_s(msg, sizeof msg, "PrecipWindSoundBarrier clamped normalized precipitation %.3f", normPrecip);
3318 }
3319 if (IsInvalidFloat(normPrecip))
3320 normPrecip = 0.0f;
3321 else
3322 normPrecip = RiseMath::Min(RiseMath::Max(normPrecip, 0.0f), 1.0f);
3323 }
3324 else
3325 invalidPrecipReported = false;
3326 float apparentPrecip = normPrecip + percentVelocity * (1.0f - normPrecip); // nonlinear blend
3327 apparentPrecip = RiseMath::Min(apparentPrecip, 1.0f); // clamp
3328
3329 const float base = sqrtf(normPrecip); // already normalized from 0–1
3330 float motionEffect = percentVelocity * base;
3331 volume = 0.6f * base + 0.4f * motionEffect;
3332
3333 // 5 samples = 4 thresholds (or "bands" between them)
3334 float thresholds[5] = { 0.0f, 0.25f, 0.45f, 0.65f, 0.85f }; // Entry points for samples 0 to 4
3335
3336 int lowIndex = -1, highIndex = -1;
3337 float blend = 0.0f;
3338
3339 for (int i = 0; i < 4; ++i) {
3340 if (apparentPrecip >= thresholds[i] && apparentPrecip < thresholds[i + 1]) {
3341 lowIndex = i;
3342 highIndex = i + 1;
3343
3344 float range = thresholds[i + 1] - thresholds[i];
3345 blend = (apparentPrecip - thresholds[i]) / range;
3346 break;
3347 }
3348 }
3349
3350 if (apparentPrecip >= thresholds[4]) {
3351 lowIndex = 4;
3352 highIndex = -1;
3353 blend = 0.0f;
3354 }
3355
3356 for (int i = 0; i < 5; ++i) {
3357 float sampleVolume = 0.0f;
3358
3359 if (i == lowIndex)
3360 sampleVolume = volume * (1.0f - blend);
3361 else if (i == highIndex)
3362 sampleVolume = volume * blend;
3363
3364 // Will update volume if already playing, or start if needed
3365 if (sampleVolume)
3366 PlayEx(static_cast<SOUNDS>(SOUND_PRECIP0 + i), true, sampleVolume, freq, pan, false, true);
3367 else
3368 Stop(static_cast<SOUNDS>(SOUND_PRECIP0 + i));
3369 }
3370
3371#pragma endregion
3372
3373 game->logger->AddToCallStack("Sound::PrecipWindSoundBarrier DONE");
3374}
3375
3376void Sound::AddDelayedSound(SOUNDS soundEnum, float delay, float volume, float freq, bool fromOutside)
3377{
3378 char msg[99];
3379 sprintf_s(msg, sizeof msg, "AddDelayedSound adding sound %i with delay: %.3f", soundEnum, delay);
3380 Trace(msg);
3381
3382 if (delay < 0.017f) // one frame
3383 {
3384 PlayEx(soundEnum, false, volume);
3385 return;
3386 }
3387
3388 Sdelayedeffects delayedEffect;
3389 delayedEffect.delay = delay;
3390 delayedEffect.soundEnum = soundEnum;
3391 delayedEffect.volume = volume;
3392 delayedEffect.freq = freq;
3393 delayedEffect.fromOutside = fromOutside;
3394 delayedeffects.emplace_back(delayedEffect);
3395}
3396
3397void Sound::Stop(SOUNDS soundEnum) const
3398{
3399 if (sound_stream[soundEnum])
3400 BASS_ChannelStop(sound_stream[soundEnum]);
3401 if (sound_streamFx[soundEnum])
3402 BASS_ChannelStop(sound_streamFx[soundEnum]);
3403}
3404
3405void Sound::AddLoopingVehicleSound(SOUNDS soundEnum, unsigned char array)
3406{
3407 char msg[99];
3408 sprintf_s(msg, sizeof msg, "AddLoopingVehicleSound sound %i array %i vehicle %i", soundEnum, array, playerships[array].vehicleId);
3409 Trace(msg);
3410
3411 for (size_t i = 0; i < loopingeffects.size(); i++)
3412 {
3413 if (loopingeffects.at(i).array == array && loopingeffects.at(i).soundEnum == soundEnum)
3414 {
3415 Trace("-> Already had a looping effect for that vehicle and that sound effect!");
3416 return;
3417 }
3418 }
3419
3420 Sloopingeffects loopingEffect;
3421 loopingEffect.soundEnum = soundEnum;
3422 loopingEffect.array = array;
3423 loopingEffect.vehicleId = playerships[array].vehicleId;
3424 loopingeffects.emplace_back(loopingEffect);
3425 std::sort(loopingeffects.begin(), loopingeffects.end());
3426}
3427
3428void Sound::RemoveLoopingVehicleSound(unsigned char array, SOUNDS soundEnum)
3429{
3430 char msg[99];
3431
3432 for (size_t t = 0; t < loopingeffects.size(); t++)
3433 {
3434 if (loopingeffects.at(t).array == array && (soundEnum == SOUND_NONE || loopingeffects.at(t).soundEnum == soundEnum))
3435 {
3436 sprintf_s(msg, sizeof msg, "RemoveLoopingVehicleSound sound %i array %i vehicle %i", soundEnum, array, playerships[array].vehicleId);
3437 Trace(msg);
3438 sprintf_s(msg, sizeof msg, "-> Found looping effect, calling Stop and erase");
3439 Trace(msg);
3440
3441 Stop(loopingeffects.at(t).soundEnum);
3442 loopingeffects.erase(loopingeffects.begin() + t);
3443 return;
3444 }
3445 }
3446
3447 if (soundEnum != SOUND_NONE)
3448 {
3449 sprintf_s(msg, sizeof msg, "RemoveLoopingVehicleSound sound %i array %i vehicle %i", soundEnum, array, playerships[array].vehicleId);
3450 Trace(msg);
3451 sprintf_s(msg, sizeof msg, "-> Could not find looping effect!");
3452 Trace(msg, Logger::Warn);
3453 }
3454}
3455
3457{
3458 if (!game->bus->RevenuePassengers || sound_enum < SOUND_BOARDING || sound_enum > SOUND_DISTURBANCE)
3459 return;
3460
3461 cabinPassengersActive = true;
3462
3463 if (sound_enum == SOUND_LANDED)
3464 {
3468 return;
3469
3470 cabinLandingPending = true;
3472 return;
3473 }
3474
3475 QueueCabinAnnouncement(sound_enum);
3476}
3477
3479{
3480 if (!game->bus->RevenuePassengers)
3481 {
3484 return;
3485 }
3486
3487 cabinPassengersActive = true;
3488 const bool onGround = playerships[0].reference == REF_ONGROUND;
3489
3490 if (!onGround)
3491 {
3492 if (elapsedTime > 0.0f)
3493 cabinAirborneTime += elapsedTime;
3494
3495 // A transient takeoff bounce is not a completed flight. Either 400 feet AGL or
3496 // 30 continuous airborne seconds establishes a flight, including low circuits.
3497 if (game->bus->RadioAltitudeKm >= 0.12192f || cabinAirborneTime >= 30.0f)
3499
3500 cabinLandingPending = false;
3503 }
3504 else if (cabinLandingPending)
3505 {
3506 bool thrustIdle = true;
3507 for (int i = 0; i < ourcockpit.engines; i++)
3508 thrustIdle &= game->bus->EngineThrustLever[i] <= 0.1f;
3509
3510 if (thrustIdle && elapsedTime > 0.0f)
3511 cabinLandingConfirmationTime += elapsedTime;
3512 else
3514
3515 if (cabinLandingConfirmationTime >= 5.0f)
3516 {
3517 cabinLandingPending = false;
3520 }
3521 }
3522 else if (!cabinFlightEstablished)
3523 {
3524 cabinAirborneTime = 0.0f;
3525 }
3526
3528 {
3529 const SOUNDS soundEnum = cabinAnnouncementQueue.front();
3531
3532 if (soundEnum == SOUND_LANDED && !onGround)
3533 continue;
3534
3535 PlayEx(soundEnum, false, 0.2f, 1, 0, true);
3536 if (soundEnum == SOUND_LANDED)
3537 {
3538 cabinFlightEstablished = false;
3539 cabinAirborneTime = 0.0f;
3540 }
3541 break;
3542 }
3543}
3544
3546{
3547 if (soundEnum != SOUND_NONE)
3548 return BASS_ChannelIsActive(sound_stream[soundEnum]) == BASS_ACTIVE_PLAYING;
3549
3550 for (int i = SOUND_BOARDING; i <= SOUND_DISTURBANCE; i++)
3551 {
3552 if (BASS_ChannelIsActive(sound_stream[i]) == BASS_ACTIVE_PLAYING)
3553 return true;
3554 }
3555
3556 return false;
3557}
3558
3560{
3561 if (IsCabinAnnouncementPlaying(soundEnum) ||
3562 std::find(cabinAnnouncementQueue.begin(), cabinAnnouncementQueue.end(), soundEnum) != cabinAnnouncementQueue.end())
3563 return;
3564
3565 cabinAnnouncementQueue.emplace_back(soundEnum);
3566}
3567
3569{
3571 std::remove(cabinAnnouncementQueue.begin(), cabinAnnouncementQueue.end(), soundEnum),
3573}
3574
3575void Sound::LoadDockSounds(short dockTexture)
3576{
3577 for (int i = SOUND_DOCKANNOUNCE1; i <= SOUND_DOCKCHIME; i++)
3578 {
3580 sound_stream[i] = NULL;
3581 }
3582
3583 if (dockTexture == 2) // TAC
3584 {
3585 sound_path[SOUND_DOCKANNOUNCE1] = "Sounds\\Docks\\TURGRND0.wav";
3586 sound_path[SOUND_DOCKANNOUNCE2] = "Sounds\\Docks\\TURGRND1.wav";
3587 sound_path[SOUND_DOCKANNOUNCE3] = "Sounds\\Docks\\TURGRND2.wav";
3588 sound_path[SOUND_DOCKANNOUNCE4] = "Sounds\\Docks\\TURGRND3.wav";
3589 sound_path[SOUND_DOCKANNOUNCE5] = "Sounds\\Docks\\TURGRND4.wav";
3590 sound_path[SOUND_DOCKANNOUNCE6] = "Sounds\\Docks\\TURGRND5.wav";
3591 sound_path[SOUND_DOCKANNOUNCE7] = "Sounds\\Docks\\TURGRND6.wav";
3592 sound_path[SOUND_DOCKANNOUNCE8] = "Sounds\\Docks\\TURGRND7.wav";
3593 sound_path[SOUND_DOCKANNOUNCE9] = "Sounds\\Docks\\TURGRND8.wav";
3594 sound_path[SOUND_DOCKANNOUNCE10] = "Sounds\\Docks\\TURGRND9.wav";
3595 sound_path[SOUND_DOCKANNOUNCE11] = "Sounds\\Docks\\TURGRNDA.wav";
3596 sound_path[SOUND_DOCKANNOUNCE12] = "Sounds\\Docks\\TURGRNDB.wav";
3597 sound_path[SOUND_DOCKEVAC] = "Sounds\\Docks\\TURGEVAC.wav";
3598 sound_path[SOUND_DOCKCHIME] = "Sounds\\Docks\\CHIME_A.wav";
3599 }
3600 else if (dockTexture == 1) // CPOC
3601 {
3602 sound_path[SOUND_DOCKANNOUNCE1] = "Sounds\\Docks\\CPOC\\cpoc2.wav";
3603 sound_path[SOUND_DOCKANNOUNCE2] = "Sounds\\Docks\\CPOC\\cpoc3.wav";
3604 sound_path[SOUND_DOCKANNOUNCE3] = "Sounds\\Docks\\CPOC\\cpoc4.wav";
3605 sound_path[SOUND_DOCKANNOUNCE4] = "Sounds\\Docks\\CPOC\\cpoc5.wav";
3606 sound_path[SOUND_DOCKANNOUNCE5] = "Sounds\\Docks\\CPOC\\cpoc6.wav";
3607 sound_path[SOUND_DOCKANNOUNCE6] = "Sounds\\Docks\\CPOC\\cpoc7.wav";
3608 sound_path[SOUND_DOCKANNOUNCE7] = "Sounds\\Docks\\CPOC\\cpoc8.wav";
3609 sound_path[SOUND_DOCKANNOUNCE8] = "Sounds\\Docks\\CPOC\\cpoc9.wav";
3610 sound_path[SOUND_DOCKANNOUNCE9] = "Sounds\\Docks\\CPOC\\cpoc10.wav";
3611 sound_path[SOUND_DOCKANNOUNCE10] = "Sounds\\Docks\\CPOC\\cpoc14.wav";
3612 sound_path[SOUND_DOCKANNOUNCE11] = "Sounds\\Docks\\CPOC\\cpoc15.wav";
3613 sound_path[SOUND_DOCKANNOUNCE12] = "Sounds\\Docks\\CPOC\\cpoc16.wav";
3614 sound_path[SOUND_DOCKEVAC] = "Sounds\\Docks\\CPOC\\evac.wav";
3615 sound_path[SOUND_DOCKCHIME] = "Sounds\\Docks\\CPOC\\chime.wav";
3616 }
3617
3618 if (dockTexture)
3619 {
3620 for (int i = SOUND_DOCKANNOUNCE1; i <= SOUND_DOCKCHIME; i++)
3621 LoadSound(i, nullptr);
3622 }
3623}
3624
3626{
3627 BASS_ChannelStop(sound_stream[SOUND_BOARDING]);
3628 BASS_ChannelStop(sound_stream[SOUND_BEFORETAKEOFF]);
3629 BASS_ChannelStop(sound_stream[SOUND_CLIMBING10K]);
3630 BASS_ChannelStop(sound_stream[SOUND_CRUISE]);
3631 BASS_ChannelStop(sound_stream[SOUND_DESCENT]);
3632 BASS_ChannelStop(sound_stream[SOUND_DOCKING]);
3633 BASS_ChannelStop(sound_stream[SOUND_LANDED]);
3634 BASS_ChannelStop(sound_stream[SOUND_DEPLANING]);
3635 BASS_ChannelStop(sound_stream[SOUND_DISTURBANCE]);
3636
3637 cabinAnnouncementQueue.clear();
3638 cabinAirborneTime = 0.0f;
3640 cabinFlightEstablished = false;
3641 cabinLandingPending = false;
3642 cabinPassengersActive = false;
3643}
3644
3645void Sound::ChangeCockpit(bool force)
3646{
3647 game->logger->AddToCallStack("Sound::ChangeCockpit");
3649
3650 bleedAirGain = 0.f;
3653 LoadCockpitSound(SOUND_RAINAIRRUSH, nullptr, force);
3654 for (int i = SOUND_PROP1; i <= SOUND_PROP6; ++i) Stop(static_cast<SOUNDS>(i));
3655 Stop(SOUND_THRUST); // going from A-4 back to apartment while hitting F9
3656
3657 switch (ourcockpit.texturelib)
3658 {
3659 case VehicleType::E10:
3660 LoadCockpitSound(SOUND_COCKPITAMBIENT, "Sounds\\Cockpits\\320-idle.wav", force);
3661 LoadCockpitSound(SOUND_COCKPITENGINELEFT, "Sounds\\Cockpits\\AlienFreighter.wav", force);
3662 LoadCockpitSound(SOUND_COCKPITENGINERIGHT, "Sounds\\Cockpits\\AlienFreighter.wav", force);
3663 LoadCockpitSound(SOUND_COCKPITENGINECENTER, "Sounds\\Cockpits\\AlienFreighter.wav", force);
3664 LoadCockpitSound(SOUND_COCKPITSTART, "Sounds\\Cockpits\\startup40.wav", force);
3665 LoadCockpitSound(SOUND_COCKPITLAND, "Sounds\\Cockpits\\touchlb.wav", force);
3666 LoadCockpitSound(SOUND_COCKPITLEVEL, "Sounds\\Cockpits\\touchld.wav", force);
3668 LoadCockpitSound(SOUND_PROP1, nullptr, force);
3669 LoadCockpitSound(SOUND_PROP2, nullptr, force);
3670 LoadCockpitSound(SOUND_PROP3, nullptr, force);
3671 LoadCockpitSound(SOUND_PROP4, nullptr, force);
3672 LoadCockpitSound(SOUND_PROP5, nullptr, force);
3673 LoadCockpitSound(SOUND_PROP6, nullptr, force);
3674
3676 LoadCockpitSound(SOUND_STALL, "Sounds\\VMU\\E-10\\stall.wav", force, &game->config.soundConfigComputer);
3677 LoadCockpitSound(SOUND_OVERSPEED, "Sounds\\VMU\\overspeed.mp3", force, &game->config.soundConfigComputer);
3678
3679 LoadCockpitSound(SOUND_GPWSSINKRATE, "Sounds\\VMU\\E-10\\GPWS\\monroe-sr.wav", force, &game->config.soundConfigComputer);
3680 LoadCockpitSound(SOUND_GPWSPULLUP, "Sounds\\VMU\\E-10\\GPWS\\monroe-pu.wav", force, &game->config.soundConfigComputer);
3681 LoadCockpitSound(SOUND_TA_PULLUP, "Sounds\\VMU\\E-10\\GPWS\\PullUp.wav", force, &game->config.soundConfigComputer);
3682 LoadCockpitSound(SOUND_GPWSTERRAINTERRAIN, "Sounds\\VMU\\E-10\\GPWS\\monroe-tt.wav", force, &game->config.soundConfigComputer);
3683 LoadCockpitSound(SOUND_GPWSTERRAIN, "Sounds\\VMU\\E-10\\GPWS\\Terrain.wav", force, &game->config.soundConfigComputer);
3684 LoadCockpitSound(SOUND_GPWSTOOLOWTERRAIN, "Sounds\\VMU\\E-10\\GPWS\\TooLowTerrain.wav", force, &game->config.soundConfigComputer);
3685 LoadCockpitSound(SOUND_GPWSTOOLOWGEAR, "Sounds\\VMU\\E-10\\GPWS\\monroe-struts.wav", force, &game->config.soundConfigComputer);
3687 LoadCockpitSound(SOUND_GPWSBANKANGLE, "Sounds\\VMU\\E-10\\GPWS\\BankAngle.wav", force, &game->config.soundConfigComputer);
3688 LoadCockpitSound(SOUND_GPWSGLIDESLOPE, "Sounds\\VMU\\E-10\\GPWS\\Glideslope.wav", force, &game->config.soundConfigComputer);
3689 LoadCockpitSound(SOUND_GPWSRETARD, "Sounds\\VMU\\E-10\\GPWS\\Retard.wav", force, &game->config.soundConfigComputer);
3690 LoadCockpitSound(SOUND_GPWSTEN, "Sounds\\VMU\\E-10\\GPWS\\10.wav", force, &game->config.soundConfigComputer);
3691 LoadCockpitSound(SOUND_GPWSTWENTY, "Sounds\\VMU\\E-10\\GPWS\\20.wav", force, &game->config.soundConfigComputer);
3692 LoadCockpitSound(SOUND_GPWSTHIRTY, "Sounds\\VMU\\E-10\\GPWS\\30.wav", force, &game->config.soundConfigComputer);
3693 LoadCockpitSound(SOUND_GPWSFORTY, "Sounds\\VMU\\E-10\\GPWS\\40.wav", force, &game->config.soundConfigComputer);
3694 LoadCockpitSound(SOUND_GPWSFIFTY, "Sounds\\VMU\\E-10\\GPWS\\50.wav", force, &game->config.soundConfigComputer);
3695 LoadCockpitSound(SOUND_GPWSONEHUNDRED, "Sounds\\VMU\\E-10\\GPWS\\100.wav", force, &game->config.soundConfigComputer);
3696 LoadCockpitSound(SOUND_GPWSTWOHUNDRED, "Sounds\\VMU\\E-10\\GPWS\\200.wav", force, &game->config.soundConfigComputer);
3697 LoadCockpitSound(SOUND_GPWSMINIMUMS, "Sounds\\VMU\\E-10\\GPWS\\Minimums.wav", force, &game->config.soundConfigComputer);
3698 LoadCockpitSound(SOUND_GPWSFIVEHUNDRED, "Sounds\\VMU\\E-10\\GPWS\\500.wav", force, &game->config.soundConfigComputer);
3699 LoadCockpitSound(SOUND_GPWSONETHOUSAND, "Sounds\\VMU\\E-10\\GPWS\\1000.wav", force, &game->config.soundConfigComputer);
3700 LoadCockpitSound(SOUND_GPWSDONTSINK, "Sounds\\VMU\\E-10\\GPWS\\DontSink.wav", force, &game->config.soundConfigComputer);
3701 LoadCockpitSound(SOUND_GPWSPOSITIVERATE, "Sounds\\VMU\\E-10\\GPWS\\PositiveRate.wav", force, &game->config.soundConfigComputer);
3702 LoadCockpitSound(SOUND_GPWSWINDSHEARWARNING, "Sounds\\VMU\\E-10\\GPWS\\WindshearWarning.wav", force, &game->config.soundConfigComputer);
3703 LoadCockpitSound(SOUND_GPWSWINDSHEARCAUTION, "Sounds\\VMU\\E-10\\GPWS\\WindshearCaution.wav", force, &game->config.soundConfigComputer);
3705 LoadCockpitSound(SOUND_TA_CAUTION_TERRAIN, "Sounds\\VMU\\E-10\\GPWS\\CautionTerrain.wav", force, &game->config.soundConfigComputer);
3706 LoadCockpitSound(SOUND_TA_CAUTION_OBSTACLE, "Sounds\\VMU\\E-10\\GPWS\\CautionObstacle.wav", force, &game->config.soundConfigComputer);
3707 LoadCockpitSound(SOUND_TA_OBSTACLE_WARNING, "Sounds\\VMU\\E-10\\GPWS\\ObstacleObstacle.wav", force, &game->config.soundConfigComputer);
3708
3709 LoadCockpitSound(SOUND_TCASTRAFFIC, "Sounds\\VMU\\E-10\\TCAS\\traffic.wav", force, &game->config.soundConfigComputer);
3710 LoadCockpitSound(SOUND_TCASCLIMB, "Sounds\\VMU\\E-10\\TCAS\\climb.wav", force, &game->config.soundConfigComputer);
3711 LoadCockpitSound(SOUND_TCASDESCEND, "Sounds\\VMU\\E-10\\TCAS\\descend.wav", force, &game->config.soundConfigComputer);
3712 LoadCockpitSound(SOUND_TCASINCREASECLIMB, "Sounds\\VMU\\E-10\\TCAS\\IncreaseClimb.wav", force, & game->config.soundConfigComputer);
3713 LoadCockpitSound(SOUND_TCASINCREASEDESCENT,"Sounds\\VMU\\E-10\\TCAS\\IncreaseDescent.wav", force, & game->config.soundConfigComputer);
3714 LoadCockpitSound(SOUND_TCASREDUCECLIMB, "Sounds\\VMU\\E-10\\TCAS\\ReduceClimb.wav", force, & game->config.soundConfigComputer);
3715 LoadCockpitSound(SOUND_TCASREDUCEDESCENT, "Sounds\\VMU\\E-10\\TCAS\\ReduceDescent.wav", force, & game->config.soundConfigComputer);
3716 LoadCockpitSound(SOUND_TCASCLIMBNOW, "Sounds\\VMU\\E-10\\TCAS\\ClimbClimbNow.wav", force, & game->config.soundConfigComputer);
3717 LoadCockpitSound(SOUND_TCASDESCENDNOW, "Sounds\\VMU\\E-10\\TCAS\\DescendDescendNow.wav", force, & game->config.soundConfigComputer);
3718 LoadCockpitSound(SOUND_TCASMAINTAIN, "Sounds\\VMU\\E-10\\TCAS\\MaintainVerticalSpeedMaintain.wav", force, & game->config.soundConfigComputer);
3719 LoadCockpitSound(SOUND_TCASADJUST, "Sounds\\VMU\\E-10\\TCAS\\AdjustVerticalSpeedAdjust.wav", force, & game->config.soundConfigComputer);
3720 LoadCockpitSound(SOUND_TCASMONITOR, "Sounds\\VMU\\E-10\\TCAS\\monitorverticalspeed.wav", force, &game->config.soundConfigComputer);
3721 LoadCockpitSound(SOUND_TCASCROSSING, "Sounds\\VMU\\E-10\\TCAS\\Crossing.wav", force, & game->config.soundConfigComputer);
3722 LoadCockpitSound(SOUND_TCASCLEAR, "Sounds\\VMU\\E-10\\TCAS\\clearofconflict.wav", force, &game->config.soundConfigComputer);
3723 LoadCockpitSound(SOUND_TCASTESTOK, "Sounds\\VMU\\E-10\\TCAS\\TcasSystemTestOk.wav", force, & game->config.soundConfigComputer);
3724
3725 LoadCockpitSound(SOUND_MONROECARGOBAY, "Sounds\\VMU\\E-10\\monroe-tiaditcb.wav", force, &game->config.soundConfigComputer);
3726 LoadCockpitSound(SOUND_MONROEALLMOORINGSCLEARED, "Sounds\\VMU\\E-10\\monroe-amc.wav", force, &game->config.soundConfigComputer);
3727 LoadCockpitSound(SOUND_MONROEGEARDOWN, "Sounds\\VMU\\E-10\\monroe-strutse.wav", force, &game->config.soundConfigComputer);
3728 LoadCockpitSound(SOUND_MONROEHULLIONIZATION, "Sounds\\VMU\\E-10\\monroe-hid.wav", force, &game->config.soundConfigComputer);
3729 LoadCockpitSound(SOUND_MONROESOUNDBARRIER, "Sounds\\VMU\\E-10\\monroe-psb.wav", force, &game->config.soundConfigComputer);
3731 LoadCockpitSound(SOUND_CONFIGAF, "Sounds\\VMU\\E-10\\config-af.wav", force, &game->config.soundConfigComputer);
3732 LoadCockpitSound(SOUND_CONFIGLANDINGGEAR, ourcockpit.spaceCapable ? "Sounds\\VMU\\E-10\\config-landing-gear.wav" : nullptr, force, &game->config.soundConfigComputer);
3734 LoadCockpitSound(SOUND_CONFIGTRIM, "Sounds\\VMU\\E-10\\config-trim.wav", force, &game->config.soundConfigComputer);
3735 LoadCockpitSound(SOUND_CONFIGSPOILERS, "Sounds\\VMU\\E-10\\config-spoilers.wav", force, &game->config.soundConfigComputer);
3736 LoadCockpitSound(SOUND_AURALUNITOKAY, "Sounds\\VMU\\E-10\\AuralUnitOkay.wav", force, &game->config.soundConfigComputer);
3737 LoadCockpitSound(SOUND_AURALUNITTESTA, "Sounds\\VMU\\E-10\\AuralWarningTestA.wav", force, &game->config.soundConfigComputer);
3738 LoadCockpitSound(SOUND_AURALUNITTESTB, "Sounds\\VMU\\E-10\\AuralWarningTestB.wav", force, &game->config.soundConfigComputer);
3739 LoadCockpitSound(SOUND_SCANNERSYNC, "Sounds\\VMU\\E-10\\ScannerSync.wav", force, &game->config.soundConfigComputer);
3740 LoadCockpitSound(SOUND_FORWARDTHRUST, "Sounds\\VMU\\E-10\\ForwardThrust.wav", force, &game->config.soundConfigComputer);
3741 LoadCockpitSound(SOUND_REVERSETHRUST, "Sounds\\VMU\\E-10\\ReverseThrust.wav", force, &game->config.soundConfigComputer);
3742 LoadCockpitSound(SOUND_CABINPRESSURE, "Sounds\\VMU\\E-10\\CabinPressure.wav", force, &game->config.soundConfigComputer);
3743 LoadCockpitSound(SOUND_GEARDISAGREE, "Sounds\\VMU\\E-10\\GearDisagree.wav", force, &game->config.soundConfigComputer);
3744 LoadCockpitSound(SOUND_AIRSPEEDALIVE, "Sounds\\VMU\\E-10\\AirspeedAlive.wav", force, &game->config.soundConfigComputer);
3747 LoadCockpitSound(SOUND_INTRANSIT, "Sounds\\VMU\\E-10\\InTransit.wav", force, &game->config.soundConfigComputer);
3748 LoadCockpitSound(SOUND_LOCALIZERALIVE, "Sounds\\VMU\\E-10\\LocalizerAlive.wav", force, &game->config.soundConfigComputer);
3749 LoadCockpitSound(SOUND_LOCALIZERCAPTURED, "Sounds\\VMU\\E-10\\LocalizerCaptured.wav", force, &game->config.soundConfigComputer);
3750 LoadCockpitSound(SOUND_GLIDESLOPEALIVE, "Sounds\\VMU\\E-10\\GlideslopeAlive.wav", force, &game->config.soundConfigComputer);
3751 LoadCockpitSound(SOUND_GLIDESLOPECAPTURED, "Sounds\\VMU\\E-10\\GlideslopeCaptured.wav", force, &game->config.soundConfigComputer);
3752 break;
3753
3754 case VehicleType::E11:
3755 LoadCockpitSound(SOUND_COCKPITAMBIENT, "Sounds\\Cockpits\\320-idle.wav", force);
3756 LoadCockpitSound(SOUND_COCKPITENGINELEFT, "Sounds\\Cockpits\\AlienFreighter.wav", force);
3757 LoadCockpitSound(SOUND_COCKPITENGINERIGHT, "Sounds\\Cockpits\\AlienFreighter.wav", force);
3758 LoadCockpitSound(SOUND_COCKPITENGINECENTER, "Sounds\\Cockpits\\AlienFreighter.wav", force);
3759 LoadCockpitSound(SOUND_COCKPITSTART, "Sounds\\Cockpits\\startup40.wav", force);
3760 LoadCockpitSound(SOUND_COCKPITLAND, "Sounds\\Cockpits\\touchlb.wav", force);
3761 LoadCockpitSound(SOUND_COCKPITLEVEL, "Sounds\\Cockpits\\touchld.wav", force);
3762 LoadCockpitSound(SOUND_WINDSHIELDWIPERS, "Sounds\\Cockpits\\BleedAir-DuctGlass-Loop.wav", force);
3763 LoadCockpitSound(SOUND_RAINAIRRUSH, "Sounds\\Cockpits\\BleedAir-ExteriorRush-Loop.wav", force);
3764 LoadCockpitSound(SOUND_PROP1, nullptr, force);
3765 LoadCockpitSound(SOUND_PROP2, nullptr, force);
3766 LoadCockpitSound(SOUND_PROP3, nullptr, force);
3767 LoadCockpitSound(SOUND_PROP4, nullptr, force);
3768 LoadCockpitSound(SOUND_PROP5, nullptr, force);
3769 LoadCockpitSound(SOUND_PROP6, nullptr, force);
3770
3772 LoadCockpitSound(SOUND_STALL, "Sounds\\VMU\\stall.mp3", force, &game->config.soundConfigComputer);
3773 LoadCockpitSound(SOUND_OVERSPEED, "Sounds\\VMU\\overspeed.mp3", force, &game->config.soundConfigComputer);
3774
3775 LoadCockpitSound(SOUND_GPWSSINKRATE, "Sounds\\VMU\\GPWS\\monroe-sr.mp3", force, &game->config.soundConfigComputer);
3776 LoadCockpitSound(SOUND_GPWSPULLUP, "Sounds\\VMU\\GPWS\\monroe-pu.mp3", force, &game->config.soundConfigComputer);
3777 LoadCockpitSound(SOUND_TA_PULLUP, "Sounds\\VMU\\GPWS\\PullUp.mp3", force, &game->config.soundConfigComputer);
3778 LoadCockpitSound(SOUND_GPWSTERRAINTERRAIN, "Sounds\\VMU\\GPWS\\TerrainTerrain.mp3", force, &game->config.soundConfigComputer);
3779 LoadCockpitSound(SOUND_GPWSTERRAIN, "Sounds\\VMU\\GPWS\\Terrain.mp3", force, &game->config.soundConfigComputer);
3780 LoadCockpitSound(SOUND_GPWSTOOLOWTERRAIN, "Sounds\\VMU\\GPWS\\TooLowTerrain.mp3", force, &game->config.soundConfigComputer);
3781 LoadCockpitSound(SOUND_GPWSTOOLOWGEAR, "Sounds\\VMU\\GPWS\\TooLowStruts.mp3", force, &game->config.soundConfigComputer);
3783 LoadCockpitSound(SOUND_GPWSBANKANGLE, "Sounds\\VMU\\GPWS\\BankAngle.wav", force, &game->config.soundConfigComputer);
3784 LoadCockpitSound(SOUND_GPWSGLIDESLOPE, "Sounds\\VMU\\GPWS\\Glideslope.wav", force, &game->config.soundConfigComputer);
3785 LoadCockpitSound(SOUND_GPWSRETARD, "Sounds\\VMU\\GPWS\\Retard.wav", force, &game->config.soundConfigComputer);
3786 LoadCockpitSound(SOUND_GPWSTEN, "Sounds\\VMU\\GPWS\\10.wav", force, &game->config.soundConfigComputer);
3787 LoadCockpitSound(SOUND_GPWSTWENTY, "Sounds\\VMU\\GPWS\\20.wav", force, &game->config.soundConfigComputer);
3788 LoadCockpitSound(SOUND_GPWSTHIRTY, "Sounds\\VMU\\GPWS\\30.wav", force, &game->config.soundConfigComputer);
3789 LoadCockpitSound(SOUND_GPWSFORTY, "Sounds\\VMU\\GPWS\\40.wav", force, &game->config.soundConfigComputer);
3790 LoadCockpitSound(SOUND_GPWSFIFTY, "Sounds\\VMU\\GPWS\\50.wav", force, &game->config.soundConfigComputer);
3791 LoadCockpitSound(SOUND_GPWSONEHUNDRED, "Sounds\\VMU\\GPWS\\100.wav", force, &game->config.soundConfigComputer);
3792 LoadCockpitSound(SOUND_GPWSTWOHUNDRED, "Sounds\\VMU\\GPWS\\200.wav", force, &game->config.soundConfigComputer);
3793 LoadCockpitSound(SOUND_GPWSMINIMUMS, "Sounds\\VMU\\GPWS\\Minimums.wav", force, &game->config.soundConfigComputer);
3794 LoadCockpitSound(SOUND_GPWSFIVEHUNDRED, "Sounds\\VMU\\GPWS\\500.wav", force, &game->config.soundConfigComputer);
3795 LoadCockpitSound(SOUND_GPWSONETHOUSAND, "Sounds\\VMU\\GPWS\\1000.wav", force, &game->config.soundConfigComputer);
3796 LoadCockpitSound(SOUND_GPWSDONTSINK, "Sounds\\VMU\\GPWS\\DontSink.mp3", force, &game->config.soundConfigComputer);
3797 LoadCockpitSound(SOUND_GPWSPOSITIVERATE, "Sounds\\VMU\\GPWS\\PositiveRate.mp3", force, &game->config.soundConfigComputer);
3798 LoadCockpitSound(SOUND_GPWSWINDSHEARWARNING, "Sounds\\VMU\\GPWS\\WindshearWarning.wav", force, &game->config.soundConfigComputer);
3799 LoadCockpitSound(SOUND_GPWSWINDSHEARCAUTION, "Sounds\\VMU\\GPWS\\WindshearCaution.mp3", force, &game->config.soundConfigComputer);
3801 LoadCockpitSound(SOUND_TA_CAUTION_TERRAIN, "Sounds\\VMU\\GPWS\\CautionTerrain.mp3", force, &game->config.soundConfigComputer);
3802 LoadCockpitSound(SOUND_TA_CAUTION_OBSTACLE, "Sounds\\VMU\\GPWS\\CautionObstacle.mp3", force, &game->config.soundConfigComputer);
3803 LoadCockpitSound(SOUND_TA_OBSTACLE_WARNING, "Sounds\\VMU\\GPWS\\ObstacleObstacle.mp3", force, &game->config.soundConfigComputer);
3804
3805 LoadCockpitSound(SOUND_TCASTRAFFIC, "Sounds\\VMU\\TCAS\\traffic.mp3", force, &game->config.soundConfigComputer);
3806 LoadCockpitSound(SOUND_TCASCLIMB, "Sounds\\VMU\\TCAS\\climb.mp3", force, &game->config.soundConfigComputer);
3807 LoadCockpitSound(SOUND_TCASDESCEND, "Sounds\\VMU\\TCAS\\descend.mp3", force, &game->config.soundConfigComputer);
3808 LoadCockpitSound(SOUND_TCASINCREASECLIMB, "Sounds\\VMU\\TCAS\\IncreaseClimb.wav", force, &game->config.soundConfigComputer);
3809 LoadCockpitSound(SOUND_TCASINCREASEDESCENT, "Sounds\\VMU\\TCAS\\IncreaseDescent.wav", force, &game->config.soundConfigComputer);
3810 LoadCockpitSound(SOUND_TCASREDUCECLIMB, "Sounds\\VMU\\TCAS\\ReduceClimb.wav", force, &game->config.soundConfigComputer);
3811 LoadCockpitSound(SOUND_TCASREDUCEDESCENT, "Sounds\\VMU\\TCAS\\ReduceDescent.wav", force, &game->config.soundConfigComputer);
3812 LoadCockpitSound(SOUND_TCASCLIMBNOW, "Sounds\\VMU\\TCAS\\ClimbClimbNow.wav", force, &game->config.soundConfigComputer);
3813 LoadCockpitSound(SOUND_TCASDESCENDNOW, "Sounds\\VMU\\TCAS\\DescendDescendNow.wav", force, &game->config.soundConfigComputer);
3814 LoadCockpitSound(SOUND_TCASMAINTAIN, "Sounds\\VMU\\TCAS\\MaintainVerticalSpeedMaintain.wav", force, &game->config.soundConfigComputer);
3815 LoadCockpitSound(SOUND_TCASADJUST, "Sounds\\VMU\\TCAS\\AdjustVerticalSpeedAdjust.wav", force, &game->config.soundConfigComputer);
3816 LoadCockpitSound(SOUND_TCASMONITOR, "Sounds\\VMU\\TCAS\\monitorverticalspeed.mp3", force, &game->config.soundConfigComputer);
3817 LoadCockpitSound(SOUND_TCASCROSSING, "Sounds\\VMU\\TCAS\\Crossing.wav", force, &game->config.soundConfigComputer);
3818 LoadCockpitSound(SOUND_TCASCLEAR, "Sounds\\VMU\\TCAS\\clearofconflict.mp3", force, &game->config.soundConfigComputer);
3819 LoadCockpitSound(SOUND_TCASTESTOK, "Sounds\\VMU\\TCAS\\TcasSystemTestOk.wav", force, &game->config.soundConfigComputer);
3820
3821 LoadCockpitSound(SOUND_MONROECARGOBAY, "Sounds\\VMU\\monroe-tiaditcb.mp3", force, &game->config.soundConfigComputer);
3822 LoadCockpitSound(SOUND_MONROEALLMOORINGSCLEARED, "Sounds\\VMU\\monroe-amc.mp3", force, &game->config.soundConfigComputer);
3823 LoadCockpitSound(SOUND_MONROEGEARDOWN, "Sounds\\VMU\\monroe-geardown.mp3", force, &game->config.soundConfigComputer);
3824 LoadCockpitSound(SOUND_MONROEHULLIONIZATION, "Sounds\\VMU\\monroe-hid.mp3", force, &game->config.soundConfigComputer);
3825 LoadCockpitSound(SOUND_MONROESOUNDBARRIER, "Sounds\\VMU\\monroe-psb.mp3", force, &game->config.soundConfigComputer);
3827 LoadCockpitSound(SOUND_CONFIGAF, "Sounds\\VMU\\config-af.mp3", force, &game->config.soundConfigComputer);
3828 LoadCockpitSound(SOUND_CONFIGLANDINGGEAR, ourcockpit.spaceCapable ? "Sounds\\VMU\\config-landing-gear.mp3" : nullptr, force, &game->config.soundConfigComputer);
3830 LoadCockpitSound(SOUND_CONFIGTRIM, "Sounds\\VMU\\config-trim.mp3", force, &game->config.soundConfigComputer);
3831 LoadCockpitSound(SOUND_CONFIGSPOILERS, "Sounds\\VMU\\config-spoilers.mp3", force, &game->config.soundConfigComputer);
3832 LoadCockpitSound(SOUND_AURALUNITOKAY, "Sounds\\VMU\\AuralUnitOkay.mp3", force, &game->config.soundConfigComputer);
3833 LoadCockpitSound(SOUND_AURALUNITTESTA, "Sounds\\VMU\\AuralWarningTestA.mp3", force, &game->config.soundConfigComputer);
3834 LoadCockpitSound(SOUND_AURALUNITTESTB, "Sounds\\VMU\\AuralWarningTestB.mp3", force, &game->config.soundConfigComputer);
3835 LoadCockpitSound(SOUND_SCANNERSYNC, "Sounds\\VMU\\ScannerSync.mp3", force, &game->config.soundConfigComputer);
3836 LoadCockpitSound(SOUND_FORWARDTHRUST, "Sounds\\VMU\\ForwardThrust.mp3", force, &game->config.soundConfigComputer);
3837 LoadCockpitSound(SOUND_REVERSETHRUST, "Sounds\\VMU\\ReverseThrust.mp3", force, &game->config.soundConfigComputer);
3838 LoadCockpitSound(SOUND_CABINPRESSURE, "Sounds\\VMU\\CabinPressure.mp3", force, &game->config.soundConfigComputer);
3839 LoadCockpitSound(SOUND_GEARDISAGREE, "Sounds\\VMU\\GearDisagree.mp3", force, &game->config.soundConfigComputer);
3840 LoadCockpitSound(SOUND_AIRSPEEDALIVE, "Sounds\\VMU\\AirspeedAlive.mp3", force, &game->config.soundConfigComputer);
3843 LoadCockpitSound(SOUND_INTRANSIT, "Sounds\\VMU\\InTransit.mp3", force, &game->config.soundConfigComputer);
3844 LoadCockpitSound(SOUND_LOCALIZERALIVE, "Sounds\\VMU\\LocalizerAlive.mp3", force, &game->config.soundConfigComputer);
3845 LoadCockpitSound(SOUND_LOCALIZERCAPTURED, "Sounds\\VMU\\LocalizerCaptured.mp3", force, &game->config.soundConfigComputer);
3846 LoadCockpitSound(SOUND_GLIDESLOPEALIVE, "Sounds\\VMU\\GlideslopeAlive.mp3", force, &game->config.soundConfigComputer);
3847 LoadCockpitSound(SOUND_GLIDESLOPECAPTURED, "Sounds\\VMU\\GlideslopeCaptured.mp3", force, &game->config.soundConfigComputer);
3848 break;
3849
3850 case VehicleType::C98:
3851 case VehicleType::C2:
3852 case VehicleType::C2A:
3853 LoadCockpitSound(SOUND_COCKPITAMBIENT, "Sounds\\Cockpits\\321-idle.wav", force);
3856 LoadCockpitSound(SOUND_COCKPITENGINECENTER, "Sounds\\Cockpits\\MuVERmoto.wav", force);
3857 LoadCockpitSound(SOUND_COCKPITSTART, "Sounds\\Cockpits\\vehicle_start.wav", force);
3858 LoadCockpitSound(SOUND_COCKPITLAND, "Sounds\\Cockpits\\cmtouch1.wav", force);
3859 LoadCockpitSound(SOUND_COCKPITLEVEL, "Sounds\\Cockpits\\cmtouch2.wav", force);
3860 LoadCockpitSound(SOUND_WINDSHIELDWIPERS, "Sounds\\Cockpits\\wipers.wav", force);
3861 LoadCockpitSound(SOUND_PROP1, ourcockpit.texturelib == VehicleType::C2A ? "Sounds\\Cockpits\\canhit1.wav" : nullptr, force);
3862 LoadCockpitSound(SOUND_PROP2, ourcockpit.texturelib == VehicleType::C2A ? "Sounds\\Cockpits\\canhit2.wav" : nullptr, force);
3863 LoadCockpitSound(SOUND_PROP3, ourcockpit.texturelib == VehicleType::C2A ? "Sounds\\Cockpits\\canhit3.wav" : nullptr, force);
3864 LoadCockpitSound(SOUND_PROP4, ourcockpit.texturelib == VehicleType::C2A ? "Sounds\\Cockpits\\canroll1.wav" : nullptr, force);
3865 LoadCockpitSound(SOUND_PROP5, ourcockpit.texturelib == VehicleType::C2A ? "Sounds\\Cockpits\\canroll2.wav" : nullptr, force);
3866 LoadCockpitSound(SOUND_PROP6, ourcockpit.texturelib == VehicleType::C2A ? "Sounds\\Cockpits\\canroll3.wav" : nullptr, force);
3867
3868 LoadCockpitSound(SOUND_COCKPITLOWFUEL, "Sounds\\nchime.wav", force, &game->config.soundConfigComputer);
3871
3901
3917
3944 break;
3945
3946 case VehicleType::T120:
3947 LoadCockpitSound(SOUND_COCKPITAMBIENT, "Sounds\\Cockpits\\321-idle.wav", force);
3950 LoadCockpitSound(SOUND_COCKPITENGINECENTER, "Sounds\\Cockpits\\steerhead_run.wav", force);
3951 LoadCockpitSound(SOUND_COCKPITSTART, "Sounds\\Cockpits\\steerhead_start.wav", force);
3952 LoadCockpitSound(SOUND_COCKPITLAND, "Sounds\\Cockpits\\cmtouch1.wav", force);
3953 LoadCockpitSound(SOUND_COCKPITLEVEL, "Sounds\\Cockpits\\cmtouch2.wav", force);
3954 LoadCockpitSound(SOUND_WINDSHIELDWIPERS, "Sounds\\Cockpits\\wipers.wav", force);
3955 LoadCockpitSound(SOUND_PROP1, nullptr, force);
3956 LoadCockpitSound(SOUND_PROP2, nullptr, force);
3957 LoadCockpitSound(SOUND_PROP3, nullptr, force);
3958 LoadCockpitSound(SOUND_PROP4, nullptr, force);
3959 LoadCockpitSound(SOUND_PROP5, nullptr, force);
3960 LoadCockpitSound(SOUND_PROP6, nullptr, force);
3961
3962 LoadCockpitSound(SOUND_COCKPITLOWFUEL, "Sounds\\nchime.wav", force, &game->config.soundConfigComputer);
3965
3995
4011
4038 break;
4039
4040 case VehicleType::T121:
4041 LoadCockpitSound(SOUND_COCKPITAMBIENT, "Sounds\\Cockpits\\321-idle.wav", force);
4044 LoadCockpitSound(SOUND_COCKPITENGINECENTER, "Sounds\\Cockpits\\steerhead_run2.wav", force);
4045 LoadCockpitSound(SOUND_COCKPITSTART, "Sounds\\Cockpits\\steerhead_start2.wav", force);
4046 LoadCockpitSound(SOUND_COCKPITLAND, "Sounds\\Cockpits\\cmtouch1.wav", force);
4047 LoadCockpitSound(SOUND_COCKPITLEVEL, "Sounds\\Cockpits\\cmtouch2.wav", force);
4048 LoadCockpitSound(SOUND_WINDSHIELDWIPERS, "Sounds\\Cockpits\\wipers.wav", force);
4049 LoadCockpitSound(SOUND_PROP1, nullptr, force);
4050 LoadCockpitSound(SOUND_PROP2, nullptr, force);
4051 LoadCockpitSound(SOUND_PROP3, nullptr, force);
4052 LoadCockpitSound(SOUND_PROP4, nullptr, force);
4053 LoadCockpitSound(SOUND_PROP5, nullptr, force);
4054 LoadCockpitSound(SOUND_PROP6, nullptr, force);
4055
4056 LoadCockpitSound(SOUND_COCKPITLOWFUEL, "Sounds\\nchime.wav", force, &game->config.soundConfigComputer);
4059
4089
4105
4132 break;
4133
4134 case VehicleType::P13:
4135 LoadCockpitSound(SOUND_COCKPITAMBIENT, "Sounds\\Cockpits\\322-idle.wav", force);
4136 LoadCockpitSound(SOUND_COCKPITENGINELEFT, "Sounds\\Cockpits\\AlienEng1.wav", force);
4137 LoadCockpitSound(SOUND_COCKPITENGINERIGHT, "Sounds\\Cockpits\\AlienEng1.wav", force);
4139 LoadCockpitSound(SOUND_COCKPITSTART, "Sounds\\Cockpits\\prowler_start.wav", force);
4140 LoadCockpitSound(SOUND_COCKPITLAND, "Sounds\\Cockpits\\touchlb.wav", force);
4141 LoadCockpitSound(SOUND_COCKPITLEVEL, "Sounds\\Cockpits\\touchld.wav", force);
4143 LoadCockpitSound(SOUND_PROP1, nullptr, force);
4144 LoadCockpitSound(SOUND_PROP2, nullptr, force);
4145 LoadCockpitSound(SOUND_PROP3, nullptr, force);
4146 LoadCockpitSound(SOUND_PROP4, nullptr, force);
4147 LoadCockpitSound(SOUND_PROP5, nullptr, force);
4148 LoadCockpitSound(SOUND_PROP6, nullptr, force);
4149
4151 LoadCockpitSound(SOUND_STALL, "Sounds\\VMU\\E-10\\stall.wav", force, &game->config.soundConfigComputer);
4152 LoadCockpitSound(SOUND_OVERSPEED, "Sounds\\VMU\\overspeed.mp3", force, &game->config.soundConfigComputer);
4153
4154 LoadCockpitSound(SOUND_GPWSSINKRATE, "Sounds\\VMU\\E-10\\GPWS\\monroe-sr.wav", force, &game->config.soundConfigComputer);
4155 LoadCockpitSound(SOUND_GPWSPULLUP, "Sounds\\VMU\\E-10\\GPWS\\monroe-pu.wav", force, &game->config.soundConfigComputer);
4156 LoadCockpitSound(SOUND_TA_PULLUP, "Sounds\\VMU\\E-10\\GPWS\\PullUp.wav", force, &game->config.soundConfigComputer);
4157 LoadCockpitSound(SOUND_GPWSTERRAINTERRAIN, "Sounds\\VMU\\E-10\\GPWS\\monroe-tt.wav", force, &game->config.soundConfigComputer);
4158 LoadCockpitSound(SOUND_GPWSTERRAIN, "Sounds\\VMU\\E-10\\GPWS\\Terrain.wav", force, &game->config.soundConfigComputer);
4159 LoadCockpitSound(SOUND_GPWSTOOLOWTERRAIN, "Sounds\\VMU\\E-10\\GPWS\\TooLowTerrain.wav", force, &game->config.soundConfigComputer);
4160 LoadCockpitSound(SOUND_GPWSTOOLOWGEAR, "Sounds\\VMU\\E-10\\GPWS\\monroe-struts.wav", force, &game->config.soundConfigComputer);
4162 LoadCockpitSound(SOUND_GPWSBANKANGLE, "Sounds\\VMU\\E-10\\GPWS\\BankAngle.wav", force, &game->config.soundConfigComputer);
4163 LoadCockpitSound(SOUND_GPWSGLIDESLOPE, "Sounds\\VMU\\E-10\\GPWS\\Glideslope.wav", force, &game->config.soundConfigComputer);
4164 LoadCockpitSound(SOUND_GPWSRETARD, "Sounds\\VMU\\E-10\\GPWS\\Retard.wav", force, &game->config.soundConfigComputer);
4165 LoadCockpitSound(SOUND_GPWSTEN, "Sounds\\VMU\\E-10\\GPWS\\10.wav", force, &game->config.soundConfigComputer);
4166 LoadCockpitSound(SOUND_GPWSTWENTY, "Sounds\\VMU\\E-10\\GPWS\\20.wav", force, &game->config.soundConfigComputer);
4167 LoadCockpitSound(SOUND_GPWSTHIRTY, "Sounds\\VMU\\E-10\\GPWS\\30.wav", force, &game->config.soundConfigComputer);
4168 LoadCockpitSound(SOUND_GPWSFORTY, "Sounds\\VMU\\E-10\\GPWS\\40.wav", force, &game->config.soundConfigComputer);
4169 LoadCockpitSound(SOUND_GPWSFIFTY, "Sounds\\VMU\\E-10\\GPWS\\50.wav", force, &game->config.soundConfigComputer);
4170 LoadCockpitSound(SOUND_GPWSONEHUNDRED, "Sounds\\VMU\\E-10\\GPWS\\100.wav", force, &game->config.soundConfigComputer);
4171 LoadCockpitSound(SOUND_GPWSTWOHUNDRED, "Sounds\\VMU\\E-10\\GPWS\\200.wav", force, &game->config.soundConfigComputer);
4172 LoadCockpitSound(SOUND_GPWSMINIMUMS, "Sounds\\VMU\\E-10\\GPWS\\500.wav", force, &game->config.soundConfigComputer);
4173 LoadCockpitSound(SOUND_GPWSFIVEHUNDRED, "Sounds\\VMU\\E-10\\GPWS\\500.wav", force, &game->config.soundConfigComputer);
4174 LoadCockpitSound(SOUND_GPWSONETHOUSAND, "Sounds\\VMU\\E-10\\GPWS\\1000.wav", force, &game->config.soundConfigComputer);
4175 LoadCockpitSound(SOUND_GPWSDONTSINK, "Sounds\\VMU\\E-10\\GPWS\\DontSink.wav", force, &game->config.soundConfigComputer);
4176 LoadCockpitSound(SOUND_GPWSPOSITIVERATE, "Sounds\\VMU\\E-10\\GPWS\\PositiveRate.wav", force, &game->config.soundConfigComputer);
4177 LoadCockpitSound(SOUND_GPWSWINDSHEARWARNING, "Sounds\\VMU\\E-10\\GPWS\\WindshearWarning.wav", force, &game->config.soundConfigComputer);
4178 LoadCockpitSound(SOUND_GPWSWINDSHEARCAUTION, "Sounds\\VMU\\E-10\\GPWS\\WindshearCaution.wav", force, &game->config.soundConfigComputer);
4180 LoadCockpitSound(SOUND_TA_CAUTION_TERRAIN, "Sounds\\VMU\\E-10\\GPWS\\CautionTerrain.wav", force, &game->config.soundConfigComputer);
4181 LoadCockpitSound(SOUND_TA_CAUTION_OBSTACLE, "Sounds\\VMU\\E-10\\GPWS\\CautionObstacle.wav", force, &game->config.soundConfigComputer);
4182 LoadCockpitSound(SOUND_TA_OBSTACLE_WARNING, "Sounds\\VMU\\E-10\\GPWS\\ObstacleObstacle.wav", force, &game->config.soundConfigComputer);
4183
4184 LoadCockpitSound(SOUND_TCASTRAFFIC, "Sounds\\VMU\\E-10\\TCAS\\traffic.wav", force, &game->config.soundConfigComputer);
4185 LoadCockpitSound(SOUND_TCASCLIMB, "Sounds\\VMU\\E-10\\TCAS\\climb.wav", force, &game->config.soundConfigComputer);
4186 LoadCockpitSound(SOUND_TCASDESCEND, "Sounds\\VMU\\E-10\\TCAS\\descend.wav", force, &game->config.soundConfigComputer);
4187 LoadCockpitSound(SOUND_TCASINCREASECLIMB, "Sounds\\VMU\\E-10\\TCAS\\IncreaseClimb.wav", force, &game->config.soundConfigComputer);
4188 LoadCockpitSound(SOUND_TCASINCREASEDESCENT, "Sounds\\VMU\\E-10\\TCAS\\IncreaseDescent.wav", force, &game->config.soundConfigComputer);
4189 LoadCockpitSound(SOUND_TCASREDUCECLIMB, "Sounds\\VMU\\E-10\\TCAS\\ReduceClimb.wav", force, &game->config.soundConfigComputer);
4190 LoadCockpitSound(SOUND_TCASREDUCEDESCENT, "Sounds\\VMU\\E-10\\TCAS\\ReduceDescent.wav", force, &game->config.soundConfigComputer);
4191 LoadCockpitSound(SOUND_TCASCLIMBNOW, "Sounds\\VMU\\E-10\\TCAS\\ClimbClimbNow.wav", force, &game->config.soundConfigComputer);
4192 LoadCockpitSound(SOUND_TCASDESCENDNOW, "Sounds\\VMU\\E-10\\TCAS\\DescendDescendNow.wav", force, &game->config.soundConfigComputer);
4193 LoadCockpitSound(SOUND_TCASMAINTAIN, "Sounds\\VMU\\E-10\\TCAS\\MaintainVerticalSpeedMaintain.wav", force, &game->config.soundConfigComputer);
4194 LoadCockpitSound(SOUND_TCASADJUST, "Sounds\\VMU\\E-10\\TCAS\\AdjustVerticalSpeedAdjust.wav", force, &game->config.soundConfigComputer);
4195 LoadCockpitSound(SOUND_TCASMONITOR, "Sounds\\VMU\\E-10\\TCAS\\monitorverticalspeed.wav", force, &game->config.soundConfigComputer);
4196 LoadCockpitSound(SOUND_TCASCROSSING, "Sounds\\VMU\\E-10\\TCAS\\Crossing.wav", force, &game->config.soundConfigComputer);
4197 LoadCockpitSound(SOUND_TCASCLEAR, "Sounds\\VMU\\E-10\\TCAS\\clearofconflict.wav", force, &game->config.soundConfigComputer);
4198 LoadCockpitSound(SOUND_TCASTESTOK, "Sounds\\VMU\\E-10\\TCAS\\TcasSystemTestOk.wav", force, &game->config.soundConfigComputer);
4199
4200 LoadCockpitSound(SOUND_MONROECARGOBAY, "Sounds\\VMU\\E-10\\monroe-tiaditcb.wav", force, &game->config.soundConfigComputer);
4201 LoadCockpitSound(SOUND_MONROEALLMOORINGSCLEARED, "Sounds\\VMU\\E-10\\monroe-amc.wav", force, &game->config.soundConfigComputer);
4202 LoadCockpitSound(SOUND_MONROEGEARDOWN, "Sounds\\VMU\\E-10\\monroe-strutse.wav", force, &game->config.soundConfigComputer);
4203 LoadCockpitSound(SOUND_MONROEHULLIONIZATION, "Sounds\\VMU\\E-10\\monroe-hid.wav", force, &game->config.soundConfigComputer);
4204 LoadCockpitSound(SOUND_MONROESOUNDBARRIER, "Sounds\\VMU\\E-10\\monroe-psb.wav", force, &game->config.soundConfigComputer);
4206 LoadCockpitSound(SOUND_CONFIGAF, "Sounds\\VMU\\E-10\\config-af.wav", force, &game->config.soundConfigComputer);
4207 LoadCockpitSound(SOUND_CONFIGLANDINGGEAR, ourcockpit.spaceCapable ? "Sounds\\VMU\\E-10\\config-landing-gear.wav" : nullptr, force, &game->config.soundConfigComputer);
4209 LoadCockpitSound(SOUND_CONFIGTRIM, "Sounds\\VMU\\E-10\\config-trim.wav", force, &game->config.soundConfigComputer);
4211 LoadCockpitSound(SOUND_AURALUNITOKAY, "Sounds\\VMU\\E-10\\AuralUnitOkay.wav", force, &game->config.soundConfigComputer);
4212 LoadCockpitSound(SOUND_AURALUNITTESTA, "Sounds\\VMU\\E-10\\AuralWarningTestA.wav", force, &game->config.soundConfigComputer);
4213 LoadCockpitSound(SOUND_AURALUNITTESTB, "Sounds\\VMU\\E-10\\AuralWarningTestB.wav", force, &game->config.soundConfigComputer);
4214 LoadCockpitSound(SOUND_SCANNERSYNC, "Sounds\\VMU\\E-10\\ScannerSync.wav", force, &game->config.soundConfigComputer);
4215 LoadCockpitSound(SOUND_FORWARDTHRUST, "Sounds\\VMU\\E-10\\ForwardThrust.wav", force, &game->config.soundConfigComputer);
4216 LoadCockpitSound(SOUND_REVERSETHRUST, "Sounds\\VMU\\E-10\\ReverseThrust.wav", force, &game->config.soundConfigComputer);
4217 LoadCockpitSound(SOUND_CABINPRESSURE, "Sounds\\VMU\\E-10\\CabinPressure.wav", force, &game->config.soundConfigComputer);
4218 LoadCockpitSound(SOUND_GEARDISAGREE, "Sounds\\VMU\\E-10\\GearDisagree.wav", force, &game->config.soundConfigComputer);
4219 LoadCockpitSound(SOUND_AIRSPEEDALIVE, "Sounds\\VMU\\E-10\\AirspeedAlive.wav", force, &game->config.soundConfigComputer);
4222 LoadCockpitSound(SOUND_INTRANSIT, "Sounds\\VMU\\E-10\\InTransit.wav", force, &game->config.soundConfigComputer);
4223 LoadCockpitSound(SOUND_LOCALIZERALIVE, "Sounds\\VMU\\E-10\\LocalizerAlive.wav", force, &game->config.soundConfigComputer);
4224 LoadCockpitSound(SOUND_LOCALIZERCAPTURED, "Sounds\\VMU\\E-10\\LocalizerCaptured.wav", force, &game->config.soundConfigComputer);
4225 LoadCockpitSound(SOUND_GLIDESLOPEALIVE, "Sounds\\VMU\\E-10\\GlideslopeAlive.wav", force, &game->config.soundConfigComputer);
4226 LoadCockpitSound(SOUND_GLIDESLOPECAPTURED, "Sounds\\VMU\\E-10\\GlideslopeCaptured.wav", force, &game->config.soundConfigComputer);
4227 break;
4228
4229 case VehicleType::A4:
4230 LoadCockpitSound(SOUND_COCKPITAMBIENT, "Sounds\\Cockpits\\CABIN FANS.wav", force);
4231 LoadCockpitSound(SOUND_COCKPITENGINELEFT, "Sounds\\Cockpits\\fighter_on_space1.wav", force);
4232 LoadCockpitSound(SOUND_COCKPITENGINERIGHT, "Sounds\\Cockpits\\fighter_on_space1.wav", force);
4234 LoadCockpitSound(SOUND_COCKPITSTART, "Sounds\\Cockpits\\cruiser_start.wav", force);
4235 LoadCockpitSound(SOUND_COCKPITLAND, "Sounds\\Cockpits\\touchlb.wav", force);
4236 LoadCockpitSound(SOUND_COCKPITLEVEL, "Sounds\\Cockpits\\touchld.wav", force);
4238 LoadCockpitSound(SOUND_PROP1, nullptr, force);
4239 LoadCockpitSound(SOUND_PROP2, nullptr, force);
4240 LoadCockpitSound(SOUND_PROP3, nullptr, force);
4241 LoadCockpitSound(SOUND_PROP4, nullptr, force);
4242 LoadCockpitSound(SOUND_PROP5, nullptr, force);
4243 LoadCockpitSound(SOUND_PROP6, nullptr, force);
4244
4246 LoadCockpitSound(SOUND_STALL, "Sounds\\VMU\\E-10\\stall.wav", force, &game->config.soundConfigComputer);
4247 LoadCockpitSound(SOUND_OVERSPEED, "Sounds\\VMU\\overspeed.mp3", force, &game->config.soundConfigComputer);
4248
4249 LoadCockpitSound(SOUND_GPWSSINKRATE, "Sounds\\VMU\\E-10\\GPWS\\monroe-sr.wav", force, &game->config.soundConfigComputer);
4250 LoadCockpitSound(SOUND_GPWSPULLUP, "Sounds\\VMU\\E-10\\GPWS\\monroe-pu.wav", force, &game->config.soundConfigComputer);
4251 LoadCockpitSound(SOUND_TA_PULLUP, "Sounds\\VMU\\E-10\\GPWS\\PullUp.wav", force, &game->config.soundConfigComputer);
4252 LoadCockpitSound(SOUND_GPWSTERRAINTERRAIN, "Sounds\\VMU\\E-10\\GPWS\\monroe-tt.wav", force, &game->config.soundConfigComputer);
4253 LoadCockpitSound(SOUND_GPWSTERRAIN, "Sounds\\VMU\\E-10\\GPWS\\Terrain.wav", force, &game->config.soundConfigComputer);
4254 LoadCockpitSound(SOUND_GPWSTOOLOWTERRAIN, "Sounds\\VMU\\E-10\\GPWS\\TooLowTerrain.wav", force, &game->config.soundConfigComputer);
4255 LoadCockpitSound(SOUND_GPWSTOOLOWGEAR, "Sounds\\VMU\\E-10\\GPWS\\monroe-struts.wav", force, &game->config.soundConfigComputer);
4257 LoadCockpitSound(SOUND_GPWSBANKANGLE, "Sounds\\VMU\\E-10\\GPWS\\BankAngle.wav", force, &game->config.soundConfigComputer);
4258 LoadCockpitSound(SOUND_GPWSGLIDESLOPE, "Sounds\\VMU\\E-10\\GPWS\\Glideslope.wav", force, &game->config.soundConfigComputer);
4259 LoadCockpitSound(SOUND_GPWSRETARD, "Sounds\\VMU\\E-10\\GPWS\\Retard.wav", force, &game->config.soundConfigComputer);
4260 LoadCockpitSound(SOUND_GPWSTEN, "Sounds\\VMU\\E-10\\GPWS\\10.wav", force, &game->config.soundConfigComputer);
4261 LoadCockpitSound(SOUND_GPWSTWENTY, "Sounds\\VMU\\E-10\\GPWS\\20.wav", force, &game->config.soundConfigComputer);
4262 LoadCockpitSound(SOUND_GPWSTHIRTY, "Sounds\\VMU\\E-10\\GPWS\\30.wav", force, &game->config.soundConfigComputer);
4263 LoadCockpitSound(SOUND_GPWSFORTY, "Sounds\\VMU\\E-10\\GPWS\\40.wav", force, &game->config.soundConfigComputer);
4264 LoadCockpitSound(SOUND_GPWSFIFTY, "Sounds\\VMU\\E-10\\GPWS\\50.wav", force, &game->config.soundConfigComputer);
4265 LoadCockpitSound(SOUND_GPWSONEHUNDRED, "Sounds\\VMU\\E-10\\GPWS\\100.wav", force, &game->config.soundConfigComputer);
4266 LoadCockpitSound(SOUND_GPWSTWOHUNDRED, "Sounds\\VMU\\E-10\\GPWS\\200.wav", force, &game->config.soundConfigComputer);
4267 LoadCockpitSound(SOUND_GPWSMINIMUMS, "Sounds\\VMU\\E-10\\GPWS\\Minimums.wav", force, &game->config.soundConfigComputer);
4268 LoadCockpitSound(SOUND_GPWSFIVEHUNDRED, "Sounds\\VMU\\E-10\\GPWS\\500.wav", force, &game->config.soundConfigComputer);
4269 LoadCockpitSound(SOUND_GPWSONETHOUSAND, "Sounds\\VMU\\E-10\\GPWS\\1000.wav", force, &game->config.soundConfigComputer);
4270 LoadCockpitSound(SOUND_GPWSDONTSINK, "Sounds\\VMU\\E-10\\GPWS\\DontSink.wav", force, &game->config.soundConfigComputer);
4271 LoadCockpitSound(SOUND_GPWSPOSITIVERATE, "Sounds\\VMU\\E-10\\GPWS\\PositiveRate.wav", force, &game->config.soundConfigComputer);
4272 LoadCockpitSound(SOUND_GPWSWINDSHEARWARNING, "Sounds\\VMU\\E-10\\GPWS\\WindshearWarning.wav", force, &game->config.soundConfigComputer);
4273 LoadCockpitSound(SOUND_GPWSWINDSHEARCAUTION, "Sounds\\VMU\\E-10\\GPWS\\WindshearCaution.wav", force, &game->config.soundConfigComputer);
4275 LoadCockpitSound(SOUND_TA_CAUTION_TERRAIN, "Sounds\\VMU\\E-10\\GPWS\\CautionTerrain.wav", force, &game->config.soundConfigComputer);
4276 LoadCockpitSound(SOUND_TA_CAUTION_OBSTACLE, "Sounds\\VMU\\E-10\\GPWS\\CautionObstacle.wav", force, &game->config.soundConfigComputer);
4277 LoadCockpitSound(SOUND_TA_OBSTACLE_WARNING, "Sounds\\VMU\\E-10\\GPWS\\ObstacleObstacle.wav", force, &game->config.soundConfigComputer);
4278
4279 LoadCockpitSound(SOUND_TCASTRAFFIC, "Sounds\\VMU\\E-10\\TCAS\\traffic.wav", force, &game->config.soundConfigComputer);
4280 LoadCockpitSound(SOUND_TCASCLIMB, "Sounds\\VMU\\E-10\\TCAS\\climb.wav", force, &game->config.soundConfigComputer);
4281 LoadCockpitSound(SOUND_TCASDESCEND, "Sounds\\VMU\\E-10\\TCAS\\descend.wav", force, &game->config.soundConfigComputer);
4282 LoadCockpitSound(SOUND_TCASINCREASECLIMB, "Sounds\\VMU\\E-10\\TCAS\\IncreaseClimb.wav", force, &game->config.soundConfigComputer);
4283 LoadCockpitSound(SOUND_TCASINCREASEDESCENT, "Sounds\\VMU\\E-10\\TCAS\\IncreaseDescent.wav", force, &game->config.soundConfigComputer);
4284 LoadCockpitSound(SOUND_TCASREDUCECLIMB, "Sounds\\VMU\\E-10\\TCAS\\ReduceClimb.wav", force, &game->config.soundConfigComputer);
4285 LoadCockpitSound(SOUND_TCASREDUCEDESCENT, "Sounds\\VMU\\E-10\\TCAS\\ReduceDescent.wav", force, &game->config.soundConfigComputer);
4286 LoadCockpitSound(SOUND_TCASCLIMBNOW, "Sounds\\VMU\\E-10\\TCAS\\ClimbClimbNow.wav", force, &game->config.soundConfigComputer);
4287 LoadCockpitSound(SOUND_TCASDESCENDNOW, "Sounds\\VMU\\E-10\\TCAS\\DescendDescendNow.wav", force, &game->config.soundConfigComputer);
4288 LoadCockpitSound(SOUND_TCASMAINTAIN, "Sounds\\VMU\\E-10\\TCAS\\MaintainVerticalSpeedMaintain.wav", force, &game->config.soundConfigComputer);
4289 LoadCockpitSound(SOUND_TCASADJUST, "Sounds\\VMU\\E-10\\TCAS\\AdjustVerticalSpeedAdjust.wav", force, &game->config.soundConfigComputer);
4290 LoadCockpitSound(SOUND_TCASMONITOR, "Sounds\\VMU\\E-10\\TCAS\\monitorverticalspeed.wav", force, &game->config.soundConfigComputer);
4291 LoadCockpitSound(SOUND_TCASCROSSING, "Sounds\\VMU\\E-10\\TCAS\\Crossing.wav", force, &game->config.soundConfigComputer);
4292 LoadCockpitSound(SOUND_TCASCLEAR, "Sounds\\VMU\\E-10\\TCAS\\clearofconflict.wav", force, &game->config.soundConfigComputer);
4293 LoadCockpitSound(SOUND_TCASTESTOK, "Sounds\\VMU\\E-10\\TCAS\\TcasSystemTestOk.wav", force, &game->config.soundConfigComputer);
4294
4295 LoadCockpitSound(SOUND_MONROECARGOBAY, "Sounds\\VMU\\E-10\\monroe-tiaditcb.wav", force, &game->config.soundConfigComputer);
4296 LoadCockpitSound(SOUND_MONROEALLMOORINGSCLEARED, "Sounds\\VMU\\E-10\\monroe-amc.wav", force, &game->config.soundConfigComputer);
4297 LoadCockpitSound(SOUND_MONROEGEARDOWN, "Sounds\\VMU\\E-10\\monroe-strutse.wav", force, &game->config.soundConfigComputer);
4298 LoadCockpitSound(SOUND_MONROEHULLIONIZATION, "Sounds\\VMU\\E-10\\monroe-hid.wav", force, &game->config.soundConfigComputer);
4299 LoadCockpitSound(SOUND_MONROESOUNDBARRIER, "Sounds\\VMU\\E-10\\monroe-psb.wav", force, &game->config.soundConfigComputer);
4301 LoadCockpitSound(SOUND_CONFIGAF, "Sounds\\VMU\\E-10\\config-af.wav", force, &game->config.soundConfigComputer);
4302 LoadCockpitSound(SOUND_CONFIGLANDINGGEAR, ourcockpit.spaceCapable ? "Sounds\\VMU\\E-10\\config-landing-gear.wav" : nullptr, force, &game->config.soundConfigComputer);
4304 LoadCockpitSound(SOUND_CONFIGTRIM, "Sounds\\VMU\\E-10\\config-trim.wav", force, &game->config.soundConfigComputer);
4306 LoadCockpitSound(SOUND_AURALUNITOKAY, "Sounds\\VMU\\E-10\\AuralUnitOkay.wav", force, &game->config.soundConfigComputer);
4307 LoadCockpitSound(SOUND_AURALUNITTESTA, "Sounds\\VMU\\E-10\\AuralWarningTestA.wav", force, &game->config.soundConfigComputer);
4308 LoadCockpitSound(SOUND_AURALUNITTESTB, "Sounds\\VMU\\E-10\\AuralWarningTestB.wav", force, &game->config.soundConfigComputer);
4309 LoadCockpitSound(SOUND_SCANNERSYNC, "Sounds\\VMU\\E-10\\ScannerSync.wav", force, &game->config.soundConfigComputer);
4310 LoadCockpitSound(SOUND_FORWARDTHRUST, "Sounds\\VMU\\E-10\\ForwardThrust.wav", force, &game->config.soundConfigComputer);
4311 LoadCockpitSound(SOUND_REVERSETHRUST, "Sounds\\VMU\\E-10\\ReverseThrust.wav", force, &game->config.soundConfigComputer);
4312 LoadCockpitSound(SOUND_CABINPRESSURE, "Sounds\\VMU\\E-10\\CabinPressure.wav", force, &game->config.soundConfigComputer);
4313 LoadCockpitSound(SOUND_GEARDISAGREE, "Sounds\\VMU\\E-10\\GearDisagree.wav", force, &game->config.soundConfigComputer);
4314 LoadCockpitSound(SOUND_AIRSPEEDALIVE, "Sounds\\VMU\\E-10\\AirspeedAlive.wav", force, &game->config.soundConfigComputer);
4317 LoadCockpitSound(SOUND_INTRANSIT, "Sounds\\VMU\\E-10\\InTransit.wav", force, &game->config.soundConfigComputer);
4318 LoadCockpitSound(SOUND_LOCALIZERALIVE, "Sounds\\VMU\\E-10\\LocalizerAlive.wav", force, &game->config.soundConfigComputer);
4319 LoadCockpitSound(SOUND_LOCALIZERCAPTURED, "Sounds\\VMU\\E-10\\LocalizerCaptured.wav", force, &game->config.soundConfigComputer);
4320 LoadCockpitSound(SOUND_GLIDESLOPEALIVE, "Sounds\\VMU\\E-10\\GlideslopeAlive.wav", force, &game->config.soundConfigComputer);
4321 LoadCockpitSound(SOUND_GLIDESLOPECAPTURED, "Sounds\\VMU\\E-10\\GlideslopeCaptured.wav", force, &game->config.soundConfigComputer);
4322 break;
4323
4325 LoadCockpitSound(SOUND_COCKPITAMBIENT, "Sounds\\Cockpits\\ambient w-6.wav", force);
4326 LoadCockpitSound(SOUND_COCKPITENGINELEFT, "Sounds\\Cockpits\\engine w-6.wav", force);
4327 LoadCockpitSound(SOUND_COCKPITENGINERIGHT, "Sounds\\Cockpits\\engine w-6.wav", force);
4329 LoadCockpitSound(SOUND_COCKPITSTART, "Sounds\\Cockpits\\startup w-6.wav", force);
4330 LoadCockpitSound(SOUND_COCKPITLAND, "Sounds\\Cockpits\\bmtouch2.wav", force);
4331 LoadCockpitSound(SOUND_COCKPITLEVEL, "Sounds\\Cockpits\\bmtouch4.wav", force);
4332 LoadCockpitSound(SOUND_WINDSHIELDWIPERS, "Sounds\\Cockpits\\BleedAir-DuctGlass-Loop.wav", force);
4333 LoadCockpitSound(SOUND_RAINAIRRUSH, "Sounds\\Cockpits\\BleedAir-ExteriorRush-Loop.wav", force);
4334 LoadCockpitSound(SOUND_PROP1, nullptr, force);
4335 LoadCockpitSound(SOUND_PROP2, nullptr, force);
4336 LoadCockpitSound(SOUND_PROP3, nullptr, force);
4337 LoadCockpitSound(SOUND_PROP4, nullptr, force);
4338 LoadCockpitSound(SOUND_PROP5, nullptr, force);
4339 LoadCockpitSound(SOUND_PROP6, nullptr, force);
4340
4342 LoadCockpitSound(SOUND_STALL, "Sounds\\VMU\\stall.mp3", force, &game->config.soundConfigComputer);
4343 LoadCockpitSound(SOUND_OVERSPEED, "Sounds\\VMU\\overspeed.mp3", force, &game->config.soundConfigComputer);
4344
4345 LoadCockpitSound(SOUND_GPWSSINKRATE, "Sounds\\VMU\\GPWS\\monroe-sr.mp3", force, &game->config.soundConfigComputer);
4346 LoadCockpitSound(SOUND_GPWSPULLUP, "Sounds\\VMU\\GPWS\\monroe-pu.mp3", force, &game->config.soundConfigComputer);
4347 LoadCockpitSound(SOUND_TA_PULLUP, "Sounds\\VMU\\GPWS\\PullUp.mp3", force, &game->config.soundConfigComputer);
4348 LoadCockpitSound(SOUND_GPWSTERRAINTERRAIN, "Sounds\\VMU\\GPWS\\TerrainTerrain.mp3", force, &game->config.soundConfigComputer);
4349 LoadCockpitSound(SOUND_GPWSTERRAIN, "Sounds\\VMU\\GPWS\\Terrain.mp3", force, &game->config.soundConfigComputer);
4350 LoadCockpitSound(SOUND_GPWSTOOLOWTERRAIN, "Sounds\\VMU\\GPWS\\TooLowTerrain.mp3", force, &game->config.soundConfigComputer);
4351 LoadCockpitSound(SOUND_GPWSTOOLOWGEAR, "Sounds\\VMU\\GPWS\\TooLowGear.mp3", force, &game->config.soundConfigComputer);
4352 LoadCockpitSound(SOUND_GPWSTOOLOWFLAPS, "Sounds\\VMU\\GPWS\\TooLowFlaps.mp3", force, &game->config.soundConfigComputer);
4353 LoadCockpitSound(SOUND_GPWSBANKANGLE, "Sounds\\VMU\\GPWS\\BankAngle.wav", force, &game->config.soundConfigComputer);
4354 LoadCockpitSound(SOUND_GPWSGLIDESLOPE, "Sounds\\VMU\\GPWS\\Glideslope.wav", force, &game->config.soundConfigComputer);
4355 LoadCockpitSound(SOUND_GPWSRETARD, "Sounds\\VMU\\GPWS\\Retard.wav", force, &game->config.soundConfigComputer);
4356 LoadCockpitSound(SOUND_GPWSTEN, "Sounds\\VMU\\GPWS\\10.wav", force, &game->config.soundConfigComputer);
4357 LoadCockpitSound(SOUND_GPWSTWENTY, "Sounds\\VMU\\GPWS\\20.wav", force, &game->config.soundConfigComputer);
4358 LoadCockpitSound(SOUND_GPWSTHIRTY, "Sounds\\VMU\\GPWS\\30.wav", force, &game->config.soundConfigComputer);
4359 LoadCockpitSound(SOUND_GPWSFORTY, "Sounds\\VMU\\GPWS\\40.wav", force, &game->config.soundConfigComputer);
4360 LoadCockpitSound(SOUND_GPWSFIFTY, "Sounds\\VMU\\GPWS\\50.wav", force, &game->config.soundConfigComputer);
4361 LoadCockpitSound(SOUND_GPWSONEHUNDRED, "Sounds\\VMU\\GPWS\\100.wav", force, &game->config.soundConfigComputer);
4362 LoadCockpitSound(SOUND_GPWSTWOHUNDRED, "Sounds\\VMU\\GPWS\\200.wav", force, &game->config.soundConfigComputer);
4363 LoadCockpitSound(SOUND_GPWSMINIMUMS, "Sounds\\VMU\\GPWS\\Minimums.wav", force, &game->config.soundConfigComputer);
4364 LoadCockpitSound(SOUND_GPWSFIVEHUNDRED, "Sounds\\VMU\\GPWS\\500.wav", force, &game->config.soundConfigComputer);
4365 LoadCockpitSound(SOUND_GPWSONETHOUSAND, "Sounds\\VMU\\GPWS\\1000.wav", force, &game->config.soundConfigComputer);
4366 LoadCockpitSound(SOUND_GPWSDONTSINK, "Sounds\\VMU\\GPWS\\DontSink.mp3", force, &game->config.soundConfigComputer);
4367 LoadCockpitSound(SOUND_GPWSPOSITIVERATE, "Sounds\\VMU\\GPWS\\PositiveRate.mp3", force, &game->config.soundConfigComputer);
4368 LoadCockpitSound(SOUND_GPWSWINDSHEARWARNING, "Sounds\\VMU\\GPWS\\WindshearWarning.wav", force, &game->config.soundConfigComputer);
4369 LoadCockpitSound(SOUND_GPWSWINDSHEARCAUTION, "Sounds\\VMU\\GPWS\\WindshearCaution.mp3", force, &game->config.soundConfigComputer);
4370 LoadCockpitSound(SOUND_GPWSROTATE, "Sounds\\VMU\\GPWS\\Rotate.mp3", force, &game->config.soundConfigComputer);
4371 LoadCockpitSound(SOUND_TA_CAUTION_TERRAIN, "Sounds\\VMU\\GPWS\\CautionTerrain.mp3", force, &game->config.soundConfigComputer);
4372 LoadCockpitSound(SOUND_TA_CAUTION_OBSTACLE, "Sounds\\VMU\\GPWS\\CautionObstacle.mp3", force, &game->config.soundConfigComputer);
4373 LoadCockpitSound(SOUND_TA_OBSTACLE_WARNING, "Sounds\\VMU\\GPWS\\ObstacleObstacle.mp3", force, &game->config.soundConfigComputer);
4374
4375 LoadCockpitSound(SOUND_TCASTRAFFIC, "Sounds\\VMU\\TCAS\\traffic.mp3", force, &game->config.soundConfigComputer);
4376 LoadCockpitSound(SOUND_TCASCLIMB, "Sounds\\VMU\\TCAS\\climb.mp3", force, &game->config.soundConfigComputer);
4377 LoadCockpitSound(SOUND_TCASDESCEND, "Sounds\\VMU\\TCAS\\descend.mp3", force, &game->config.soundConfigComputer);
4378 LoadCockpitSound(SOUND_TCASINCREASECLIMB, "Sounds\\VMU\\TCAS\\IncreaseClimb.wav", force, &game->config.soundConfigComputer);
4379 LoadCockpitSound(SOUND_TCASINCREASEDESCENT, "Sounds\\VMU\\TCAS\\IncreaseDescent.wav", force, &game->config.soundConfigComputer);
4380 LoadCockpitSound(SOUND_TCASREDUCECLIMB, "Sounds\\VMU\\TCAS\\ReduceClimb.wav", force, &game->config.soundConfigComputer);
4381 LoadCockpitSound(SOUND_TCASREDUCEDESCENT, "Sounds\\VMU\\TCAS\\ReduceDescent.wav", force, &game->config.soundConfigComputer);
4382 LoadCockpitSound(SOUND_TCASCLIMBNOW, "Sounds\\VMU\\TCAS\\ClimbClimbNow.wav", force, &game->config.soundConfigComputer);
4383 LoadCockpitSound(SOUND_TCASDESCENDNOW, "Sounds\\VMU\\TCAS\\DescendDescendNow.wav", force, &game->config.soundConfigComputer);
4384 LoadCockpitSound(SOUND_TCASMAINTAIN, "Sounds\\VMU\\TCAS\\MaintainVerticalSpeedMaintain.wav", force, &game->config.soundConfigComputer);
4385 LoadCockpitSound(SOUND_TCASADJUST, "Sounds\\VMU\\TCAS\\AdjustVerticalSpeedAdjust.wav", force, &game->config.soundConfigComputer);
4386 LoadCockpitSound(SOUND_TCASMONITOR, "Sounds\\VMU\\TCAS\\monitorverticalspeed.mp3", force, &game->config.soundConfigComputer);
4387 LoadCockpitSound(SOUND_TCASCROSSING, "Sounds\\VMU\\TCAS\\Crossing.wav", force, &game->config.soundConfigComputer);
4388 LoadCockpitSound(SOUND_TCASCLEAR, "Sounds\\VMU\\TCAS\\clearofconflict.mp3", force, &game->config.soundConfigComputer);
4389 LoadCockpitSound(SOUND_TCASTESTOK, "Sounds\\VMU\\TCAS\\TcasSystemTestOk.wav", force, &game->config.soundConfigComputer);
4390
4391 LoadCockpitSound(SOUND_MONROECARGOBAY, "Sounds\\VMU\\monroe-tiaditcb.mp3", force, &game->config.soundConfigComputer);
4392 LoadCockpitSound(SOUND_MONROEALLMOORINGSCLEARED, "Sounds\\VMU\\monroe-amc.mp3", force, &game->config.soundConfigComputer);
4393 LoadCockpitSound(SOUND_MONROEGEARDOWN, "Sounds\\VMU\\monroe-geardown.mp3", force, &game->config.soundConfigComputer);
4394 LoadCockpitSound(SOUND_MONROEHULLIONIZATION, "Sounds\\VMU\\monroe-hid.mp3", force, &game->config.soundConfigComputer);
4395 LoadCockpitSound(SOUND_MONROESOUNDBARRIER, "Sounds\\VMU\\monroe-psb.mp3", force, &game->config.soundConfigComputer);
4396 LoadCockpitSound(SOUND_CONFIGBRAKE, "Sounds\\VMU\\config-brake.mp3", force, &game->config.soundConfigComputer);
4397 LoadCockpitSound(SOUND_CONFIGAF, "Sounds\\VMU\\config-af.mp3", force, &game->config.soundConfigComputer);
4398 LoadCockpitSound(SOUND_CONFIGLANDINGGEAR, ourcockpit.spaceCapable ? "Sounds\\VMU\\config-landing-gear.mp3" : nullptr, force, &game->config.soundConfigComputer);
4399 LoadCockpitSound(SOUND_CONFIGFLAPS, "Sounds\\VMU\\config-flaps.mp3", force, &game->config.soundConfigComputer);
4400 LoadCockpitSound(SOUND_CONFIGTRIM, "Sounds\\VMU\\config-trim.mp3", force, &game->config.soundConfigComputer);
4401 LoadCockpitSound(SOUND_CONFIGSPOILERS, "Sounds\\VMU\\config-spoilers.mp3", force, &game->config.soundConfigComputer);
4402 LoadCockpitSound(SOUND_AURALUNITOKAY, "Sounds\\VMU\\AuralUnitOkay.mp3", force, &game->config.soundConfigComputer);
4403 LoadCockpitSound(SOUND_AURALUNITTESTA, "Sounds\\VMU\\AuralWarningTestA.mp3", force, &game->config.soundConfigComputer);
4404 LoadCockpitSound(SOUND_AURALUNITTESTB, "Sounds\\VMU\\AuralWarningTestB.mp3", force, &game->config.soundConfigComputer);
4405 LoadCockpitSound(SOUND_SCANNERSYNC, "Sounds\\VMU\\ScannerSync.mp3", force, &game->config.soundConfigComputer);
4406 LoadCockpitSound(SOUND_FORWARDTHRUST, "Sounds\\VMU\\ForwardThrust.mp3", force, &game->config.soundConfigComputer);
4407 LoadCockpitSound(SOUND_REVERSETHRUST, "Sounds\\VMU\\ReverseThrust.mp3", force, &game->config.soundConfigComputer);
4408 LoadCockpitSound(SOUND_CABINPRESSURE, "Sounds\\VMU\\CabinPressure.mp3", force, &game->config.soundConfigComputer);
4409 LoadCockpitSound(SOUND_GEARDISAGREE, "Sounds\\VMU\\GearDisagree.mp3", force, &game->config.soundConfigComputer);
4410 LoadCockpitSound(SOUND_AIRSPEEDALIVE, "Sounds\\VMU\\AirspeedAlive.mp3", force, &game->config.soundConfigComputer);
4411 LoadCockpitSound(SOUND_V1, "Sounds\\VMU\\V1.mp3", force, &game->config.soundConfigComputer);
4412 LoadCockpitSound(SOUND_V2, "Sounds\\VMU\\V2.mp3", force, &game->config.soundConfigComputer);
4413 LoadCockpitSound(SOUND_INTRANSIT, "Sounds\\VMU\\InTransit.mp3", force, &game->config.soundConfigComputer);
4414 LoadCockpitSound(SOUND_LOCALIZERALIVE, "Sounds\\VMU\\LocalizerAlive.mp3", force, &game->config.soundConfigComputer);
4415 LoadCockpitSound(SOUND_LOCALIZERCAPTURED, "Sounds\\VMU\\LocalizerCaptured.mp3", force, &game->config.soundConfigComputer);
4416 LoadCockpitSound(SOUND_GLIDESLOPEALIVE, "Sounds\\VMU\\GlideslopeAlive.mp3", force, &game->config.soundConfigComputer);
4417 LoadCockpitSound(SOUND_GLIDESLOPECAPTURED, "Sounds\\VMU\\GlideslopeCaptured.mp3", force, &game->config.soundConfigComputer);
4418 break;
4419
4421 LoadCockpitSound(SOUND_COCKPITAMBIENT, "Sounds\\Cockpits\\Apartment.wav", force);
4425 LoadCockpitSound(SOUND_COCKPITSTART, nullptr, force);
4426 LoadCockpitSound(SOUND_COCKPITLAND, "Sounds\\People\\step2.wav", force);
4427 LoadCockpitSound(SOUND_COCKPITLEVEL, nullptr, force);
4429 LoadCockpitSound(SOUND_PROP1, nullptr, force);
4430 LoadCockpitSound(SOUND_PROP2, nullptr, force);
4431 LoadCockpitSound(SOUND_PROP3, nullptr, force);
4432 LoadCockpitSound(SOUND_PROP4, nullptr, force);
4433 LoadCockpitSound(SOUND_PROP5, nullptr, force);
4434 LoadCockpitSound(SOUND_PROP6, nullptr, force);
4435
4439
4469
4485
4512 break;
4513
4515 LoadCockpitSound(SOUND_COCKPITAMBIENT, "Sounds\\Cockpits\\ControlTower.wav", force);
4519 LoadCockpitSound(SOUND_COCKPITSTART, nullptr, force);
4520 LoadCockpitSound(SOUND_COCKPITLAND, "Sounds\\People\\step3.wav", force);
4521 LoadCockpitSound(SOUND_COCKPITLEVEL, nullptr, force);
4523 LoadCockpitSound(SOUND_PROP1, nullptr, force);
4524 LoadCockpitSound(SOUND_PROP2, nullptr, force);
4525 LoadCockpitSound(SOUND_PROP3, nullptr, force);
4526 LoadCockpitSound(SOUND_PROP4, nullptr, force);
4527 LoadCockpitSound(SOUND_PROP5, nullptr, force);
4528 LoadCockpitSound(SOUND_PROP6, nullptr, force);
4529
4533
4563
4579
4606 break;
4607
4609 LoadCockpitSound(SOUND_COCKPITAMBIENT, "Sounds\\Cockpits\\Hangar.wav", force);
4613 LoadCockpitSound(SOUND_COCKPITSTART, nullptr, force);
4614 LoadCockpitSound(SOUND_COCKPITLAND, "Sounds\\People\\step4.wav", force);
4615 LoadCockpitSound(SOUND_COCKPITLEVEL, nullptr, force);
4617 LoadCockpitSound(SOUND_PROP1, nullptr, force);
4618 LoadCockpitSound(SOUND_PROP2, nullptr, force);
4619 LoadCockpitSound(SOUND_PROP3, nullptr, force);
4620 LoadCockpitSound(SOUND_PROP4, nullptr, force);
4621 LoadCockpitSound(SOUND_PROP5, nullptr, force);
4622 LoadCockpitSound(SOUND_PROP6, nullptr, force);
4623
4627
4657
4673
4700 break;
4701
4703 LoadCockpitSound(SOUND_COCKPITAMBIENT, "Sounds\\Cockpits\\Simbay.wav", force);
4704 LoadCockpitSound(SOUND_COCKPITENGINELEFT, "Sounds\\Cockpits\\Stewart.wav", force);
4705 LoadCockpitSound(SOUND_COCKPITENGINERIGHT, "Sounds\\Cockpits\\Stewart.wav", force);
4706 LoadCockpitSound(SOUND_COCKPITENGINECENTER, "Sounds\\Cockpits\\Stewart.wav", force);
4707 LoadCockpitSound(SOUND_COCKPITSTART, nullptr, force);
4708 LoadCockpitSound(SOUND_COCKPITLAND, "Sounds\\People\\step1.wav", force);
4709 LoadCockpitSound(SOUND_COCKPITLEVEL, nullptr, force);
4711 LoadCockpitSound(SOUND_PROP1, nullptr, force);
4712 LoadCockpitSound(SOUND_PROP2, nullptr, force);
4713 LoadCockpitSound(SOUND_PROP3, nullptr, force);
4714 LoadCockpitSound(SOUND_PROP4, nullptr, force);
4715 LoadCockpitSound(SOUND_PROP5, nullptr, force);
4716 LoadCockpitSound(SOUND_PROP6, nullptr, force);
4717
4721
4751
4767
4794 break;
4795
4796 case VehicleType::T19:
4797 LoadCockpitSound(SOUND_COCKPITAMBIENT, "Sounds\\Cockpits\\cockpit t-1.wav", force);
4798 LoadCockpitSound(SOUND_COCKPITENGINELEFT, "Sounds\\Cockpits\\engine t-1.wav", force);
4799 LoadCockpitSound(SOUND_COCKPITENGINERIGHT, "Sounds\\Cockpits\\engine t-1.wav", force);
4801 LoadCockpitSound(SOUND_COCKPITSTART, "Sounds\\Cockpits\\startup t-1.wav", force);
4802 LoadCockpitSound(SOUND_COCKPITLAND, "Sounds\\Cockpits\\cmtouch1.wav", force);
4803 LoadCockpitSound(SOUND_COCKPITLEVEL, "Sounds\\Cockpits\\cmtouch2.wav", force);
4804 LoadCockpitSound(SOUND_WINDSHIELDWIPERS, "Sounds\\Cockpits\\wipers.wav", force);
4805 LoadCockpitSound(SOUND_PROP1, nullptr, force);
4806 LoadCockpitSound(SOUND_PROP2, nullptr, force);
4807 LoadCockpitSound(SOUND_PROP3, nullptr, force);
4808 LoadCockpitSound(SOUND_PROP4, nullptr, force);
4809 LoadCockpitSound(SOUND_PROP5, nullptr, force);
4810 LoadCockpitSound(SOUND_PROP6, nullptr, force);
4811
4813 LoadCockpitSound(SOUND_STALL, "Sounds\\VMU\\stall.mp3", force, &game->config.soundConfigComputer);
4814 LoadCockpitSound(SOUND_OVERSPEED, "Sounds\\VMU\\overspeed.mp3", force, &game->config.soundConfigComputer);
4815
4816 LoadCockpitSound(SOUND_GPWSSINKRATE, "Sounds\\VMU\\GPWS\\monroe-sr.mp3", force, &game->config.soundConfigComputer);
4817 LoadCockpitSound(SOUND_GPWSPULLUP, "Sounds\\VMU\\GPWS\\monroe-pu.mp3", force, &game->config.soundConfigComputer);
4818 LoadCockpitSound(SOUND_TA_PULLUP, "Sounds\\VMU\\GPWS\\PullUp.mp3", force, &game->config.soundConfigComputer);
4819 LoadCockpitSound(SOUND_GPWSTERRAINTERRAIN, "Sounds\\VMU\\GPWS\\TerrainTerrain.mp3", force, &game->config.soundConfigComputer);
4820 LoadCockpitSound(SOUND_GPWSTERRAIN, "Sounds\\VMU\\GPWS\\Terrain.mp3", force, &game->config.soundConfigComputer);
4821 LoadCockpitSound(SOUND_GPWSTOOLOWTERRAIN, "Sounds\\VMU\\GPWS\\TooLowTerrain.mp3", force, &game->config.soundConfigComputer);
4822 LoadCockpitSound(SOUND_GPWSTOOLOWGEAR, "Sounds\\VMU\\GPWS\\TooLowGear.mp3", force, &game->config.soundConfigComputer);
4823 LoadCockpitSound(SOUND_GPWSTOOLOWFLAPS, "Sounds\\VMU\\GPWS\\TooLowFlaps.mp3", force, &game->config.soundConfigComputer);
4824 LoadCockpitSound(SOUND_GPWSBANKANGLE, "Sounds\\VMU\\GPWS\\BankAngle.wav", force, &game->config.soundConfigComputer);
4825 LoadCockpitSound(SOUND_GPWSGLIDESLOPE, "Sounds\\VMU\\GPWS\\Glideslope.wav", force, &game->config.soundConfigComputer);
4826 LoadCockpitSound(SOUND_GPWSRETARD, "Sounds\\VMU\\GPWS\\Retard.wav", force, &game->config.soundConfigComputer);
4827 LoadCockpitSound(SOUND_GPWSTEN, "Sounds\\VMU\\GPWS\\10.wav", force, &game->config.soundConfigComputer);
4828 LoadCockpitSound(SOUND_GPWSTWENTY, "Sounds\\VMU\\GPWS\\20.wav", force, &game->config.soundConfigComputer);
4829 LoadCockpitSound(SOUND_GPWSTHIRTY, "Sounds\\VMU\\GPWS\\30.wav", force, &game->config.soundConfigComputer);
4830 LoadCockpitSound(SOUND_GPWSFORTY, "Sounds\\VMU\\GPWS\\40.wav", force, &game->config.soundConfigComputer);
4831 LoadCockpitSound(SOUND_GPWSFIFTY, "Sounds\\VMU\\GPWS\\50.wav", force, &game->config.soundConfigComputer);
4832 LoadCockpitSound(SOUND_GPWSONEHUNDRED, "Sounds\\VMU\\GPWS\\100.wav", force, &game->config.soundConfigComputer);
4833 LoadCockpitSound(SOUND_GPWSTWOHUNDRED, "Sounds\\VMU\\GPWS\\200.wav", force, &game->config.soundConfigComputer);
4834 LoadCockpitSound(SOUND_GPWSMINIMUMS, "Sounds\\VMU\\GPWS\\Minimums.wav", force, &game->config.soundConfigComputer);
4835 LoadCockpitSound(SOUND_GPWSFIVEHUNDRED, "Sounds\\VMU\\GPWS\\500.wav", force, &game->config.soundConfigComputer);
4836 LoadCockpitSound(SOUND_GPWSONETHOUSAND, "Sounds\\VMU\\GPWS\\1000.wav", force, &game->config.soundConfigComputer);
4837 LoadCockpitSound(SOUND_GPWSDONTSINK, "Sounds\\VMU\\GPWS\\DontSink.mp3", force, &game->config.soundConfigComputer);
4838 LoadCockpitSound(SOUND_GPWSPOSITIVERATE, "Sounds\\VMU\\GPWS\\PositiveRate.mp3", force, &game->config.soundConfigComputer);
4839 LoadCockpitSound(SOUND_GPWSWINDSHEARWARNING, "Sounds\\VMU\\GPWS\\WindshearWarning.wav", force, &game->config.soundConfigComputer);
4840 LoadCockpitSound(SOUND_GPWSWINDSHEARCAUTION, "Sounds\\VMU\\GPWS\\WindshearCaution.mp3", force, &game->config.soundConfigComputer);
4841 LoadCockpitSound(SOUND_GPWSROTATE, "Sounds\\VMU\\GPWS\\Rotate.mp3", force, &game->config.soundConfigComputer);
4842 LoadCockpitSound(SOUND_TA_CAUTION_TERRAIN, "Sounds\\VMU\\GPWS\\CautionTerrain.mp3", force, &game->config.soundConfigComputer);
4843 LoadCockpitSound(SOUND_TA_CAUTION_OBSTACLE, "Sounds\\VMU\\GPWS\\CautionObstacle.mp3", force, &game->config.soundConfigComputer);
4844 LoadCockpitSound(SOUND_TA_OBSTACLE_WARNING, "Sounds\\VMU\\GPWS\\ObstacleObstacle.mp3", force, &game->config.soundConfigComputer);
4845
4846 LoadCockpitSound(SOUND_TCASTRAFFIC, "Sounds\\VMU\\TCAS\\traffic.mp3", force, &game->config.soundConfigComputer);
4847 LoadCockpitSound(SOUND_TCASCLIMB, "Sounds\\VMU\\TCAS\\climb.mp3", force, &game->config.soundConfigComputer);
4848 LoadCockpitSound(SOUND_TCASDESCEND, "Sounds\\VMU\\TCAS\\descend.mp3", force, &game->config.soundConfigComputer);
4849 LoadCockpitSound(SOUND_TCASINCREASECLIMB, "Sounds\\VMU\\TCAS\\IncreaseClimb.wav", force, &game->config.soundConfigComputer);
4850 LoadCockpitSound(SOUND_TCASINCREASEDESCENT, "Sounds\\VMU\\TCAS\\IncreaseDescent.wav", force, &game->config.soundConfigComputer);
4851 LoadCockpitSound(SOUND_TCASREDUCECLIMB, "Sounds\\VMU\\TCAS\\ReduceClimb.wav", force, &game->config.soundConfigComputer);
4852 LoadCockpitSound(SOUND_TCASREDUCEDESCENT, "Sounds\\VMU\\TCAS\\ReduceDescent.wav", force, &game->config.soundConfigComputer);
4853 LoadCockpitSound(SOUND_TCASCLIMBNOW, "Sounds\\VMU\\TCAS\\ClimbClimbNow.wav", force, &game->config.soundConfigComputer);
4854 LoadCockpitSound(SOUND_TCASDESCENDNOW, "Sounds\\VMU\\TCAS\\DescendDescendNow.wav", force, &game->config.soundConfigComputer);
4855 LoadCockpitSound(SOUND_TCASMAINTAIN, "Sounds\\VMU\\TCAS\\MaintainVerticalSpeedMaintain.wav", force, &game->config.soundConfigComputer);
4856 LoadCockpitSound(SOUND_TCASADJUST, "Sounds\\VMU\\TCAS\\AdjustVerticalSpeedAdjust.wav", force, &game->config.soundConfigComputer);
4857 LoadCockpitSound(SOUND_TCASMONITOR, "Sounds\\VMU\\TCAS\\monitorverticalspeed.mp3", force, &game->config.soundConfigComputer);
4858 LoadCockpitSound(SOUND_TCASCROSSING, "Sounds\\VMU\\TCAS\\Crossing.wav", force, &game->config.soundConfigComputer);
4859 LoadCockpitSound(SOUND_TCASCLEAR, "Sounds\\VMU\\TCAS\\clearofconflict.mp3", force, &game->config.soundConfigComputer);
4860 LoadCockpitSound(SOUND_TCASTESTOK, "Sounds\\VMU\\TCAS\\TcasSystemTestOk.wav", force, &game->config.soundConfigComputer);
4861
4862 LoadCockpitSound(SOUND_MONROECARGOBAY, "Sounds\\VMU\\monroe-tiaditcb.mp3", force, &game->config.soundConfigComputer);
4863 LoadCockpitSound(SOUND_MONROEALLMOORINGSCLEARED, "Sounds\\VMU\\monroe-amc.mp3", force, &game->config.soundConfigComputer);
4864 LoadCockpitSound(SOUND_MONROEGEARDOWN, "Sounds\\VMU\\monroe-geardown.mp3", force, &game->config.soundConfigComputer);
4865 LoadCockpitSound(SOUND_MONROEHULLIONIZATION, "Sounds\\VMU\\monroe-hid.mp3", force, &game->config.soundConfigComputer);
4866 LoadCockpitSound(SOUND_MONROESOUNDBARRIER, "Sounds\\VMU\\monroe-psb.mp3", force, &game->config.soundConfigComputer);
4867 LoadCockpitSound(SOUND_CONFIGBRAKE, "Sounds\\VMU\\config-brake.mp3", force, &game->config.soundConfigComputer);
4868 LoadCockpitSound(SOUND_CONFIGAF, "Sounds\\VMU\\config-af.mp3", force, &game->config.soundConfigComputer);
4869 LoadCockpitSound(SOUND_CONFIGLANDINGGEAR, ourcockpit.spaceCapable ? "Sounds\\VMU\\config-landing-gear.mp3" : nullptr, force, &game->config.soundConfigComputer);
4870 LoadCockpitSound(SOUND_CONFIGFLAPS, "Sounds\\VMU\\config-flaps.mp3", force, &game->config.soundConfigComputer);
4871 LoadCockpitSound(SOUND_CONFIGTRIM, "Sounds\\VMU\\config-trim.mp3", force, &game->config.soundConfigComputer);
4872 LoadCockpitSound(SOUND_CONFIGSPOILERS, "Sounds\\VMU\\config-spoilers.mp3", force, &game->config.soundConfigComputer);
4873 LoadCockpitSound(SOUND_AURALUNITOKAY, "Sounds\\VMU\\AuralUnitOkay.mp3", force, &game->config.soundConfigComputer);
4874 LoadCockpitSound(SOUND_AURALUNITTESTA, "Sounds\\VMU\\AuralWarningTestA.mp3", force, &game->config.soundConfigComputer);
4875 LoadCockpitSound(SOUND_AURALUNITTESTB, "Sounds\\VMU\\AuralWarningTestB.mp3", force, &game->config.soundConfigComputer);
4876 LoadCockpitSound(SOUND_SCANNERSYNC, "Sounds\\VMU\\ScannerSync.mp3", force, &game->config.soundConfigComputer);
4877 LoadCockpitSound(SOUND_FORWARDTHRUST, "Sounds\\VMU\\ForwardThrust.mp3", force, &game->config.soundConfigComputer);
4878 LoadCockpitSound(SOUND_REVERSETHRUST, "Sounds\\VMU\\ReverseThrust.mp3", force, &game->config.soundConfigComputer);
4879 LoadCockpitSound(SOUND_CABINPRESSURE, "Sounds\\VMU\\CabinPressure.mp3", force, &game->config.soundConfigComputer);
4880 LoadCockpitSound(SOUND_GEARDISAGREE, "Sounds\\VMU\\GearDisagree.mp3", force, &game->config.soundConfigComputer);
4881 LoadCockpitSound(SOUND_AIRSPEEDALIVE, "Sounds\\VMU\\AirspeedAlive.mp3", force, &game->config.soundConfigComputer);
4882 LoadCockpitSound(SOUND_V1, "Sounds\\VMU\\V1.mp3", force, &game->config.soundConfigComputer);
4883 LoadCockpitSound(SOUND_V2, "Sounds\\VMU\\V2.mp3", force, &game->config.soundConfigComputer);
4884 LoadCockpitSound(SOUND_INTRANSIT, "Sounds\\VMU\\InTransit.mp3", force, &game->config.soundConfigComputer);
4885 LoadCockpitSound(SOUND_LOCALIZERALIVE, "Sounds\\VMU\\LocalizerAlive.mp3", force, &game->config.soundConfigComputer);
4886 LoadCockpitSound(SOUND_LOCALIZERCAPTURED, "Sounds\\VMU\\LocalizerCaptured.mp3", force, &game->config.soundConfigComputer);
4887 LoadCockpitSound(SOUND_GLIDESLOPEALIVE, "Sounds\\VMU\\GlideslopeAlive.mp3", force, &game->config.soundConfigComputer);
4888 LoadCockpitSound(SOUND_GLIDESLOPECAPTURED, "Sounds\\VMU\\GlideslopeCaptured.mp3", force, &game->config.soundConfigComputer);
4889 break;
4890
4891 case VehicleType::T27:
4892 LoadCockpitSound(SOUND_COCKPITAMBIENT, "Sounds\\Cockpits\\MammothAmbient.wav", force);
4893 LoadCockpitSound(SOUND_COCKPITENGINELEFT, "Sounds\\Cockpits\\MammothRun.wav", force);
4894 LoadCockpitSound(SOUND_COCKPITENGINERIGHT, "Sounds\\Cockpits\\MammothRun.wav", force);
4896 LoadCockpitSound(SOUND_COCKPITSTART, "Sounds\\Cockpits\\MammothStart.wav", force);
4897 LoadCockpitSound(SOUND_COCKPITLAND, "Sounds\\Cockpits\\cmtouch1.wav", force);
4898 LoadCockpitSound(SOUND_COCKPITLEVEL, "Sounds\\Cockpits\\cmtouch2.wav", force);
4899 LoadCockpitSound(SOUND_WINDSHIELDWIPERS, "Sounds\\Cockpits\\wipers.wav", force);
4900 LoadCockpitSound(SOUND_PROP1, nullptr, force);
4901 LoadCockpitSound(SOUND_PROP2, nullptr, force);
4902 LoadCockpitSound(SOUND_PROP3, nullptr, force);
4903 LoadCockpitSound(SOUND_PROP4, nullptr, force);
4904 LoadCockpitSound(SOUND_PROP5, nullptr, force);
4905 LoadCockpitSound(SOUND_PROP6, nullptr, force);
4906
4907 LoadCockpitSound(SOUND_COCKPITLOWFUEL, "Sounds\\Cockpits\\MammothChime.wav", force, &game->config.soundConfigComputer);
4910
4940
4956
4983 break;
4984
4986 LoadCockpitSound(SOUND_COCKPITAMBIENT, "Sounds\\Cockpits\\HelmetAmbient.wav", force);
4990 LoadCockpitSound(SOUND_COCKPITSTART, nullptr, force);
4991 LoadCockpitSound(SOUND_COCKPITLAND, nullptr, force);
4992 LoadCockpitSound(SOUND_COCKPITLEVEL, nullptr, force);
4994 LoadCockpitSound(SOUND_PROP1, nullptr, force);
4995 LoadCockpitSound(SOUND_PROP2, nullptr, force);
4996 LoadCockpitSound(SOUND_PROP3, nullptr, force);
4997 LoadCockpitSound(SOUND_PROP4, nullptr, force);
4998 LoadCockpitSound(SOUND_PROP5, nullptr, force);
4999 LoadCockpitSound(SOUND_PROP6, nullptr, force);
5000
5004
5034
5050
5077 break;
5078
5080 LoadCockpitSound(SOUND_COCKPITAMBIENT, "Sounds\\Cockpits\\Estate.wav", force);
5084 LoadCockpitSound(SOUND_COCKPITSTART, nullptr, force);
5085 LoadCockpitSound(SOUND_COCKPITLAND, "Sounds\\People\\step4.wav", force);
5086 LoadCockpitSound(SOUND_COCKPITLEVEL, nullptr, force);
5088 LoadCockpitSound(SOUND_PROP1, nullptr, force);
5089 LoadCockpitSound(SOUND_PROP2, nullptr, force);
5090 LoadCockpitSound(SOUND_PROP3, nullptr, force);
5091 LoadCockpitSound(SOUND_PROP4, nullptr, force);
5092 LoadCockpitSound(SOUND_PROP5, nullptr, force);
5093 LoadCockpitSound(SOUND_PROP6, nullptr, force);
5094
5098
5128
5144
5171 break;
5172
5173 default:
5174 // here we would decipher the interiors
5175 LoadCockpitSound(SOUND_COCKPITAMBIENT, nullptr, force);
5179 LoadCockpitSound(SOUND_COCKPITSTART, nullptr, force);
5180 LoadCockpitSound(SOUND_COCKPITLAND, nullptr, force);
5181 LoadCockpitSound(SOUND_COCKPITLEVEL, nullptr, force);
5183 LoadCockpitSound(SOUND_PROP1, nullptr, force);
5184 LoadCockpitSound(SOUND_PROP2, nullptr, force);
5185 LoadCockpitSound(SOUND_PROP3, nullptr, force);
5186 LoadCockpitSound(SOUND_PROP4, nullptr, force);
5187 LoadCockpitSound(SOUND_PROP5, nullptr, force);
5188 LoadCockpitSound(SOUND_PROP6, nullptr, force);
5189
5193
5223
5239
5266
5267 char msg[99];
5268 sprintf_s(msg, sizeof msg, "Unsupported interior frame: %i", ourcockpit.texturelib);
5270 break;
5271 }
5272
5273 if (playerships[0].isSimulator)
5274 delayedeffects.clear();
5275}
5276
5277void Sound::LoadCustomSound(SOUNDS sound_enum, const char* path, SoundConfig* device)
5278{
5279 sound_path[sound_enum] = path;
5280 LoadSound(sound_enum, device);
5281}
SCRIPT_CONTROL SCRIPT_STATE const void SCRIPT_CONTROL SCRIPT_STATE const int SCRIPT_TABDEF const BYTE SCRIPT_STRING_ANALYSIS BOOL
SCRIPT_CONTROL SCRIPT_STATE const void DWORD
GameState
Definition GameState.h:4
@ STATUS_LOADING
Definition GameState.h:8
@ STATUS_GAME
Definition GameState.h:9
@ STATUS_CREATE
Definition GameState.h:7
@ STATUS_LOGIN
Definition GameState.h:6
@ STATUS_SPLASH
Definition GameState.h:5
const GUID MYGUID_DEFAULT
Definition Guids.h:5
const GUID MYGUID_NULL
Definition Guids.h:3
constexpr auto Clamp(T1 val, T2 min, T3 max)
@ EVENT_RADIO
Definition Networking.h:38
@ ARJ_ENUM
Definition ServerTypes.h:79
@ W6Manx
Definition ServerTypes.h:84
@ Hangar
Definition ServerTypes.h:90
@ EVA_SUIT
Definition ServerTypes.h:69
@ C98
Definition ServerTypes.h:61
@ ControlTower
Definition ServerTypes.h:86
@ C2
Definition ServerTypes.h:66
@ C2A
Definition ServerTypes.h:81
@ T19
Definition ServerTypes.h:87
@ P13
Definition ServerTypes.h:64
@ Apartment
Definition ServerTypes.h:80
@ ARJ_PAX
Definition ServerTypes.h:70
@ E10
Definition ServerTypes.h:63
@ T120
Definition ServerTypes.h:67
@ T27
Definition ServerTypes.h:82
@ E11
Definition ServerTypes.h:68
@ SimBay
Definition ServerTypes.h:85
@ A4
Definition ServerTypes.h:65
@ T121
Definition ServerTypes.h:89
@ Estate
Definition ServerTypes.h:91
#define MAX_ONLINEPLAYERS
#define MAX_SCAN
PlotType
@ DeoisIndustrial
@ NorthPole
@ UserFarming
@ UserMining
@ UserRefinery
@ NotZoned
@ REF_BUILDING
Definition ServerTypes.h:46
@ REF_ACLMODE
Definition ServerTypes.h:44
@ REF_DOCKENUMCPOC
Definition ServerTypes.h:53
@ REF_INANOTHER
Definition ServerTypes.h:45
@ REF_APNMODE
Definition ServerTypes.h:42
@ REF_ONGROUND
Definition ServerTypes.h:43
SOUNDS
Definition Sound.h:23
@ SOUND_CYCLETARGET
Definition Sound.h:173
@ SOUND_AIRSPEEDALIVE
Definition Sound.h:106
@ SOUND_SHORE
Definition Sound.h:223
@ SOUND_RAINAIRRUSH
Definition Sound.h:34
@ SOUND_GPWSTOOLOWFLAPS
Definition Sound.h:49
@ SOUND_GPWSTHIRTY
Definition Sound.h:55
@ SOUND_INTRANSIT
Definition Sound.h:109
@ SOUND_PRECIP0
Definition Sound.h:137
@ SOUND_TCASDESCENDNOW
Definition Sound.h:82
@ SOUND_DOCK
Definition Sound.h:207
@ SOUND_OVERSPEED
Definition Sound.h:42
@ SOUND_GPWSPOSITIVERATE
Definition Sound.h:65
@ SOUND_CONFIGAF
Definition Sound.h:94
@ SOUND_PROP1
Definition Sound.h:35
@ SOUND_GROUNDSCRAPELOOP
Definition Sound.h:269
@ SOUND_BACKUP
Definition Sound.h:261
@ SOUND_BOARDING
Definition Sound.h:182
@ SOUND_COCKPITENGINERIGHT
Definition Sound.h:31
@ SOUND_TCASTESTOK
Definition Sound.h:88
@ SOUND_DOCKANNOUNCE2
Definition Sound.h:193
@ SOUND_HIGHBYPASS
Definition Sound.h:216
@ SOUND_GEARRETRACT
Definition Sound.h:213
@ SOUND_CLIMBING10K
Definition Sound.h:184
@ SOUND_EXPLODERING
Definition Sound.h:303
@ SOUND_WIND_MIC
Definition Sound.h:143
@ SOUND_CONFIGLANDINGGEAR
Definition Sound.h:98
@ SOUND_DOCKANNOUNCE3
Definition Sound.h:194
@ SOUND_TCASADJUST
Definition Sound.h:84
@ SOUND_GPWSDONTSINK
Definition Sound.h:64
@ SOUND_TA_CAUTION_OBSTACLE
Definition Sound.h:69
@ SOUND_GPWSFIVEHUNDRED
Definition Sound.h:61
@ SOUND_OPENAIR
Definition Sound.h:229
@ SOUND_HOLIDAY2026
Definition Sound.h:293
@ SOUND_APTRIMCLACKER
Definition Sound.h:169
@ SOUND_RADIOCARRIER11
Definition Sound.h:328
@ SOUND_POLICECHIRP
Definition Sound.h:267
@ SOUND_HOLIDAY2021
Definition Sound.h:292
@ SOUND_EARPOP2
Definition Sound.h:336
@ SOUND_DISTURBANCE
Definition Sound.h:190
@ SOUND_COCKPITSTART
Definition Sound.h:26
@ SOUND_EXPLODE2
Definition Sound.h:296
@ SOUND_AURALUNITOKAY
Definition Sound.h:114
@ SOUND_GPWSTEN
Definition Sound.h:53
@ SOUND_CONFIGSPOILERS
Definition Sound.h:97
@ SOUND_GLIDESLOPECAPTURED
Definition Sound.h:113
@ SOUND_WINDSHIELDWIPERS
Definition Sound.h:33
@ SOUND_UNDOCK
Definition Sound.h:208
@ SOUND_MONROEALLMOORINGSCLEARED
Definition Sound.h:91
@ SOUND_PROXIMITY
Definition Sound.h:175
@ SOUND_DOCKCHIME
Definition Sound.h:205
@ SOUND_TCASCLEAR
Definition Sound.h:87
@ SOUND_TCASTRAFFIC
Definition Sound.h:74
@ SOUND_CONFIGFLAPS
Definition Sound.h:95
@ SOUND_APCAVALRY
Definition Sound.h:171
@ SOUND_TCASREDUCEDESCENT
Definition Sound.h:80
@ SOUND_GPWSMINIMUMS
Definition Sound.h:60
@ SOUND_AIRBRAKEONMAMMOTH
Definition Sound.h:265
@ SOUND_APCCHORD
Definition Sound.h:172
@ SOUND_DESCENT
Definition Sound.h:186
@ SOUND_PROP2
Definition Sound.h:35
@ SOUND_TCASCLIMB
Definition Sound.h:75
@ SOUND_EARPOP3
Definition Sound.h:337
@ SOUND_AOA
Definition Sound.h:170
@ SOUND_INNERMARKER
Definition Sound.h:178
@ SOUND_TCASMONITOR
Definition Sound.h:85
@ SOUND_HORNMAMMOTH_START
Definition Sound.h:340
@ SOUND_COCKPITLOWFUEL
Definition Sound.h:40
@ SOUND_NONE
Definition Sound.h:24
@ SOUND_SONICBOOM
Definition Sound.h:238
@ SOUND_GLIDESLOPEALIVE
Definition Sound.h:112
@ SOUND_RADIOCUT1
Definition Sound.h:310
@ SOUND_MONROESOUNDBARRIER
Definition Sound.h:100
@ SOUND_DOCKANNOUNCE6
Definition Sound.h:197
@ SOUND_THUNDER_NEAR
Definition Sound.h:121
@ SOUND_MONROEGEARDOWN
Definition Sound.h:92
@ SOUND_COCKPITLEVEL
Definition Sound.h:29
@ SOUND_CARALARM
Definition Sound.h:272
@ SOUND_DEPLANING
Definition Sound.h:189
@ SOUND_OUTERMARKER
Definition Sound.h:176
@ SOUND_WIND
Definition Sound.h:142
@ SOUND_ALARMCHIRP
Definition Sound.h:273
@ SOUND_EXPLODEINT1
Definition Sound.h:300
@ SOUND_HOLIDAY
Definition Sound.h:167
@ SOUND_WLAND2
Definition Sound.h:254
@ SOUND_GPWSTOOLOWTERRAIN
Definition Sound.h:47
@ SOUND_MASTERWARNING
Definition Sound.h:179
@ SOUND_TCASCLIMBNOW
Definition Sound.h:81
@ SOUND_GPWSTOOLOWGEAR
Definition Sound.h:48
@ SOUND_HOLIDAY2019
Definition Sound.h:291
@ SOUND_DOCKANNOUNCE5
Definition Sound.h:196
@ SOUND_DOCKANNOUNCE8
Definition Sound.h:199
@ SOUND_TCASCROSSING
Definition Sound.h:86
@ SOUND_MONROEHULLIONIZATION
Definition Sound.h:99
@ SOUND_NEWSFLASH
Definition Sound.h:165
@ SOUND_TCASINCREASECLIMB
Definition Sound.h:77
@ SOUND_EXPLODEINT3
Definition Sound.h:302
@ SOUND_MIDDLEMARKER
Definition Sound.h:177
@ SOUND_GPWSTWOHUNDRED
Definition Sound.h:59
@ SOUND_GPWSBANKANGLE
Definition Sound.h:50
@ SOUND_DOCKANNOUNCE9
Definition Sound.h:200
@ SOUND_DOORCLOSE
Definition Sound.h:212
@ SOUND_STATIONIDLL
Definition Sound.h:330
@ SOUND_TEST
Definition Sound.h:146
@ SOUND_REFINERY
Definition Sound.h:226
@ SOUND_CRUISE
Definition Sound.h:185
@ SOUND_GPWSFORTY
Definition Sound.h:56
@ SOUND_FLAPMOTOR
Definition Sound.h:210
@ SOUND_MIDWAYTARGET
Definition Sound.h:174
@ SOUND_SPOILERWIND
Definition Sound.h:257
@ SOUND_SILVERBELLS
Definition Sound.h:227
@ SOUND_TCASREDUCECLIMB
Definition Sound.h:79
@ SOUND_STATIONIDCK
Definition Sound.h:332
@ SOUND_DOCKANNOUNCE4
Definition Sound.h:195
@ SOUND_LOCALIZERCAPTURED
Definition Sound.h:111
@ SOUND_BACKUPMAMMOTH
Definition Sound.h:264
@ SOUND_PROP6
Definition Sound.h:36
@ SOUND_GPWSPULLUP
Definition Sound.h:45
@ SOUND_GPWSGLIDESLOPE
Definition Sound.h:51
@ SOUND_COCKPITAMBIENT
Definition Sound.h:27
@ SOUND_AIRBRAKEOFFMAMMOTH
Definition Sound.h:266
@ SOUND_DOCKANNOUNCE11
Definition Sound.h:202
@ SOUND_AIRBRAKEOFF
Definition Sound.h:263
@ SOUND_EARPOP1
Definition Sound.h:335
@ SOUND_REVERSETHRUST
Definition Sound.h:103
@ SOUND_GPWSFIFTY
Definition Sound.h:57
@ SOUND_ROADNOISELOOP
Definition Sound.h:271
@ SOUND_V1
Definition Sound.h:107
@ SOUND_GROUNDSCRAPESTOP
Definition Sound.h:270
@ SOUND_SCANNERSYNC
Definition Sound.h:101
@ SOUND_ENUMERATION
Definition Sound.h:344
@ SOUND_GEARDISAGREE
Definition Sound.h:105
@ SOUND_TA_OBSTACLE_WARNING
Definition Sound.h:70
@ SOUND_GPWSROTATE
Definition Sound.h:63
@ SOUND_GEARWIND
Definition Sound.h:255
@ SOUND_SPEAKERPOP
Definition Sound.h:144
@ SOUND_MONROECARGOBAY
Definition Sound.h:90
@ SOUND_MASTERCAUTION
Definition Sound.h:180
@ SOUND_CABINPRESSURE
Definition Sound.h:104
@ SOUND_CONFIGBRAKE
Definition Sound.h:93
@ SOUND_TCASMAINTAIN
Definition Sound.h:83
@ SOUND_EAS
Definition Sound.h:228
@ SOUND_TCASDESCEND
Definition Sound.h:76
@ SOUND_DOCKING
Definition Sound.h:187
@ SOUND_GPWSRETARD
Definition Sound.h:52
@ SOUND_INDUSTRIAL
Definition Sound.h:225
@ SOUND_HEARTBEAT
Definition Sound.h:276
@ SOUND_PROP4
Definition Sound.h:36
@ SOUND_GPWSTWENTY
Definition Sound.h:54
@ SOUND_FORWARDTHRUST
Definition Sound.h:102
@ SOUND_TA_PULLUP
Definition Sound.h:72
@ SOUND_STATIONIDWM
Definition Sound.h:331
@ SOUND_GPWSWINDSHEARCAUTION
Definition Sound.h:67
@ SOUND_FARMING
Definition Sound.h:224
@ SOUND_MINING
Definition Sound.h:222
@ SOUND_DOOROPEN
Definition Sound.h:211
@ SOUND_HORNCAR_START
Definition Sound.h:339
@ SOUND_GPWSTERRAIN
Definition Sound.h:71
@ SOUND_WDEATH1
Definition Sound.h:240
@ SOUND_DOCKANNOUNCE1
Definition Sound.h:192
@ SOUND_THRUST
Definition Sound.h:268
@ SOUND_DOCKEVAC
Definition Sound.h:204
@ SOUND_AURALUNITTESTA
Definition Sound.h:38
@ SOUND_ECTO1_END
Definition Sound.h:342
@ SOUND_DOCKANNOUNCE12
Definition Sound.h:203
@ SOUND_DIHV
Definition Sound.h:219
@ SOUND_DOPPLER
Definition Sound.h:258
@ SOUND_PROP5
Definition Sound.h:36
@ SOUND_COCKPITENGINELEFT
Definition Sound.h:30
@ SOUND_COCKPITENGINECENTER
Definition Sound.h:32
@ SOUND_CONFIGTRIM
Definition Sound.h:96
@ SOUND_STALL
Definition Sound.h:41
@ SOUND_GEAREXTEND
Definition Sound.h:214
@ SOUND_GPWSONEHUNDRED
Definition Sound.h:58
@ SOUND_DOCKANNOUNCE7
Definition Sound.h:198
@ SOUND_FLAPWIND
Definition Sound.h:256
@ SOUND_V2
Definition Sound.h:108
@ SOUND_LOCALIZERALIVE
Definition Sound.h:110
@ SOUND_BEFORETAKEOFF
Definition Sound.h:183
@ SOUND_DOPPLER2
Definition Sound.h:259
@ SOUND_TCASINCREASEDESCENT
Definition Sound.h:78
@ SOUND_AURALUNITTESTB
Definition Sound.h:39
@ SOUND_GPWSWINDSHEARWARNING
Definition Sound.h:66
@ SOUND_GPWSTERRAINTERRAIN
Definition Sound.h:46
@ SOUND_DOCKANNOUNCE10
Definition Sound.h:201
@ SOUND_TA_CAUTION_TERRAIN
Definition Sound.h:68
@ SOUND_AIRBRAKEON
Definition Sound.h:262
@ SOUND_COCKPITLAND
Definition Sound.h:28
@ SOUND_HOLIDAY2018
Definition Sound.h:290
@ SOUND_GPWSONETHOUSAND
Definition Sound.h:62
@ SOUND_HORNMAMMOTH_END
Definition Sound.h:340
@ SOUND_PROP3
Definition Sound.h:35
@ SOUND_SHOCKWAVE
Definition Sound.h:304
@ SOUND_GPWSSINKRATE
Definition Sound.h:44
@ SOUND_LANDED
Definition Sound.h:188
@ SOUND_PRESSUREDUMP
Definition Sound.h:215
#define MIN_VOL
Definition Sound.h:18
#define MIN_VOL_DELTA
Definition Sound.h:17
float StaticAirPressureMb
Definition Bus.h:406
bool RevenuePassengers
Definition Bus.h:478
float Mach
Definition Bus.h:456
float EngineThrustOutput[MAX_ENGINES]
Definition Bus.h:54
float PressureDiffMb
Definition Bus.h:405
float DebugSoundClose
Definition Bus.h:551
RainAir::State RainAirStatus
Definition Bus.h:488
float DebugSoundReal
Definition Bus.h:551
float CabinPressureMb
Definition Bus.h:403
float DebugSoundBear
Definition Bus.h:551
float EngineThrustLever[MAX_ENGINES]
Definition Bus.h:357
float DebugSoundFake
Definition Bus.h:551
float IndicatedAirspeedKms
Definition Bus.h:34
short station
Definition Bus.h:506
float RadioAltitudeKm
Definition Bus.h:157
float ComputedVneKms
Definition Bus.h:38
std::vector< Command > commandStream
Definition Bus.h:442
float vmuHold
Definition Bus.h:507
SoundConfig soundConfigComms
Definition config.h:50
SoundConfig soundConfigLegacy
Definition config.h:51
SoundConfig soundConfigComputer
Definition config.h:49
bool g_bSoundIntroMusic
Definition config.h:18
SoundConfig soundConfigRadio
Definition config.h:52
bool Apply(HSTREAM stream)
Definition EarMuffle.h:118
bool SetAmount(float value)
Definition EarMuffle.h:92
void Remove(HSTREAM stream)
Definition EarMuffle.h:81
Playback Update(bool audible, unsigned int characterId, float seconds, bool popped)
float Muffle() const
Definition EarPressure.h:49
void Reset()
Definition EarPressure.h:41
bool Update(bool active, unsigned int characterId, float pressureMb, int age, int sex, float seconds, PopDiagnostics *diagnostics=nullptr)
Definition EarPressure.h:53
GameState displaystage
Definition GameClass.h:118
std::unique_ptr< Bus > bus
Definition GameClass.h:108
Config config
Definition GameClass.h:100
std::unique_ptr< HMI > GUI
Definition GameClass.h:106
std::unique_ptr< Networking > networking
Definition GameClass.h:103
static void TouchFile(const WCHAR *str)
std::unique_ptr< Viewscreen > viewscreen
Definition GameClass.h:107
std::unique_ptr< Logger > logger
Definition GameClass.h:109
void ToggleFullScreen(bool goFullScreen)
SPlayerData player[MAX_ONLINEPLAYERS]
Definition gui.h:1093
tm tm_time
Definition gui.h:1029
unsigned char ourplayerC
Definition gui.h:1094
void Log(const char *msg, Level level=Info, int errorCode=0)
Definition Logger.cpp:283
void AddToCallStack(const char *msg)
Definition Logger.cpp:355
Level
Definition Logger.h:23
@ Debug
Definition Logger.h:27
@ Info
Definition Logger.h:25
@ Warn
Definition Logger.h:26
@ Fatal
Definition Logger.h:29
@ Error
Definition Logger.h:28
void SendToServer(void *pData, DWORD dwSize, bool bGuaranteed, PacketOrdering order=ORDERING_NONE) const
void SendEvent(EventType eventType, float extent=0.0f) const
float currentPan
Definition Camera.h:12
bool outside
Definition Camera.h:17
float attenuate
Definition Camera.h:28
void FrameMoveHorns()
Definition Sound.cpp:1781
HSYNC hsync
Definition Sound.h:695
void AddDelayedSound(SOUNDS soundEnum, float delay, float volume=1.0f, float freq=1.0f, bool fromOutside=false)
Definition Sound.cpp:3376
void AddLoopingVehicleSound(SOUNDS soundEnum, unsigned char array)
Definition Sound.cpp:3405
char stationUrls[6][64]
Definition Sound.h:703
float exTimeToFadeIn
Definition Sound.h:648
void ChangeVolume(SoundConfig *config, float modVolume)
Definition Sound.cpp:551
float oldPan
Definition Sound.h:653
bool cabinLandingPending
Definition Sound.h:664
bool cabinPassengersActive
Definition Sound.h:665
PlotType ambtype1
Definition Sound.h:691
bool issuedWarning
Definition Sound.h:689
float cabinLandingConfirmationTime
Definition Sound.h:662
void Init()
Definition Sound.cpp:178
char metadata[999]
Definition Sound.h:637
EarPressure earPressure
Definition Sound.h:680
void Stop(SOUNDS soundEnum) const
Definition Sound.cpp:3397
void LoadSounds(short instage)
Definition Sound.cpp:2159
void StopCabinAnnouncements()
Definition Sound.cpp:3625
char sound_device[SOUND_ENUMERATION]
Definition Sound.h:387
int GetConfigSelectionIndex(const SoundConfig *deviceConfig) const
Definition Sound.cpp:155
bool sound_debug[SOUND_ENUMERATION]
Definition Sound.h:395
float sound_volume[SOUND_ENUMERATION]
Definition Sound.h:385
bool sound_fxEnabled[SOUND_ENUMERATION]
Definition Sound.h:392
void FrameMoveEarPressure(float elapsedTime)
Definition Sound.cpp:1717
HFX sound_fxLP[SOUND_ENUMERATION]
Definition Sound.h:390
bool cabinFlightEstablished
Definition Sound.h:663
char currentSoundDevice
Definition Sound.h:631
void ChangeVolume()
Definition Sound.cpp:789
float gaTimeToFadeIn
Definition Sound.h:646
float gaTimeToHold
Definition Sound.h:645
const float minrate
Definition Sound.h:376
void RemoveQueuedCabinAnnouncement(SOUNDS soundEnum)
Definition Sound.cpp:3568
char currentRadioDevice
Definition Sound.h:632
bool sound_fromOutside[SOUND_ENUMERATION]
Definition Sound.h:393
void PrecipWindSoundBarrier(RiseMath::Vector3 relativeWindTrueKms)
Definition Sound.cpp:3126
std::vector< std::string > sound_path
Definition Sound.h:397
void QueueCabinAnnouncement(SOUNDS soundEnum)
Definition Sound.cpp:3559
std::vector< Sloopingeffects > loopingeffects
Definition Sound.h:659
void InitDevice(SoundConfig *deviceConfig)
Definition Sound.cpp:204
GameClass * game
Definition Sound.h:374
std::vector< std::string > deviceNames
Definition Sound.h:705
SoundConfig * sound_config[SOUND_ENUMERATION]
Definition Sound.h:388
void FrameMoveVehicleSounds()
Definition Sound.cpp:766
void EnumDevices()
Definition Sound.cpp:91
HSTREAM radio
Definition Sound.h:378
bool sound_partOfHull[SOUND_ENUMERATION]
Definition Sound.h:394
float oldvolume
Definition Sound.h:653
void ApplyEarMuffle(HSTREAM stream)
Definition Sound.cpp:1672
float sound_length[SOUND_ENUMERATION]
Definition Sound.h:383
EarMuffleChannels earMuffleChannels
Definition Sound.h:681
static void CALLBACK AdvanceStage(HSYNC handle, DWORD channel, DWORD data, void *user)
Definition Sound.cpp:1246
void FrameMove(float elapsedTime)
Definition Sound.cpp:1901
void PlayCabinAnnouncement(SOUNDS sound_enum)
Definition Sound.cpp:3456
BOOL FreeStream(HSTREAM stream)
Definition Sound.cpp:1661
HSTREAM sound_stream[SOUND_ENUMERATION]
Definition Sound.h:381
HSTREAM GlassFX(SOUNDS soundEnum)
Definition Sound.cpp:829
void FrameMoveAAC()
Definition Sound.cpp:2424
HFX sound_fxShelf[SOUND_ENUMERATION]
Definition Sound.h:389
void FrameMoveDelayedEffects(float elapsedTime)
Definition Sound.cpp:2577
float gaTimer
Definition Sound.h:643
float exTimeToHold
Definition Sound.h:649
void RemoveLoopingVehicleSound(unsigned char array, SOUNDS soundEnum=SOUND_NONE)
Definition Sound.cpp:3428
bool passedSoundBarrierBoom
Definition Sound.h:656
float exTimeToFadeOut
Definition Sound.h:650
VehicleHorn::Playback hornPlayback[4]
Definition Sound.h:370
GameState musicstage
Definition Sound.h:701
void Trace(const char *msg, Logger::Level severity=Logger::Level::Info) const
Definition Sound.cpp:423
void FrameMoveWipers(float elapsedTime)
Definition Sound.cpp:1849
float Play(SOUNDS soundEnum, float volume=1.0f)
Definition Sound.cpp:802
char celebrity
Definition Sound.h:639
float globalAttenuate
Definition Sound.h:642
SOUNDS excludeFromGlobalAttenuate
Definition Sound.h:641
void FrameMoveImmigration()
Definition Sound.cpp:1773
float sound_pan[SOUND_ENUMERATION]
Definition Sound.h:386
void UpdateEarMuffle()
Definition Sound.cpp:1682
void Close()
Definition Sound.cpp:391
short oldstation
Definition Sound.h:635
static void CALLBACK MetaData(HSYNC handle, DWORD channel, DWORD data, void *user)
Definition Sound.cpp:1198
void PlayEx(SOUNDS soundEnum, bool loop, float volume=1.0f, float frequencyMod=1.0f, float pan=0.0f, bool restart=true, bool fromOutside=false, bool partOfHull=false)
Definition Sound.cpp:1006
void Reset()
Definition Sound.cpp:808
bool IsCabinAnnouncementPlaying(SOUNDS soundEnum=SOUND_NONE) const
Definition Sound.cpp:3545
void LoadSound(int soundEnum, SoundConfig *device=nullptr)
Definition Sound.cpp:1435
float headPanScalar
Definition Sound.h:655
float cabinAirborneTime
Definition Sound.h:661
char ambtype2
Definition Sound.h:692
void LegacySoundRequestUniverse(SServerPacket datapacket)
Definition Sound.cpp:2242
void ChangeCockpit(bool force)
Definition Sound.cpp:3645
bool g_bRadioPlaying
Definition Sound.h:634
void EnvironmentalEffects()
Definition Sound.cpp:2031
float hornPan[4]
Definition Sound.h:371
float oldvolume2
Definition Sound.h:654
Sound(GameClass *gameptr)
Definition Sound.cpp:69
bool UpdateSoundMix(SOUNDS soundEnum, HSTREAM streamToPlay, float modVolume)
Definition Sound.cpp:604
HSTREAM comms
Definition Sound.h:379
float oldFrequencyMod2
Definition Sound.h:654
const float maxrate
Definition Sound.h:376
static size_t GetFileSizeBytes(const char *str)
Definition Sound.cpp:1424
void ReleaseConfigSounds(SoundConfig *config)
Definition Sound.cpp:305
void GlobalAttenuate(float prmGaTimeToFadeOut, float prmGaTimeToHold, float prmGaTimeToFadeIn, SOUNDS soundEnum, float prmExTimeToFadeIn, float prmExTimeToHold, float prmExTimeToFadeOut, float volumeAdj=1.0f)
Definition Sound.cpp:536
float gaTimeToFadeOut
Definition Sound.h:644
void FrameMoveDopplerEffects(float elapsedTime)
Definition Sound.cpp:2781
std::vector< int > deviceBassDevices
Definition Sound.h:707
float hornVolume[4]
Definition Sound.h:371
EarPopSequence earPops
Definition Sound.h:683
float radioAutoMute
Definition Sound.h:694
bool IsVehicleAttachedSound(SOUNDS soundEnum) const
Definition Sound.cpp:595
bool loopintro
Definition Sound.h:700
std::vector< SOUNDS > cabinAnnouncementQueue
Definition Sound.h:660
std::vector< Sdelayedeffects > delayedeffects
Definition Sound.h:658
void LoadCustomSound(SOUNDS sound_enum, const char *path, SoundConfig *device=nullptr)
Definition Sound.cpp:5277
void LoadDockSounds(short dockTexture)
Definition Sound.cpp:3575
char oldtitle[99]
Definition Sound.h:636
float bleedAirGain
Definition Sound.h:373
float GetLength(SOUNDS soundEnum) const
Definition Sound.cpp:797
char stationIdentification
Definition Sound.h:638
float gaVolumeAdj
Definition Sound.h:647
HSTREAM sound_streamFx[SOUND_ENUMERATION]
Definition Sound.h:382
void ClearEarMuffle()
Definition Sound.cpp:1667
float oldFrequencyMod
Definition Sound.h:653
float oldBusMach
Definition Sound.h:652
bool earMuffleWarning
Definition Sound.h:682
float oldAmbientVolume
Definition Sound.h:693
bool hornAttached[4]
Definition Sound.h:372
HSTREAM g_pSoundIntro
Definition Sound.h:698
float sound_rate[SOUND_ENUMERATION]
Definition Sound.h:384
HFX sound_fxNotch[SOUND_ENUMERATION]
Definition Sound.h:391
void PlayAudioData(unsigned char *data, size_t length)
Definition Sound.cpp:430
std::vector< GUID > deviceGuids
Definition Sound.h:706
float oldPan2
Definition Sound.h:654
void FrameMoveCabinAnnouncements(float elapsedTime)
Definition Sound.cpp:3478
void LoadCockpitSound(SOUNDS soundEnum, const char *path, bool force, SoundConfig *device=nullptr)
Definition Sound.cpp:1536
bool hasAnimatedWipers
Definition Viewscreen.h:410
RiseMath::Vector3 UniverseRelativeVelocityKms
Definition Viewscreen.h:125
void SetHornPressed(bool pressed)
std::unique_ptr< propulsion > ptrPropulsion
Definition Viewscreen.h:432
RiseMath::Matrix matrixView
Definition Viewscreen.h:346
std::unique_ptr< weather > ptrWeather
Definition Viewscreen.h:434
SCamera * camera
Definition Viewscreen.h:137
float speedOfSoundKms
Definition propulsion.h:82
RiseMath::Vector3 localWindVector
Definition propulsion.h:99
float staticDensity
Definition propulsion.h:94
float dynamicDensityScalar
Definition propulsion.h:95
float mach
Definition propulsion.h:87
float GetPrecip() const
Definition weather.cpp:1365
float GetWindspeedKms() const
Definition weather.cpp:1352
DeathType dead
Definition globals.cpp:37
float f_AGL
Definition globals.cpp:9
s_network_objects playerships[MAX_SCAN]
Definition globals.cpp:112
bool g_bEnabled
Definition globals.cpp:96
RiseMath::Vector3 insidearray[63][63][3]
Definition globals.cpp:102
Scockpit ourcockpit
Definition globals.cpp:114
LOCALGRID2 gridarray[64][64]
Definition globals.cpp:100
#define SeaLevelPressureMb
Definition globals.h:102
#define SeaLevelSpeedOfSoundKms
Definition globals.h:103
#define OneAtmosphereMb
Definition globals.h:104
int SlotForEngine(int engineCount, int engine)
Definition EngineAudio.h:12
VehicleSoundSpatial::Mix Calculate(const Sources &cache, int slot, const RiseMath::Vector3 &cameraFromVehicle, float yaw, float pitch, float roll, const RiseMath::Matrix &bodyToCameraFrame, const std::array< float, SlotCount > &weights)
float Strength(float output)
HSTREAM Create(const unsigned char *data, std::size_t length, DWORD flags, int &error)
float ExteriorGain(float relativePressure)
VehicleSoundSpatial::Mix CalculateExterior(const RiseMath::Vector3 &output, float downLimit, float upLimit, float lateralLimit, float bellyDepthKm, float roofHeightKm, const RiseMath::Vector3 &cameraFromVehicle, float yaw, float pitch, float roll, const RiseMath::Matrix &bodyToCameraFrame)
Definition RcsAudio.h:21
constexpr float CockpitGain
Definition RcsAudio.h:10
HWND ClientWindow()
double ClientTime()
float Vec3Length(const Vector3 *a)
Definition ClientMath.h:95
constexpr float Pi
Definition ClientMath.h:12
constexpr auto Min(A first, B second)
Definition ClientMath.h:15
Matrix * MatrixRotationQuaternion(Matrix *out, const Quaternion *q)
Definition ClientMath.h:135
Vector3 * Vec3TransformNormal(Vector3 *out, const Vector3 *a, const Matrix *m)
Definition ClientMath.h:107
Matrix * MatrixInverse(Matrix *out, float *determinant, const Matrix *a)
Definition ClientMath.h:118
Matrix * MatrixIdentity(Matrix *out)
Definition ClientMath.h:115
auto ToDegree(T value)
Definition ClientMath.h:14
constexpr auto Max(A first, B second)
Definition ClientMath.h:16
constexpr float HalfPi
Definition ClientMath.h:12
constexpr float MammothReferenceDistanceKm
Definition VehicleHorn.h:7
Mix Calculate(const RiseMath::Vector3 &cameraFromVehicle, float yaw, float pitch, float roll, float referenceDistanceKm=.005f)
float PlaybackRate(float duration, float cyclesPerSecond)
Definition WiperAudio.h:7
bool Synchronize(HSTREAM stream, float phase, float duration, float cyclesPerSecond, bool force)
Definition WiperAudio.h:14
std::string name
Definition Command.h:11
PlotType type
Definition globals.h:276
RiseMath::Vector3 position
Definition globals.h:273
unsigned char type
unsigned short serial
unsigned char array
float dntranslimit
Definition globals.h:601
int sonicBooms
Definition globals.h:737
float shelfFreq
Definition globals.h:744
char radioplaying[99]
Definition globals.h:628
short texturelib
Definition globals.h:602
float lrtranslimit
Definition globals.h:601
float panFactor
Definition globals.h:751
short ourplyrC
Definition globals.h:682
float uptranslimit
Definition globals.h:601
float power
Definition globals.h:599
EngineAudio::Sources engineSounds
Definition globals.h:631
float flapExtent
Definition globals.h:660
float lpSlope
Definition globals.h:748
float shelfSlope
Definition globals.h:746
bool radioPower
Definition globals.h:597
float notchFreq
Definition globals.h:749
float gearextent
Definition globals.h:617
float lpFreq
Definition globals.h:747
float attenuate
Definition globals.h:743
float strutsrettoCGKm
Definition globals.h:624
bool radioEquipped
Definition globals.h:669
bool spaceCapable
Definition globals.h:596
char engines
Definition globals.h:630
float shelfGain
Definition globals.h:745
float notchGain
Definition globals.h:750
float rooftoCGKm
Definition globals.h:624
float volume
Definition Sound.h:350
SOUNDS soundEnum
Definition Sound.h:349
bool fromOutside
Definition Sound.h:353
float delay
Definition Sound.h:351
SOUNDS soundEnum
Definition Sound.h:360
unsigned char array
Definition Sound.h:358
char bassDevice
Definition SoundConfig.h:19
RiseMath::Vector3 barycentric
Definition globals.h:500
RiseMath::Vector3 position
Definition globals.h:511
unsigned char type
Definition globals.h:488
RiseMath::Vector3 dockoffset
Definition globals.h:511
unsigned short vehicleId
Definition globals.h:537
RiseMath::Vector3 velocity
Definition globals.h:500
WindshieldWipers::Motion wipers
Definition globals.h:535
unsigned char inarray
Definition globals.h:509
float baydoorextent
Definition globals.h:539
char hullname[23]
Definition globals.h:495