X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=plugins%2Fdfsound%2Fadsr.c;h=a86f461c69c2d3401d9b3afffa694f5c9c5ae802;hp=976315dd081b9a97f3c904066110fc5e03a25047;hb=9ad8abfa940cd5c13eb0653639ea86736b65a2c4;hpb=215ff9e69c0b845f24e7a3aa9faeef06d9276145 diff --git a/plugins/dfsound/adsr.c b/plugins/dfsound/adsr.c index 976315dd..a86f461c 100644 --- a/plugins/dfsound/adsr.c +++ b/plugins/dfsound/adsr.c @@ -57,22 +57,22 @@ void InitADSR(void) // INIT ADSR INLINE void StartADSR(int ch) // MIX ADSR { - s_chan[ch].ADSRX.State=0; // and init some adsr vars + s_chan[ch].ADSRX.State=ADSR_ATTACK; // and init some adsr vars s_chan[ch].ADSRX.EnvelopeVol=0; } //////////////////////////////////////////////////////////////////////// -static int MixADSR(int ch, int ns_to) // MIX ADSR +static int MixADSR(ADSRInfoEx *adsr, int ns_to) { - int EnvelopeVol = s_chan[ch].ADSRX.EnvelopeVol; + int EnvelopeVol = adsr->EnvelopeVol; int ns = 0, val, rto, level; - if (s_chan[ch].bStop) // should be stopped: - { // do release - val = RateTableSub[s_chan[ch].ADSRX.ReleaseRate * 4]; + if (adsr->State == ADSR_RELEASE) + { + val = RateTableSub[adsr->ReleaseRate * 4]; - if (s_chan[ch].ADSRX.ReleaseModeExp) + if (adsr->ReleaseModeExp) { for (; ns < ns_to; ns++) { @@ -100,13 +100,13 @@ static int MixADSR(int ch, int ns_to) // MIX ADSR goto done; } - switch (s_chan[ch].ADSRX.State) + switch (adsr->State) { - case 0: // -> attack + case ADSR_ATTACK: // -> attack rto = 0; - if (s_chan[ch].ADSRX.AttackModeExp && EnvelopeVol >= 0x60000000) + if (adsr->AttackModeExp && EnvelopeVol >= 0x60000000) rto = 8; - val = RateTableAdd[s_chan[ch].ADSRX.AttackRate + rto]; + val = RateTableAdd[adsr->AttackRate + rto]; for (; ns < ns_to; ns++) { @@ -121,7 +121,7 @@ static int MixADSR(int ch, int ns_to) // MIX ADSR if (EnvelopeVol < 0) // overflow { EnvelopeVol = 0x7fffffff; - s_chan[ch].ADSRX.State = 1; + adsr->State = ADSR_DECAY; ns++; // sample is good already goto decay; } @@ -129,9 +129,9 @@ static int MixADSR(int ch, int ns_to) // MIX ADSR //--------------------------------------------------// decay: - case 1: // -> decay - val = RateTableSub[s_chan[ch].ADSRX.DecayRate * 4]; - level = s_chan[ch].ADSRX.SustainLevel; + case ADSR_DECAY: // -> decay + val = RateTableSub[adsr->DecayRate * 4]; + level = adsr->SustainLevel; for (; ns < ns_to; ) { @@ -145,7 +145,7 @@ static int MixADSR(int ch, int ns_to) // MIX ADSR if (((EnvelopeVol >> 27) & 0xf) <= level) { - s_chan[ch].ADSRX.State = 2; + adsr->State = ADSR_SUSTAIN; goto sustain; } } @@ -153,8 +153,8 @@ static int MixADSR(int ch, int ns_to) // MIX ADSR //--------------------------------------------------// sustain: - case 2: // -> sustain - if (s_chan[ch].ADSRX.SustainIncrease) + case ADSR_SUSTAIN: // -> sustain + if (adsr->SustainIncrease) { if (EnvelopeVol >= 0x7fff0000) { @@ -163,9 +163,9 @@ static int MixADSR(int ch, int ns_to) // MIX ADSR } rto = 0; - if (s_chan[ch].ADSRX.SustainModeExp && EnvelopeVol >= 0x60000000) + if (adsr->SustainModeExp && EnvelopeVol >= 0x60000000) rto = 8; - val = RateTableAdd[s_chan[ch].ADSRX.SustainRate + rto]; + val = RateTableAdd[adsr->SustainRate + rto]; for (; ns < ns_to; ns++) { @@ -183,8 +183,8 @@ static int MixADSR(int ch, int ns_to) // MIX ADSR } else { - val = RateTableSub[s_chan[ch].ADSRX.SustainRate]; - if (s_chan[ch].ADSRX.SustainModeExp) + val = RateTableSub[adsr->SustainRate]; + if (adsr->SustainModeExp) { for (; ns < ns_to; ns++) { @@ -213,7 +213,7 @@ static int MixADSR(int ch, int ns_to) // MIX ADSR } done: - s_chan[ch].ADSRX.EnvelopeVol = EnvelopeVol; + adsr->EnvelopeVol = EnvelopeVol; return ns; }