X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=plugins%2Fdfsound%2Fadsr.c;h=23ff3df62a537fb2031bc123ecd1547b2f1239d6;hb=0de2ae236e4f4cd7c9fb0ee648037f93753c02ff;hp=9e328620a0ca52201c9ec1193ce43b6d5820becc;hpb=c632283d5c48d7731ec5704c3d5eef54951fec20;p=pcsx_rearmed.git diff --git a/plugins/dfsound/adsr.c b/plugins/dfsound/adsr.c index 9e328620..23ff3df6 100644 --- a/plugins/dfsound/adsr.c +++ b/plugins/dfsound/adsr.c @@ -63,9 +63,9 @@ INLINE void StartADSR(int ch) // MIX ADSR //////////////////////////////////////////////////////////////////////// -static int MixADSR(ADSRInfoEx *adsr, int ns_to) +static int MixADSR(int *samples, ADSRInfoEx *adsr, int ns_to) { - int EnvelopeVol = adsr->EnvelopeVol; + unsigned int EnvelopeVol = adsr->EnvelopeVol; int ns = 0, val, rto, level; if (adsr->State == ADSR_RELEASE) @@ -77,11 +77,11 @@ static int MixADSR(ADSRInfoEx *adsr, int ns_to) for (; ns < ns_to; ns++) { EnvelopeVol += ((long long)val * EnvelopeVol) >> (15+16); - if (EnvelopeVol <= 0) + if ((signed int)EnvelopeVol <= 0) break; - ChanBuf[ns] *= EnvelopeVol >> 21; - ChanBuf[ns] >>= 10; + samples[ns] *= (signed int)EnvelopeVol >> 21; + samples[ns] >>= 10; } } else @@ -89,11 +89,11 @@ static int MixADSR(ADSRInfoEx *adsr, int ns_to) for (; ns < ns_to; ns++) { EnvelopeVol += val; - if (EnvelopeVol <= 0) + if ((signed int)EnvelopeVol <= 0) break; - ChanBuf[ns] *= EnvelopeVol >> 21; - ChanBuf[ns] >>= 10; + samples[ns] *= (signed int)EnvelopeVol >> 21; + samples[ns] >>= 10; } } @@ -111,14 +111,14 @@ static int MixADSR(ADSRInfoEx *adsr, int ns_to) for (; ns < ns_to; ns++) { EnvelopeVol += val; - if (EnvelopeVol < 0) + if ((signed int)EnvelopeVol < 0) // overflow break; - ChanBuf[ns] *= EnvelopeVol >> 21; - ChanBuf[ns] >>= 10; + samples[ns] *= (signed int)EnvelopeVol >> 21; + samples[ns] >>= 10; } - if (EnvelopeVol < 0) // overflow + if ((signed int)EnvelopeVol < 0) // overflow { EnvelopeVol = 0x7fffffff; adsr->State = ADSR_DECAY; @@ -136,11 +136,11 @@ static int MixADSR(ADSRInfoEx *adsr, int ns_to) for (; ns < ns_to; ) { EnvelopeVol += ((long long)val * EnvelopeVol) >> (15+16); - if (EnvelopeVol < 0) + if ((signed int)EnvelopeVol < 0) EnvelopeVol = 0; - ChanBuf[ns] *= EnvelopeVol >> 21; - ChanBuf[ns] >>= 10; + samples[ns] *= EnvelopeVol >> 21; + samples[ns] >>= 10; ns++; if (((EnvelopeVol >> 27) & 0xf) <= level) @@ -170,15 +170,15 @@ static int MixADSR(ADSRInfoEx *adsr, int ns_to) for (; ns < ns_to; ns++) { EnvelopeVol += val; - if ((unsigned int)EnvelopeVol >= 0x7fe00000) + if (EnvelopeVol >= 0x7fe00000) { EnvelopeVol = 0x7fffffff; ns = ns_to; break; } - ChanBuf[ns] *= EnvelopeVol >> 21; - ChanBuf[ns] >>= 10; + samples[ns] *= (signed int)EnvelopeVol >> 21; + samples[ns] >>= 10; } } else @@ -189,11 +189,11 @@ static int MixADSR(ADSRInfoEx *adsr, int ns_to) for (; ns < ns_to; ns++) { EnvelopeVol += ((long long)val * EnvelopeVol) >> (15+16); - if (EnvelopeVol < 0) + if ((signed int)EnvelopeVol < 0) break; - ChanBuf[ns] *= EnvelopeVol >> 21; - ChanBuf[ns] >>= 10; + samples[ns] *= (signed int)EnvelopeVol >> 21; + samples[ns] >>= 10; } } else @@ -201,11 +201,11 @@ static int MixADSR(ADSRInfoEx *adsr, int ns_to) for (; ns < ns_to; ns++) { EnvelopeVol += val; - if (EnvelopeVol < 0) + if ((signed int)EnvelopeVol < 0) break; - ChanBuf[ns] *= EnvelopeVol >> 21; - ChanBuf[ns] >>= 10; + samples[ns] *= (signed int)EnvelopeVol >> 21; + samples[ns] >>= 10; } } } @@ -219,7 +219,7 @@ done: static int SkipADSR(ADSRInfoEx *adsr, int ns_to) { - int EnvelopeVol = adsr->EnvelopeVol; + unsigned int EnvelopeVol = adsr->EnvelopeVol; int ns = 0, val, rto, level; int64_t v64; @@ -231,7 +231,7 @@ static int SkipADSR(ADSRInfoEx *adsr, int ns_to) for (; ns < ns_to; ns++) { EnvelopeVol += ((long long)val * EnvelopeVol) >> (15+16); - if (EnvelopeVol <= 0) + if ((signed int)EnvelopeVol <= 0) break; } } @@ -257,10 +257,10 @@ static int SkipADSR(ADSRInfoEx *adsr, int ns_to) for (; ns < ns_to; ns++) { EnvelopeVol += val; - if (EnvelopeVol < 0) + if ((signed int)EnvelopeVol < 0) break; } - if (EnvelopeVol < 0) // overflow + if ((signed int)EnvelopeVol < 0) // overflow { EnvelopeVol = 0x7fffffff; adsr->State = ADSR_DECAY; @@ -278,7 +278,7 @@ static int SkipADSR(ADSRInfoEx *adsr, int ns_to) for (; ns < ns_to; ) { EnvelopeVol += ((long long)val * EnvelopeVol) >> (15+16); - if (EnvelopeVol < 0) + if ((signed int)EnvelopeVol < 0) EnvelopeVol = 0; ns++; @@ -320,7 +320,7 @@ static int SkipADSR(ADSRInfoEx *adsr, int ns_to) for (; ns < ns_to; ns++) { EnvelopeVol += ((long long)val * EnvelopeVol) >> (15+16); - if (EnvelopeVol < 0) + if ((signed int)EnvelopeVol < 0) break; } } @@ -330,10 +330,7 @@ static int SkipADSR(ADSRInfoEx *adsr, int ns_to) v64 += (int64_t)val * (ns_to - ns); EnvelopeVol = (int)v64; if (v64 > 0) - { ns = ns_to; - break; - } } } break;