From e34b78ab803122c4c9494479135afe630f1163a5 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Fri, 24 Apr 2020 15:50:32 +1000 Subject: [PATCH] SPU: Fix pitch modulation --- src/core/spu.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/spu.cpp b/src/core/spu.cpp index 299304770..940c152a3 100644 --- a/src/core/spu.cpp +++ b/src/core/spu.cpp @@ -1443,8 +1443,9 @@ std::tuple SPU::SampleVoice(u32 voice_index) u16 step = voice.regs.adpcm_sample_rate; if (IsPitchModulationEnabled(voice_index)) { - const u32 factor = u32(std::clamp(m_voices[voice_index - 1].last_volume, -0x8000, 0x7FFF) + 0x8000); - step = Truncate16(step * factor) >> 15; + const s32 factor = std::clamp(m_voices[voice_index - 1].last_volume, -0x8000, 0x7FFF) + 0x8000; + const u16 old_step = step; + step = Truncate16(static_cast((SignExtend32(step) * factor) >> 15)); } step = std::min(step, 0x4000);