From c077500d166f1a76f45541cd8346ebd4fd49d6da Mon Sep 17 00:00:00 2001 From: N00byKing Date: Thu, 9 Jun 2022 21:46:40 +0200 Subject: [PATCH] Fix semi random volume jumps --- desktop_version/src/Music.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/desktop_version/src/Music.cpp b/desktop_version/src/Music.cpp index ac923841..15e0852f 100644 --- a/desktop_version/src/Music.cpp +++ b/desktop_version/src/Music.cpp @@ -165,6 +165,7 @@ end: vlog_error("Unable to queue sound buffer"); return; } + FAudioVoice_SetVolume(voices[i], volume, FAUDIO_COMMIT_NOW); if (FAudioSourceVoice_Start(voices[i], 0, FAUDIO_COMMIT_NOW)) { vlog_error("Unable to start voice processing"); @@ -229,10 +230,10 @@ end: static void SetVolume(int soundVolume) { - float adj_vol = (float) soundVolume / VVV_MAX_VOLUME; + volume = (float) soundVolume / VVV_MAX_VOLUME; for (size_t i = 0; i < VVV_MAX_CHANNELS; i++) { - FAudioVoice_SetVolume(voices[i], adj_vol, FAUDIO_COMMIT_NOW); + FAudioVoice_SetVolume(voices[i], volume, FAUDIO_COMMIT_NOW); } } @@ -242,8 +243,10 @@ end: bool valid; static FAudioSourceVoice** voices; + static float volume; }; FAudioSourceVoice** SoundTrack::voices = NULL; +float SoundTrack::volume; class MusicTrack {