From 4ab5b03bdcaf4b31b6fef597d33264eabe98e1c0 Mon Sep 17 00:00:00 2001 From: "sudonim1@gmail.com" Date: Mon, 3 Sep 2012 11:43:16 +0000 Subject: [PATCH] SPU2-X: Use zero coefficients when the sample data references a higher entry in the coefficients table than we know about and print a warning to the console if logging is enabled. Fixes audio glitches in "Crash" series games. Also fixed the voice stop log, it was printing when voices looped. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@5402 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/spu2-x/src/Mixer.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/plugins/spu2-x/src/Mixer.cpp b/plugins/spu2-x/src/Mixer.cpp index d7ed0f406d..ee861a6801 100644 --- a/plugins/spu2-x/src/Mixer.cpp +++ b/plugins/spu2-x/src/Mixer.cpp @@ -19,7 +19,7 @@ void ADMAOutLogWrite(void *lpData, u32 ulSize); -static const s32 tbl_XA_Factor[5][2] = +static const s32 tbl_XA_Factor[16][2] = { { 0, 0 }, { 60, 0 }, @@ -76,8 +76,11 @@ static void __forceinline XA_decode_block(s16* buffer, const s16* block, s32& pr { const s32 header = *block; const s32 shift = (header&0xF)+16; - const s32 pred1 = tbl_XA_Factor[(header>> 4)&0xF][0]; - const s32 pred2 = tbl_XA_Factor[(header>> 4)&0xF][1]; + const int id = header >> 4 & 0xF; + if (id > 4 && MsgToConsole()) + ConLog("* SPU2-X: Unknown ADPCM coefficients table id %d\n", id); + const s32 pred1 = tbl_XA_Factor[id][0]; + const s32 pred2 = tbl_XA_Factor[id][1]; const s8* blockbytes = (s8*)&block[1]; const s8* blockend = &blockbytes[13]; @@ -156,11 +159,13 @@ static __forceinline s32 GetNextDataBuffered( V_Core& thiscore, uint voiceidx ) thiscore.Regs.ENDX |= (1 << voiceidx); vc.NextA = vc.LoopStartA | 1; if (!(vc.LoopFlags & XAFLAG_LOOP)) + { vc.Stop(); - if( IsDevBuild ) - { - if(MsgVoiceOff()) ConLog("* SPU2-X: Voice Off by EndPoint: %d \n", voiceidx); + if( IsDevBuild ) + { + if(MsgVoiceOff()) ConLog("* SPU2-X: Voice Off by EndPoint: %d \n", voiceidx); + } } } else