From 990697bcbbcbb0a8809ab5ced864e67675dac97b Mon Sep 17 00:00:00 2001 From: skidau Date: Sun, 19 Oct 2014 21:20:33 +1100 Subject: [PATCH] Clamp the AX Volume to prevent clipping. Patch by hk.konpie. Fixes issue 7519. --- Source/Core/Core/HW/DSPHLE/UCodes/AXVoice.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/AXVoice.h b/Source/Core/Core/HW/DSPHLE/UCodes/AXVoice.h index 4dea13a075..f6ef24b1c8 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/AXVoice.h +++ b/Source/Core/Core/HW/DSPHLE/UCodes/AXVoice.h @@ -430,6 +430,7 @@ void MixAdd(int* out, const s16* input, u32 count, u16* pvol, s16* dpop, bool ra s64 sample = input[i]; sample *= volume; sample >>= 15; + sample = MathUtil::Clamp((s32)sample, -32767, 32767); // -32768 ? out[i] += (s16)sample; volume += volume_delta; @@ -462,7 +463,7 @@ void ProcessVoice(PB_TYPE& pb, const AXBuffers& buffers, u16 count, AXMixControl // Apply a global volume ramp using the volume envelope parameters. for (u32 i = 0; i < count; ++i) { - samples[i] = ((s32)samples[i] * pb.vol_env.cur_volume) >> 15; + samples[i] = MathUtil::Clamp(((s32)samples[i] * pb.vol_env.cur_volume) >> 15, -32767, 32767); // -32768 ? pb.vol_env.cur_volume += pb.vol_env.cur_volume_delta; }