aboutsummaryrefslogtreecommitdiff
path: root/plugins/dfsound
diff options
context:
space:
mode:
authornotaz2012-11-16 00:30:32 +0200
committernotaz2012-11-18 01:40:00 +0200
commit07bd309f731eefa49208d77a35507a7b7448ffb6 (patch)
tree11ca3763a55a084581c371e6d1f1ee9377da8fd5 /plugins/dfsound
parenta02ee86fc0e356c99516bb0d1e76c88a907a796f (diff)
downloadpcsx_rearmed-07bd309f731eefa49208d77a35507a7b7448ffb6.tar.gz
pcsx_rearmed-07bd309f731eefa49208d77a35507a7b7448ffb6.tar.bz2
pcsx_rearmed-07bd309f731eefa49208d77a35507a7b7448ffb6.zip
spu: stop at 0 volume
Diffstat (limited to 'plugins/dfsound')
-rw-r--r--plugins/dfsound/adsr.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/plugins/dfsound/adsr.c b/plugins/dfsound/adsr.c
index e4873df..79f593c 100644
--- a/plugins/dfsound/adsr.c
+++ b/plugins/dfsound/adsr.c
@@ -46,6 +46,10 @@ void InitADSR(void) // INIT ADSR
RateTableAdd[lcv] = ((7 - (lcv&3)) << 16) / denom;
RateTableSub[lcv] = ((-8 + (lcv&3)) << 16) / denom;
+
+ // XXX: this is wrong, we need more bits..
+ if (RateTableAdd[lcv] == 0)
+ RateTableAdd[lcv] = 1;
}
}
@@ -67,12 +71,13 @@ static void MixADSR(int ch, int ns, int ns_to) // MIX ADSR
if (s_chan[ch].bStop) // should be stopped:
{ // do release
val = RateTableSub[s_chan[ch].ADSRX.ReleaseRate * 4];
+
if (s_chan[ch].ADSRX.ReleaseModeExp)
{
for (; ns < ns_to; ns++)
{
EnvelopeVol += ((long long)val * EnvelopeVol) >> (15+16);
- if (EnvelopeVol < 0)
+ if (EnvelopeVol <= 0)
break;
ChanBuf[ns] *= EnvelopeVol >> 21;
@@ -84,7 +89,7 @@ static void MixADSR(int ch, int ns, int ns_to) // MIX ADSR
for (; ns < ns_to; ns++)
{
EnvelopeVol += val;
- if (EnvelopeVol < 0)
+ if (EnvelopeVol <= 0)
break;
ChanBuf[ns] *= EnvelopeVol >> 21;
@@ -92,7 +97,7 @@ static void MixADSR(int ch, int ns, int ns_to) // MIX ADSR
}
}
- if (EnvelopeVol < 0)
+ if (EnvelopeVol <= 0)
goto stop;
goto done;