From 0244097a260c8de994cd65643dc3aaf03e58dc41 Mon Sep 17 00:00:00 2001 From: ramapcsx2 Date: Sun, 7 Mar 2010 02:38:33 +0000 Subject: [PATCH] SPU2-X: - Fixed the clipping audio in many game's sound effects by using a saturating XA decoder. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2679 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/spu2-x/src/Mixer.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/plugins/spu2-x/src/Mixer.cpp b/plugins/spu2-x/src/Mixer.cpp index 4cbf117fa9..829348f13f 100644 --- a/plugins/spu2-x/src/Mixer.cpp +++ b/plugins/spu2-x/src/Mixer.cpp @@ -90,6 +90,10 @@ static void __forceinline XA_decode_block(s16* buffer, const s16* block, s32& pr s32 data = ((*blockbytes)<<28) & 0xF0000000; pcm = data>>shift; pcm+=((pred1*prev1)+(pred2*prev2))>>6; + + if(pcm> 32767) ConLog("pcm too high, is %d\n",pcm); + else if(pcm<-32768) ConLog("pcm too low, is %d\n",pcm); + if(pcm> 32767) pcm= 32767; else if(pcm<-32768) pcm=-32768; *(buffer++) = pcm; @@ -102,6 +106,10 @@ static void __forceinline XA_decode_block(s16* buffer, const s16* block, s32& pr s32 data = ((*blockbytes)<<24) & 0xF0000000; pcm2 = data>>shift; pcm2+=((pred1*pcm)+(pred2*prev1))>>6; + + if(pcm2> 32767) ConLog("pcm2 too high, is %d\n",pcm2); + else if(pcm2<-32768) ConLog("pcm2 too low, is %d\n",pcm2); + if(pcm2> 32767) pcm2= 32767; else if(pcm2<-32768) pcm2=-32768; *(buffer++) = pcm2; @@ -238,7 +246,9 @@ static __forceinline s32 __fastcall GetNextDataBuffered( V_Core& thiscore, uint g_counter_cache_misses++; } - XA_decode_block_unsaturated( vc.SBuffer, memptr, vc.Prev1, vc.Prev2 ); + // The unsaturated version causes clipping artefacts. TODO: Fix it :) + //XA_decode_block_unsaturated( vc.SBuffer, memptr, vc.Prev1, vc.Prev2 ); + XA_decode_block( vc.SBuffer, memptr, vc.Prev1, vc.Prev2 ); } vc.SCurrent = 0;