From ad6438f9364df3f6459afd64380d5339ed155f08 Mon Sep 17 00:00:00 2001 From: Silent Date: Sun, 11 Oct 2020 00:10:06 +0200 Subject: [PATCH] Fix issues related to volume getting/setting Not adding headroom to volume in HybridDirectSoundBuffer_SetMixBinVolumes_8 caused the sound to be attenuated by the headroom value every time it was updated. --- src/core/hle/DSOUND/DirectSound/DirectSoundInline.hpp | 2 +- src/core/hle/DSOUND/common/XbInternalDSVoice.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/hle/DSOUND/DirectSound/DirectSoundInline.hpp b/src/core/hle/DSOUND/DirectSound/DirectSoundInline.hpp index 00428662a..fd5f27b20 100644 --- a/src/core/hle/DSOUND/DirectSound/DirectSoundInline.hpp +++ b/src/core/hle/DSOUND/DirectSound/DirectSoundInline.hpp @@ -1319,7 +1319,7 @@ static inline HRESULT HybridDirectSoundBuffer_SetMixBinVolumes_8( } if (counter > 0) { Xb_volumeMixBin = volume / (LONG)counter; - int32_t Xb_volume = Xb_Voice->GetVolume(); + int32_t Xb_volume = Xb_Voice->GetVolume() + Xb_Voice->GetHeadroom(); hRet = HybridDirectSoundBuffer_SetVolume(pDSBuffer, Xb_volume, EmuFlags, Xb_volumeMixBin, Xb_Voice); } else { diff --git a/src/core/hle/DSOUND/common/XbInternalDSVoice.cpp b/src/core/hle/DSOUND/common/XbInternalDSVoice.cpp index 7acccc814..0515f3aa0 100644 --- a/src/core/hle/DSOUND/common/XbInternalDSVoice.cpp +++ b/src/core/hle/DSOUND/common/XbInternalDSVoice.cpp @@ -117,7 +117,7 @@ uint32_t GetVolume(T& settings) // Interface for set volume template -void SetVolume(T& settings, uint32_t volume) +void SetVolume(T& settings, int32_t volume) { settings.volume = volume - settings.headroom; } @@ -133,7 +133,7 @@ uint32_t GetHeadroom(T& settings) template void SetHeadroom(T& settings, uint32_t set_headroom) { - settings.volume = settings.volume - set_headroom - settings.headroom; + settings.volume = settings.volume + settings.headroom - set_headroom; settings.headroom = set_headroom; }