the final volume fix i think

all 5 test cases pass
This commit is contained in:
tildearrow 2021-05-17 15:36:14 -05:00
parent 9736b77401
commit ceda9a8058
3 changed files with 12 additions and 10 deletions

View File

@ -14,7 +14,7 @@ void DivPlatformSMS::tick() {
chan[i].std.next();
if (chan[i].std.hadVol) {
chan[i].outVol=(chan[i].vol*chan[i].std.vol)>>4;
sn->write(0x90|(i<<5)|(15-chan[i].outVol));
sn->write(0x90|(i<<5)|(15-(chan[i].outVol&15)));
}
if (chan[i].std.hadArp) {
if (chan[i].std.arpMode) {
@ -81,7 +81,7 @@ int DivPlatformSMS::dispatch(DivCommand c) {
chan[c.chan].freqChanged=true;
chan[c.chan].note=c.value;
chan[c.chan].active=true;
sn->write(0x90|c.chan<<5|(15-chan[c.chan].vol));
sn->write(0x90|c.chan<<5|(15-(chan[c.chan].vol&15)));
chan[c.chan].std.init(parent->getIns(chan[c.chan].ins));
break;
case DIV_CMD_NOTE_OFF:
@ -99,7 +99,7 @@ int DivPlatformSMS::dispatch(DivCommand c) {
if (!chan[c.chan].std.hasVol) {
chan[c.chan].outVol=c.value;
}
sn->write(0x90|c.chan<<5|(15-chan[c.chan].vol));
sn->write(0x90|c.chan<<5|(15-(chan[c.chan].vol&15)));
}
break;
case DIV_CMD_GET_VOLUME:

View File

@ -134,7 +134,7 @@ void DivEngine::processRow(int i, bool afterDelay) {
// volume
if (pat->data[curRow][3]!=-1) {
if ((chan[i].volume>>8)!=pat->data[curRow][3]) {
if ((min(chan[i].volMax,chan[i].volume)>>8)!=pat->data[curRow][3]) {
chan[i].volume=pat->data[curRow][3]<<8;
dispatch->dispatch(DivCommand(DIV_CMD_VOLUME,i,chan[i].volume>>8));
}
@ -242,7 +242,7 @@ void DivEngine::processRow(int i, bool afterDelay) {
if (chan[i].legato) {
dispatch->dispatch(DivCommand(DIV_CMD_LEGATO,i,chan[i].note));
} else {
dispatch->dispatch(DivCommand(DIV_CMD_NOTE_ON,i,chan[i].note));
dispatch->dispatch(DivCommand(DIV_CMD_NOTE_ON,i,chan[i].note,chan[i].volume>>8));
}
chan[i].doNote=false;
}
@ -344,16 +344,15 @@ void DivEngine::nextTick() {
}
}
if (chan[i].volSpeed!=0) {
//chan[i].volume=(chan[i].volume&0xff)|(dispatch->dispatch(DivCommand(DIV_CMD_GET_VOLUME,i))<<8);
chan[i].volume=(chan[i].volume&0xff)|(dispatch->dispatch(DivCommand(DIV_CMD_GET_VOLUME,i))<<8);
chan[i].volume+=chan[i].volSpeed;
if (chan[i].volume>chan[i].volMax) {
chan[i].volume=chan[i].volMax;
chan[i].volSpeed=0;
dispatch->dispatch(DivCommand(DIV_CMD_VOLUME,i,chan[i].volume>>8));
} else if (chan[i].volume<0) {
chan[i].volSpeed=0;
chan[i].volume=chan[i].volMax;
dispatch->dispatch(DivCommand(DIV_CMD_VOLUME,i,0));
chan[i].volume=chan[i].volMax+0x100;
dispatch->dispatch(DivCommand(DIV_CMD_VOLUME,i,chan[i].volume>>8));
} else {
dispatch->dispatch(DivCommand(DIV_CMD_VOLUME,i,chan[i].volume>>8));
}

View File

@ -6,4 +6,7 @@
typedef std::string String;
#endif
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))
#endif