SPU2-X: Tried to fix the incorrect bitshifts back from when Neill's code was optimised while the registers were broken so it wasn't testable. My maths is probably off, the code needs reviewing. The "- 1"s are so that -1 * -1 = just short of 1 instead of -1 (overflow).

With this, reverb maybe sounds somewhat like the PS2 for the first time ever!?

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4764 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
sudonim1@gmail.com 2011-06-25 01:34:41 +00:00
parent 43fba9aab8
commit c22e933f5e
1 changed files with 26 additions and 26 deletions

View File

@ -180,13 +180,13 @@ StereoOut32 V_Core::DoReverb( const StereoOut32& Input )
INPUT_SAMPLE.Left >>= 16;
INPUT_SAMPLE.Right >>= 16;
s32 input_L = (INPUT_SAMPLE.Left * Revb.IN_COEF_L);
s32 input_R = (INPUT_SAMPLE.Right * Revb.IN_COEF_R);
s32 input_L = INPUT_SAMPLE.Left * Revb.IN_COEF_L - 1;
s32 input_R = INPUT_SAMPLE.Right * Revb.IN_COEF_R - 1;
const s32 IIR_INPUT_A0 = ((_spu2mem[src_a0] * Revb.IIR_COEF) + input_L)>>16;
const s32 IIR_INPUT_A1 = ((_spu2mem[src_a1] * Revb.IIR_COEF) + input_L)>>16;
const s32 IIR_INPUT_B0 = ((_spu2mem[src_b0] * Revb.IIR_COEF) + input_R)>>16;
const s32 IIR_INPUT_B1 = ((_spu2mem[src_b1] * Revb.IIR_COEF) + input_R)>>16;
const s32 IIR_INPUT_A0 = ((_spu2mem[src_a0] * Revb.IIR_COEF - 1) + input_L)>>15;
const s32 IIR_INPUT_A1 = ((_spu2mem[src_a1] * Revb.IIR_COEF - 1) + input_L)>>15;
const s32 IIR_INPUT_B0 = ((_spu2mem[src_b0] * Revb.IIR_COEF - 1) + input_R)>>15;
const s32 IIR_INPUT_B1 = ((_spu2mem[src_b1] * Revb.IIR_COEF - 1) + input_R)>>15;
const s32 src_dest_a0 = _spu2mem[dest_a0];
const s32 src_dest_a1 = _spu2mem[dest_a1];
@ -195,28 +195,28 @@ StereoOut32 V_Core::DoReverb( const StereoOut32& Input )
// This section differs from Neill's doc as it uses single-mul interpolation instead
// of 0x8000-val inversion. (same result, faster)
const s32 IIR_A0 = src_dest_a0 + (((IIR_INPUT_A0 - src_dest_a0) * Revb.IIR_ALPHA)>>16);
const s32 IIR_A1 = src_dest_a1 + (((IIR_INPUT_A1 - src_dest_a1) * Revb.IIR_ALPHA)>>16);
const s32 IIR_B0 = src_dest_b0 + (((IIR_INPUT_B0 - src_dest_b0) * Revb.IIR_ALPHA)>>16);
const s32 IIR_B1 = src_dest_b1 + (((IIR_INPUT_B1 - src_dest_b1) * Revb.IIR_ALPHA)>>16);
const s32 IIR_A0 = src_dest_a0 + (((IIR_INPUT_A0 - src_dest_a0) * Revb.IIR_ALPHA - 1)>>15);
const s32 IIR_A1 = src_dest_a1 + (((IIR_INPUT_A1 - src_dest_a1) * Revb.IIR_ALPHA - 1)>>15);
const s32 IIR_B0 = src_dest_b0 + (((IIR_INPUT_B0 - src_dest_b0) * Revb.IIR_ALPHA - 1)>>15);
const s32 IIR_B1 = src_dest_b1 + (((IIR_INPUT_B1 - src_dest_b1) * Revb.IIR_ALPHA - 1)>>15);
_spu2mem[dest2_a0] = clamp_mix( IIR_A0 );
_spu2mem[dest2_a1] = clamp_mix( IIR_A1 );
_spu2mem[dest2_b0] = clamp_mix( IIR_B0 );
_spu2mem[dest2_b1] = clamp_mix( IIR_B1 );
const s32 ACC0 = (
((_spu2mem[acc_src_a0] * Revb.ACC_COEF_A)) +
((_spu2mem[acc_src_b0] * Revb.ACC_COEF_B)) +
((_spu2mem[acc_src_c0] * Revb.ACC_COEF_C)) +
((_spu2mem[acc_src_d0] * Revb.ACC_COEF_D))
); // >> 16;
((_spu2mem[acc_src_a0] * Revb.ACC_COEF_A - 1) >> 15) +
((_spu2mem[acc_src_b0] * Revb.ACC_COEF_B - 1) >> 15) +
((_spu2mem[acc_src_c0] * Revb.ACC_COEF_C - 1) >> 15) +
((_spu2mem[acc_src_d0] * Revb.ACC_COEF_D - 1) >> 15)
);
const s32 ACC1 = (
((_spu2mem[acc_src_a1] * Revb.ACC_COEF_A)) +
((_spu2mem[acc_src_b1] * Revb.ACC_COEF_B)) +
((_spu2mem[acc_src_c1] * Revb.ACC_COEF_C)) +
((_spu2mem[acc_src_d1] * Revb.ACC_COEF_D))
); // >> 16;
((_spu2mem[acc_src_a1] * Revb.ACC_COEF_A - 1) >> 15) +
((_spu2mem[acc_src_b1] * Revb.ACC_COEF_B - 1) >> 15) +
((_spu2mem[acc_src_c1] * Revb.ACC_COEF_C - 1) >> 15) +
((_spu2mem[acc_src_d1] * Revb.ACC_COEF_D - 1) >> 15)
);
// The following code differs from Neill's doc as it uses the more natural single-mul
// interpolative, instead of the funky ^0x8000 stuff. (better result, faster)
@ -224,14 +224,14 @@ StereoOut32 V_Core::DoReverb( const StereoOut32& Input )
const s32 FB_A0 = _spu2mem[fb_src_a0];
const s32 FB_A1 = _spu2mem[fb_src_a1];
_spu2mem[mix_dest_a0] = clamp_mix( (ACC0 - FB_A0 * Revb.FB_ALPHA) >> 16 );
_spu2mem[mix_dest_a1] = clamp_mix( (ACC1 - FB_A1 * Revb.FB_ALPHA) >> 16 );
_spu2mem[mix_dest_a0] = clamp_mix( ACC0 - ((FB_A0 * Revb.FB_ALPHA - 1) >> 15) );
_spu2mem[mix_dest_a1] = clamp_mix( ACC1 - ((FB_A1 * Revb.FB_ALPHA - 1) >> 15) );
const s32 acc_fb_mix_a = (FB_A0<<16) + ( ((ACC0>>16) - FB_A0) * Revb.FB_ALPHA );
const s32 acc_fb_mix_b = (FB_A1<<16) + ( ((ACC1>>16) - FB_A1) * Revb.FB_ALPHA );
const s32 acc_fb_mix_a = FB_A0 + (((ACC0 - FB_A0) * Revb.FB_ALPHA - 1) >> 15);
const s32 acc_fb_mix_b = FB_A1 + (((ACC1 - FB_A1) * Revb.FB_ALPHA - 1) >> 15);
_spu2mem[mix_dest_b0] = clamp_mix( ( acc_fb_mix_a - (_spu2mem[fb_src_b0] * Revb.FB_X) ) >> 16 );
_spu2mem[mix_dest_b1] = clamp_mix( ( acc_fb_mix_b - (_spu2mem[fb_src_b1] * Revb.FB_X) ) >> 16 );
_spu2mem[mix_dest_b0] = clamp_mix( ( acc_fb_mix_a - (_spu2mem[fb_src_b0] * Revb.FB_X - 1) ) >> 15 );
_spu2mem[mix_dest_b1] = clamp_mix( ( acc_fb_mix_b - (_spu2mem[fb_src_b1] * Revb.FB_X - 1) ) >> 15 );
upbuf[ubpos] = clamp_mix( StereoOut32(
(_spu2mem[mix_dest_a0] + _spu2mem[mix_dest_b0]), // left