Skip to content

Conversation

@Stubbjax
Copy link

Fixes #1941

This change fixes an issue where currently playing UI audio can be heard at maximum volume for a single frame when navigating between the shell map and other menus.

The issue is caused by a script being run via the shell map. The script reduces the sound volume to 5% when opening the options or entering other menu screens in order to silence the explosions and other noise coming from the shell map. As this also reduces the UI sound effect volume, another script is run to offset the reduced volume by adjusting a manually defined list of UI sound effect volumes to 600%. See the script reference images further below.

When the game processes a volume override command for a particular sound, the override is also immediately applied to any currently playing instances of that sound. However, when the game processes a global volume command, that volume adjustment is not applied until the next frame.

The issue is that adjustVolumeOfPlayingAudio applies the override without multiplying the global volume (m_soundVolume), so the sound immediately plays at 600% volume instead of 30% (6 × 0.05). Then, on the next frame, processPlayingList() sees m_volumeHasChanged = TRUE and calls adjustPlayingVolume(), which correctly applies the global volume. So for one frame, the sound plays at 600% volume before being corrected to 30%.

The solution is to make adjustVolumeOfPlayingAudio apply the same global volume modifiers as adjustPlayingVolume.

Script Reference

Image Image

@Stubbjax Stubbjax self-assigned this Dec 20, 2025
@Stubbjax Stubbjax added Audio Is audio related Bug Something is not working right, typically is user facing Minor Severity: Minor < Major < Critical < Blocker labels Dec 20, 2025
Real desiredVolume = playing->m_audioEventRTS->getVolume() * playing->m_audioEventRTS->getVolumeShift();
AIL_sample_volume_pan(playing->m_sample, NULL, &pan);
AIL_set_sample_volume_pan(playing->m_sample, desiredVolume, pan);
AIL_set_sample_volume_pan(playing->m_sample, m_soundVolume * desiredVolume, pan);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we do a follow up refactor and simplify all these volumes by using MilesAudioManager::getEffectiveVolume?

Then

Real desiredVolume = playing->m_audioEventRTS->getVolume() * playing->m_audioEventRTS->getVolumeShift();
AIL_set_sample_volume_pan(playing->m_sample, m_soundVolume * desiredVolume, pan);

becomes

AIL_set_sample_volume_pan(playing->m_sample, getEffectiveVolume(playing->m_audioEventRTS), pan);

This would streamline and simplify all this volume code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Audio Is audio related Bug Something is not working right, typically is user facing Minor Severity: Minor < Major < Critical < Blocker

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Setting Sound FX volume to 0 does not mute all sounds

2 participants