Also commented out the code that uses the SSEQ's volume, it seems as if
the DS doesn't use it so I probably shouldn't be using it either.
| ... | ... |
@@ -73,6 +73,8 @@ void Channel::UpdateVol(const Track &trk) |
| 73 | 73 |
int finalVol = trk.ply->masterVol; |
| 74 | 74 |
finalVol += Cnv_Sust(trk.vol); |
| 75 | 75 |
finalVol += Cnv_Sust(trk.expr); |
| 76 |
+ if (finalVol < -AMPL_K) |
|
| 77 |
+ finalVol = -AMPL_K; |
|
| 76 | 78 |
this->extAmpl = finalVol; |
| 77 | 79 |
} |
| 78 | 80 |
|
| ... | ... |
@@ -440,7 +442,7 @@ void Channel::Update() |
| 440 | 442 |
this->state = CS_ATTACK; |
| 441 | 443 |
// Fall down |
| 442 | 444 |
case CS_ATTACK: |
| 443 |
- this->ampl = (static_cast<int>(this->ampl) * static_cast<int>(this->attackLvl)) / 255; |
|
| 445 |
+ this->ampl = (this->ampl * static_cast<int>(this->attackLvl)) / 255; |
|
| 444 | 446 |
if (!this->ampl) |
| 445 | 447 |
this->state = CS_DECAY; |
| 446 | 448 |
break; |
| ... | ... |
@@ -537,19 +539,17 @@ void Channel::Update() |
| 537 | 539 |
totalVol += this->velocity; |
| 538 | 540 |
if (bModulation && this->modType == 1) |
| 539 | 541 |
totalVol += modParam; |
| 540 |
- if (totalVol < -AMPL_K) |
|
| 541 |
- totalVol = -AMPL_K; |
|
| 542 |
- else if (totalVol > 0) |
|
| 543 |
- totalVol = 0; |
|
| 542 |
+ totalVol += AMPL_K; |
|
| 543 |
+ clamp(totalVol, 0, AMPL_K); |
|
| 544 | 544 |
|
| 545 | 545 |
cr &= ~(SOUND_VOL(0x7F) | SOUND_VOLDIV(3)); |
| 546 |
- cr |= SOUND_VOL(static_cast<int>(getvoltbl[totalVol + AMPL_K])); |
|
| 546 |
+ cr |= SOUND_VOL(static_cast<int>(getvoltbl[totalVol])); |
|
| 547 | 547 |
|
| 548 |
- if (totalVol < -240) |
|
| 548 |
+ if (totalVol < AMPL_K - 240) |
|
| 549 | 549 |
cr |= SOUND_VOLDIV(3); |
| 550 |
- else if (totalVol < -120) |
|
| 550 |
+ else if (totalVol < AMPL_K - 120) |
|
| 551 | 551 |
cr |= SOUND_VOLDIV(2); |
| 552 |
- else if (totalVol < -60) |
|
| 552 |
+ else if (totalVol < AMPL_K - 60) |
|
| 553 | 553 |
cr |= SOUND_VOLDIV(1); |
| 554 | 554 |
|
| 555 | 555 |
this->vol = ((cr & SOUND_VOL(0x7F)) << 4) >> calcVolDivShift((cr & SOUND_VOLDIV(3)) >> 8); |
| ... | ... |
@@ -222,8 +222,8 @@ void XSFPlayer_NCSF::GenerateSamples(std::vector<uint8_t> &buf, unsigned offset, |
| 222 | 222 |
leftChannel = muldiv7(leftChannel, 127 - this->player.masterVol); |
| 223 | 223 |
rightChannel = muldiv7(rightChannel, 127 - this->player.masterVol); |
| 224 | 224 |
|
| 225 |
- leftChannel = muldiv7(leftChannel, this->sseqVol); |
|
| 226 |
- rightChannel = muldiv7(rightChannel, this->sseqVol); |
|
| 225 |
+ //leftChannel = muldiv7(leftChannel, this->sseqVol); |
|
| 226 |
+ //rightChannel = muldiv7(rightChannel, this->sseqVol); |
|
| 227 | 227 |
|
| 228 | 228 |
buf[offset++] = leftChannel & 0xFF; |
| 229 | 229 |
buf[offset++] = (leftChannel >> 8) & 0xFF; |