More audio improvements

- Fix a bug that made the last lap SFX played only if music was on.
- Fix the behavior of the music volume adjustment when the last lap SFX is played. Previously, the music volume was only adjusted when the music volume was above a certain threshold, but when it was above that threshold, the adjustment was too strong.
This commit is contained in:
Alayan 2023-11-17 19:11:25 +01:00
parent 40511b218c
commit e744fd3033
No known key found for this signature in database
2 changed files with 9 additions and 5 deletions

View File

@ -421,17 +421,20 @@ void LinearWorld::newLap(unsigned int kart_index)
}
if(!m_last_lap_sfx_played && lap_count > 1)
{
if (UserConfigParams::m_music)
if (UserConfigParams::m_sfx)
{
m_last_lap_sfx->play();
m_last_lap_sfx_played = true;
m_last_lap_sfx_playing = true;
// In case that no music is defined
if(music_manager->getCurrentMusic() &&
music_manager->getMasterMusicVolume() > 0.2f)
// Temporarily reduce the volume of the main music
// So that the last lap SFX can be heard
if(UserConfigParams::m_music &&
music_manager->getCurrentMusic())
{
music_manager->setTemporaryVolume(0.2f);
// The parameter taken by SetTemporaryVolume is a factor
// that gets multiplied with the master volume
music_manager->setTemporaryVolume(0.5f);
}
}
else

View File

@ -1686,6 +1686,7 @@ void ClientLobby::handleClientCommand(const std::string& cmd)
AddonsPack::install(argv[1]);
else if (argv[0] == "uninstalladdon" && argv.size() == 2)
AddonsPack::uninstall(argv[1]);
// FIXME - this code duplicates functions that should be handled elsewhere.
else if (argv[0] == "music" && argv.size() == 2)
{
int vol = atoi(argv[1].c_str());