From 07bd309f731eefa49208d77a35507a7b7448ffb6 Mon Sep 17 00:00:00 2001 From: notaz Date: Fri, 16 Nov 2012 00:30:32 +0200 Subject: [PATCH] spu: stop at 0 volume --- plugins/dfsound/adsr.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/plugins/dfsound/adsr.c b/plugins/dfsound/adsr.c index e4873dfd..79f593ca 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; -- 2.39.5