{\r
int EnvelopeVol = adsr->EnvelopeVol;\r
int ns = 0, val, rto, level;\r
+ int64_t v64;\r
\r
if (adsr->State == ADSR_RELEASE)\r
{\r
}\r
else\r
{\r
- EnvelopeVol += val * ns_to;\r
- if (EnvelopeVol > 0)\r
+ v64 = EnvelopeVol;\r
+ v64 += (int64_t)val * ns_to;\r
+ EnvelopeVol = (int)v64;\r
+ if (v64 > 0)\r
ns = ns_to;\r
}\r
goto done;\r
case ADSR_SUSTAIN: // -> sustain\r
if (adsr->SustainIncrease)\r
{\r
+ ns = ns_to;\r
+\r
if (EnvelopeVol >= 0x7fff0000)\r
- {\r
- ns = ns_to;\r
break;\r
- }\r
\r
rto = 0;\r
if (adsr->SustainModeExp && EnvelopeVol >= 0x60000000)\r
rto = 8;\r
val = RateTableAdd[adsr->SustainRate + rto];\r
\r
- EnvelopeVol += val * (ns_to - ns);\r
- if ((unsigned int)EnvelopeVol >= 0x7fe00000)\r
- {\r
+ v64 = EnvelopeVol;\r
+ v64 += (int64_t)val * (ns_to - ns);\r
+ EnvelopeVol = (int)v64;\r
+ if (v64 >= 0x7fe00000ll)\r
EnvelopeVol = 0x7fffffff;\r
- ns = ns_to;\r
- break;\r
- }\r
}\r
else\r
{\r
}\r
else\r
{\r
- EnvelopeVol += val * (ns_to - ns);\r
- if (EnvelopeVol > 0)\r
+ v64 = EnvelopeVol;\r
+ v64 += (int64_t)val * (ns_to - ns);\r
+ EnvelopeVol = (int)v64;\r
+ if (v64 > 0)\r
{\r
ns = ns_to;\r
break;\r