Skip to content

Commit

Permalink
More audio improvements
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
Alayan-stk-2 committed Nov 17, 2023
1 parent 40511b2 commit e744fd3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/modes/linear_world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/network/protocols/client_lobby.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit e744fd3

Please sign in to comment.