You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 5, 2024. It is now read-only.
Cleaned up various stuff in AudioMan and supported changes to SoundContainer
Added separate channel groups for mobile and immobile sounds
Added a vector of sound channel rolloffs for safety
Added methods to handle customization of 3d effects (panning, attenuation) for mobile sound channels. This should probably be replaced with a DSP eventually.
g_ConsoleMan.PrintString("ERROR: Could not set sound position for the sound being played on channel " + std::to_string(channelIndex) + " for SoundContainer " + soundContainer->GetPresetName() + ": " + std::string(FMOD_ErrorString(result)));
248
+
}
249
+
result = (result == FMOD_OK) ? UpdateMobileSoundChannelCalculated3DEffects(soundChannel) : result;
230
250
if (result != FMOD_OK) {
231
-
g_ConsoleMan.PrintString("ERROR: Could not set sound position for the sound being played on channel " + std::to_string(*channelIterator) + " for SoundContainer " + soundContainer->GetPresetName() + ": " + std::string(FMOD_ErrorString(result)));
251
+
g_ConsoleMan.PrintString("ERROR: Could not update attenuation for the sound being played on channel " + std::to_string(channelIndex) + " for SoundContainer " + soundContainer->GetPresetName() + ": " + std::string(FMOD_ErrorString(result)));
232
252
}
233
253
}
234
254
return result == FMOD_OK;
@@ -282,7 +302,7 @@ namespace RTE {
282
302
}
283
303
284
304
FMOD::Channel *musicChannel;
285
-
result = musicStream->set3DMinMaxDistance(100000, 100000);
305
+
result = musicStream->set3DMinMaxDistance(c_SoundMaxAudibleDistance, c_SoundMaxAudibleDistance);
result = (result == FMOD_OK) ? channel->getIndex(&channelIndex) : result;
435
-
result = (result == FMOD_OK) ? channel->setUserData(soundContainer) : result;
436
-
result = (result == FMOD_OK) ? channel->setCallback(SoundChannelEndedCallback) : result;
437
-
result = (result == FMOD_OK) ? channel->set3DAttributes(&GetAsFMODVector(position), NULL) : result;
438
-
result = (result == FMOD_OK) ? channel->set3DLevel(g_SettingsMan.SoundPanningEffectStrength()) : result;
439
-
result = (result == FMOD_OK) ? channel->setPriority(priority) : result;
440
-
result = (result == FMOD_OK) ? channel->setPitch(pitch) : result;
441
-
}
442
-
if (result != FMOD_OK) {
443
-
g_ConsoleMan.PrintString("ERROR: Could not play sounds from SoundContainer " + soundContainer->GetPresetName() + ": " + std::string(FMOD_ErrorString(result)));
result = (result == FMOD_OK) ? channel->set3DCustomRolloff(soundChannelRolloffs.at(channelIndex).data(), 2) : result;
467
+
result = (result == FMOD_OK) ? UpdateMobileSoundChannelCalculated3DEffects(channel) : result;
468
+
}
469
+
470
+
if (result != FMOD_OK) {
471
+
g_ConsoleMan.PrintString("ERROR: Could not play sounds from SoundContainer " + soundContainer->GetPresetName() + ": " + std::string(FMOD_ErrorString(result)));
472
+
returnfalse;
473
+
}
474
+
475
+
result = channel->setPaused(false);
476
+
if (result != FMOD_OK) {
477
+
g_ConsoleMan.PrintString("ERROR: Failed to start playing sounds from SoundContainer " + soundContainer->GetPresetName() + " after setting it up: " + std::string(FMOD_ErrorString(result)));
478
+
returnfalse;
479
+
}
480
+
481
+
soundContainer->AddPlayingChannel(channelIndex);
482
+
}
445
483
}
446
-
result = channel->setPaused(false);
447
-
if (result != FMOD_OK) { g_ConsoleMan.PrintString("ERROR: Failed to start playing sounds from SoundContainer " + soundContainer->GetPresetName() + " after setting it up: " + std::string(FMOD_ErrorString(result))); }
448
484
449
-
soundContainer->AddPlayingChannel(channelIndex);
450
485
451
486
// Now that the sound is playing we can register an event with the SoundContainer's channels, which can be used by clients to identify the sound being played.
452
487
if (m_IsInMultiplayerMode) {
@@ -622,6 +657,9 @@ namespace RTE {
622
657
if (channelSoundContainer->IsBeingPlayed()) { channelSoundContainer->RemovePlayingChannel(channelIndex); }
623
658
result = (result == FMOD_OK) ? channel->setUserData(NULL) : result;
624
659
660
+
// Remove the stored rolloff for this channel
661
+
if (AudioMan::Instance().soundChannelRolloffs.find(channelIndex) != AudioMan::Instance().soundChannelRolloffs.end()) { AudioMan::Instance().soundChannelRolloffs.erase(channelIndex); }
662
+
625
663
if (result != FMOD_OK) {
626
664
g_ConsoleMan.PrintString("ERROR: An error occurred when Ending a sound in SoundContainer " + channelSoundContainer->GetPresetName() + ": " + std::string(FMOD_ErrorString(result)));
FMOD_RESULT result = m_MobileSoundChannelGroup->getNumChannels(&numberOfPlayingChannels);
685
+
if (result == FMOD_OK) {
686
+
for (int i = 0; i < numberOfPlayingChannels; i++) {
687
+
result = m_MobileSoundChannelGroup->getChannel(i, &channel);
688
+
result = result == FMOD_OK ? UpdateMobileSoundChannelCalculated3DEffects(channel) : result;
689
+
if (result != FMOD_OK) {
690
+
g_ConsoleMan.PrintString("ERROR: An error occured when manually attenuating all playing channels, for channel index " + std::to_string(i) + ": " + std::string(FMOD_ErrorString(result)));
691
+
}
692
+
}
693
+
} else {
694
+
g_ConsoleMan.PrintString("ERROR: Failed to get the number of playing channels when manually attenuating all playing channels: " + std::string(FMOD_ErrorString(result)));
0 commit comments