\r
static int MixADSR(ADSRInfoEx *adsr, int ns_to)\r
{\r
- int EnvelopeVol = adsr->EnvelopeVol;\r
+ unsigned int EnvelopeVol = adsr->EnvelopeVol;\r
int ns = 0, val, rto, level;\r
\r
if (adsr->State == ADSR_RELEASE)\r
for (; ns < ns_to; ns++)\r
{\r
EnvelopeVol += ((long long)val * EnvelopeVol) >> (15+16);\r
- if (EnvelopeVol <= 0)\r
+ if ((signed int)EnvelopeVol <= 0)\r
break;\r
\r
- ChanBuf[ns] *= EnvelopeVol >> 21;\r
+ ChanBuf[ns] *= (signed int)EnvelopeVol >> 21;\r
ChanBuf[ns] >>= 10;\r
}\r
}\r
for (; ns < ns_to; ns++)\r
{\r
EnvelopeVol += val;\r
- if (EnvelopeVol <= 0)\r
+ if ((signed int)EnvelopeVol <= 0)\r
break;\r
\r
- ChanBuf[ns] *= EnvelopeVol >> 21;\r
+ ChanBuf[ns] *= (signed int)EnvelopeVol >> 21;\r
ChanBuf[ns] >>= 10;\r
}\r
}\r
for (; ns < ns_to; ns++)\r
{\r
EnvelopeVol += val;\r
- if (EnvelopeVol < 0)\r
+ if ((signed int)EnvelopeVol < 0) // overflow\r
break;\r
\r
- ChanBuf[ns] *= EnvelopeVol >> 21;\r
+ ChanBuf[ns] *= (signed int)EnvelopeVol >> 21;\r
ChanBuf[ns] >>= 10;\r
}\r
\r
- if (EnvelopeVol < 0) // overflow\r
+ if ((signed int)EnvelopeVol < 0) // overflow\r
{\r
EnvelopeVol = 0x7fffffff;\r
adsr->State = ADSR_DECAY;\r
for (; ns < ns_to; )\r
{\r
EnvelopeVol += ((long long)val * EnvelopeVol) >> (15+16);\r
- if (EnvelopeVol < 0)\r
+ if ((signed int)EnvelopeVol < 0)\r
EnvelopeVol = 0;\r
\r
ChanBuf[ns] *= EnvelopeVol >> 21;\r
for (; ns < ns_to; ns++)\r
{\r
EnvelopeVol += val;\r
- if ((unsigned int)EnvelopeVol >= 0x7fe00000)\r
+ if (EnvelopeVol >= 0x7fe00000)\r
{\r
EnvelopeVol = 0x7fffffff;\r
ns = ns_to;\r
break;\r
}\r
\r
- ChanBuf[ns] *= EnvelopeVol >> 21;\r
+ ChanBuf[ns] *= (signed int)EnvelopeVol >> 21;\r
ChanBuf[ns] >>= 10;\r
}\r
}\r
for (; ns < ns_to; ns++)\r
{\r
EnvelopeVol += ((long long)val * EnvelopeVol) >> (15+16);\r
- if (EnvelopeVol < 0) \r
+ if ((signed int)EnvelopeVol < 0)\r
break;\r
\r
- ChanBuf[ns] *= EnvelopeVol >> 21;\r
+ ChanBuf[ns] *= (signed int)EnvelopeVol >> 21;\r
ChanBuf[ns] >>= 10;\r
}\r
}\r
for (; ns < ns_to; ns++)\r
{\r
EnvelopeVol += val;\r
- if (EnvelopeVol < 0) \r
+ if ((signed int)EnvelopeVol < 0)\r
break;\r
\r
- ChanBuf[ns] *= EnvelopeVol >> 21;\r
+ ChanBuf[ns] *= (signed int)EnvelopeVol >> 21;\r
ChanBuf[ns] >>= 10;\r
}\r
}\r
\r
static int SkipADSR(ADSRInfoEx *adsr, int ns_to)\r
{\r
- int EnvelopeVol = adsr->EnvelopeVol;\r
+ unsigned int EnvelopeVol = adsr->EnvelopeVol;\r
int ns = 0, val, rto, level;\r
int64_t v64;\r
\r
for (; ns < ns_to; ns++)\r
{\r
EnvelopeVol += ((long long)val * EnvelopeVol) >> (15+16);\r
- if (EnvelopeVol <= 0)\r
+ if ((signed int)EnvelopeVol <= 0)\r
break;\r
}\r
}\r
for (; ns < ns_to; ns++)\r
{\r
EnvelopeVol += val;\r
- if (EnvelopeVol < 0)\r
+ if ((signed int)EnvelopeVol < 0)\r
break;\r
}\r
- if (EnvelopeVol < 0) // overflow\r
+ if ((signed int)EnvelopeVol < 0) // overflow\r
{\r
EnvelopeVol = 0x7fffffff;\r
adsr->State = ADSR_DECAY;\r
for (; ns < ns_to; )\r
{\r
EnvelopeVol += ((long long)val * EnvelopeVol) >> (15+16);\r
- if (EnvelopeVol < 0)\r
+ if ((signed int)EnvelopeVol < 0)\r
EnvelopeVol = 0;\r
\r
ns++;\r
for (; ns < ns_to; ns++)\r
{\r
EnvelopeVol += ((long long)val * EnvelopeVol) >> (15+16);\r
- if (EnvelopeVol < 0)\r
+ if ((signed int)EnvelopeVol < 0)\r
break;\r
}\r
}\r
v64 += (int64_t)val * (ns_to - ns);\r
EnvelopeVol = (int)v64;\r
if (v64 > 0)\r
- {\r
ns = ns_to;\r
- break;\r
- }\r
}\r
}\r
break;\r