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.
Modified AudioMan PlaySound to so it doesn't call SetPitch and SetAttenuation, in order to lower the number of SoundEvents registered and sent back and forth during multiplayer.
Changed size limit of NetworkSoundData SoundFileHashes to c_MaxPlayingSoundsPerContainer to lower the struct's size. I was confused when I set it to c_MaxAudioChannels anyway; if a SoundContainer can only have 64 channels playing at once, it couldn't need more than that many hashes.
Made the number of sound events required to trigger early sending of sound events to clients be based on the size of the NetworkSoundData struct, so it won't overflow its limits
Copy file name to clipboardExpand all lines: Managers/AudioMan.cpp
+7-6Lines changed: 7 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -427,8 +427,9 @@ namespace RTE {
427
427
returnfalse;
428
428
}
429
429
430
+
attenuation = Limit(attenuation, 0.95, 0); //Limit attenuation so it can't be closer than 0 (full volume) or farther than 0.95 (quiet but not quite silent)
pitch = Limit(pSoundContainer->IsAffectedByGlobalPitch() ? m_GlobalPitch : pitch, 8, 0.125); //Limit pitch change to 8 octaves up or down, and set it to global pitch if applicable
432
433
433
434
FMOD::Channel *channel;
434
435
FMOD_RESULT result = FMOD_OK;
@@ -442,24 +443,24 @@ namespace RTE {
442
443
result = result == FMOD_OK ? channel->getIndex(&channelIndex) : result;
443
444
result = result == FMOD_OK ? channel->setUserData(pSoundContainer) : result;
444
445
result = result == FMOD_OK ? channel->setCallback(SoundChannelEndedCallback) : result;
446
+
result = result == FMOD_OK ? channel->setVolume(1 - attenuation) : result;
445
447
result = result == FMOD_OK ? channel->setLoopCount(pSoundContainer->GetLoopSetting()) : result;
446
448
result = result == FMOD_OK ? channel->setPriority(priority) : result;
449
+
result = result == FMOD_OK ? channel->setPitch(pitch) : result;
447
450
}
448
451
449
452
if (result != FMOD_OK) {
450
453
g_ConsoleMan.PrintString("ERROR: Could not play sounds from SoundContainer " + pSoundContainer->GetPresetName() + ": " + std::string(FMOD_ErrorString(result)));
if (pitch != 1) { SetSoundPitch(pSoundContainer, pitch); }
457
-
458
457
result = channel->setPaused(false);
459
458
if (result != FMOD_OK) {
460
459
g_ConsoleMan.PrintString("ERROR: Failed to start playing sounds from SoundContainer " + pSoundContainer->GetPresetName() + " after setting it up: " + std::string(FMOD_ErrorString(result)));
461
460
}
462
461
462
+
pSoundContainer->AddPlayingChannel(channelIndex);
463
+
463
464
// 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.
Copy file name to clipboardExpand all lines: Managers/NetworkClient.cpp
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -715,7 +715,7 @@ namespace RTE
715
715
}
716
716
717
717
// We always have to add the newly made sound container to the map of server sounds, regardless of whether we were able to delete existing sounds above
718
-
if (sndDataPtr->State == AudioMan::SOUND_PLAY) { m_ServerSounds[serverSoundChannelIndex] = newlyMadeSoundContainer; }
718
+
if (sndDataPtr->State == AudioMan::SOUND_PLAY) { m_ServerSounds.insert({serverSoundChannelIndex, soundContainerToHandle}); }
0 commit comments