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
{
int r=3;
int rs=1;
int rd=0;
/*u64 r=3;
u64 rs=1;
u64 rd=0;
memset( PsxRates, 0, sizeof( PsxRates ) );
for( int i=32; i<160; ++i )
for( uint i=32; i<160; ++i )
{
if( r < 0x3FFFFFFF )
{
@ -50,12 +50,11 @@ void InitADSR() // INIT ADSR
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;
s64 rate=(i&3)+4;
@ -65,7 +64,7 @@ void InitADSR() // INIT ADSR
rate <<= shift;
PsxRates[i] = (int)min( rate, 0x3fffffffLL );
}*/
}
}
#define VOL(x) (((s32)x)) //24.8 volume
@ -102,7 +101,7 @@ bool V_ADSR::Calculate()
// Case 1 below is for pseudo exponential below 75%.
// Pseudo Exp > 75% and Linear are the same.
if (AttackMode && (Value>=0x60000000))
if( AttackMode && (Value>=0x60000000) )
Value += PsxRates[(AttackRate^0x7f)-0x18+32];
else
Value += PsxRates[(AttackRate^0x7f)-0x10+32];
@ -122,7 +121,7 @@ bool V_ADSR::Calculate()
// 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 )
{