From 85205332969b03a0182c3f2aad2687195d18b840 Mon Sep 17 00:00:00 2001 From: Ethan Lee Date: Mon, 14 Jun 2021 15:09:23 -0400 Subject: [PATCH] Music: Reset step_ms on every fade call. Without this you end up with two problems: - Fades will start past their fade time, causing it to just not fade at all - Fades will start in the middle of their fade time, causing dramatic changes in volume that are unintentional The fade system already preserves the volume that music is playing during a previous fade, so we can always reset the timer and get a good result. Part of #764 --- desktop_version/src/Music.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/desktop_version/src/Music.cpp b/desktop_version/src/Music.cpp index 283a1812..0b76695c 100644 --- a/desktop_version/src/Music.cpp +++ b/desktop_version/src/Music.cpp @@ -332,6 +332,7 @@ void musicclass::fadeMusicVolumeIn(int ms) /* Fix 1-frame glitch */ Mix_VolumeMusic(0); + fade.step_ms = 0; fade.duration_ms = ms; fade.start_volume = 0; fade.end_volume = MIX_MAX_VOLUME; @@ -342,6 +343,7 @@ void musicclass::fadeMusicVolumeOut(const int fadeout_ms) m_doFadeInVol = false; m_doFadeOutVol = true; + fade.step_ms = 0; fade.duration_ms = fadeout_ms; fade.start_volume = musicVolume; fade.end_volume = 0;