From 2aeb452dfb8e4f68a396e8729a5c2506f88db32f Mon Sep 17 00:00:00 2001 From: Nadia Holmquist Pedersen Date: Tue, 17 Aug 2021 00:34:23 +0200 Subject: SPU: Do clamping after applying SOUNDBIAS --- src/SPU.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/SPU.cpp b/src/SPU.cpp index d1c2d84..39fd946 100644 --- a/src/SPU.cpp +++ b/src/SPU.cpp @@ -799,9 +799,18 @@ void Mix(u32 dummy) rightoutput = ((s64)rightoutput * MasterVolume) >> 7; leftoutput >>= 8; + rightoutput >>= 8; + + // Add SOUNDBIAS value + // The value used by all commercial games is 0x200, so we subtract that so it won't offset the final sound output. + if (ApplyBias == true) + { + leftoutput += (Bias << 6) - 0x8000; + rightoutput += (Bias << 6) - 0x8000; + } + if (leftoutput < -0x8000) leftoutput = -0x8000; else if (leftoutput > 0x7FFF) leftoutput = 0x7FFF; - rightoutput >>= 8; if (rightoutput < -0x8000) rightoutput = -0x8000; else if (rightoutput > 0x7FFF) rightoutput = 0x7FFF; @@ -812,14 +821,6 @@ void Mix(u32 dummy) rightoutput &= 0xFFFFFFC0; } - // Add SOUNDBIAS value - // The value used by all commercial games is 0x200, so we subtract that so it won't offset the final sound output. - if (ApplyBias == true) - { - leftoutput += (Bias << 6) - 0x8000; - rightoutput += (Bias << 6) - 0x8000; - } - // OutputBufferFrame can never get full because it's // transfered to OutputBuffer at the end of the frame OutputBackbuffer[OutputBackbufferWritePosition ] = leftoutput >> 1; -- cgit v1.2.3