SPU2-X: Better ADSR fix this time, by fixing some bad math on my part during the ADSR Decay stage.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@513 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
Jake.Stine 2009-02-17 00:15:31 +00:00
parent 18566548f6
commit 965c8e4b48
1 changed files with 10 additions and 11 deletions

View File

@ -32,13 +32,13 @@ extern u32 core, voice;
void InitADSR() // INIT ADSR void InitADSR() // INIT ADSR
{ {
int r=3; /*u64 r=3;
int rs=1; u64 rs=1;
int rd=0; u64 rd=0;
memset( PsxRates, 0, sizeof( PsxRates ) ); memset( PsxRates, 0, sizeof( PsxRates ) );
for( int i=32; i<160; ++i ) for( uint i=32; i<160; ++i )
{ {
if( r < 0x3FFFFFFF ) if( r < 0x3FFFFFFF )
{ {
@ -50,12 +50,11 @@ void InitADSR() // INIT ADSR
rs <<= 1; rs <<= 1;
} }
} }
if( r > 0x3FFFFFFF ) r = 0x3FFFFFFF;
PsxRates[i] = r; PsxRates[i] = (u32)min( r, 0x3FFFFFFFULL );
} }*/
/*for (int i=0; i<(32+128); i++) for (int i=0; i<(32+128); i++)
{ {
int shift=(i-32)>>2; int shift=(i-32)>>2;
s64 rate=(i&3)+4; s64 rate=(i&3)+4;
@ -65,7 +64,7 @@ void InitADSR() // INIT ADSR
rate <<= shift; rate <<= shift;
PsxRates[i] = (int)min( rate, 0x3fffffffLL ); PsxRates[i] = (int)min( rate, 0x3fffffffLL );
}*/ }
} }
#define VOL(x) (((s32)x)) //24.8 volume #define VOL(x) (((s32)x)) //24.8 volume
@ -122,7 +121,7 @@ bool V_ADSR::Calculate()
// calculate sustain level as a factor of the ADSR maximum volume. // calculate sustain level as a factor of the ADSR maximum volume.
s32 suslev = ADSR_MAX_VOL / (0x10 - SustainLevel); s32 suslev = ((0x80000000 / 0x10 ) * (SustainLevel+1)) - 1;
if( Value <= suslev ) if( Value <= suslev )
{ {