| ... | ... |
@@ -443,10 +443,16 @@ void Channel::Update() |
| 443 | 443 |
this->state = CS_ATTACK; |
| 444 | 444 |
// Fall down |
| 445 | 445 |
case CS_ATTACK: |
| 446 |
- this->ampl = (this->ampl * static_cast<int>(this->attackLvl)) / 255; |
|
| 446 |
+ {
|
|
| 447 |
+ int newAmpl = this->ampl; |
|
| 448 |
+ do |
|
| 449 |
+ newAmpl = (newAmpl * static_cast<int>(this->attackLvl)) / 256; |
|
| 450 |
+ while (newAmpl == this->ampl); |
|
| 451 |
+ this->ampl = newAmpl; |
|
| 447 | 452 |
if (!this->ampl) |
| 448 | 453 |
this->state = CS_DECAY; |
| 449 | 454 |
break; |
| 455 |
+ } |
|
| 450 | 456 |
case CS_DECAY: |
| 451 | 457 |
{
|
| 452 | 458 |
this->ampl -= static_cast<int>(this->decayRate); |
| ... | ... |
@@ -536,6 +542,8 @@ void Channel::Update() |
| 536 | 542 |
if (bVolNeedUpdate) |
| 537 | 543 |
{
|
| 538 | 544 |
int totalVol = this->ampl >> 7; |
| 545 |
+ if (totalVol == -1) |
|
| 546 |
+ this->ampl = 0; |
|
| 539 | 547 |
totalVol += this->extAmpl; |
| 540 | 548 |
totalVol += this->velocity; |
| 541 | 549 |
if (bModulation && this->modType == 1) |