aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNadia Holmquist Pedersen <nadia@nhp.sh>2021-08-17 00:34:23 +0200
committerNadia Holmquist Pedersen <nadia@nhp.sh>2021-08-17 01:01:15 +0200
commit2aeb452dfb8e4f68a396e8729a5c2506f88db32f (patch)
tree8164a6c4c4abc918efa84a913f67582736296d4c
parent418b35198680643be760dab4f4b2b8df2696041f (diff)
SPU: Do clamping after applying SOUNDBIAS
-rw-r--r--src/SPU.cpp19
1 files changed, 10 insertions, 9 deletions
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;