aboutsummaryrefslogtreecommitdiff
path: root/plugins/dfsound/adsr.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/dfsound/adsr.c')
-rw-r--r--plugins/dfsound/adsr.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/plugins/dfsound/adsr.c b/plugins/dfsound/adsr.c
index 976315d..a86f461 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;
}