diff --git a/src/engine/engine.h b/src/engine/engine.h index 12fd05be0..9becc9d5f 100644 --- a/src/engine/engine.h +++ b/src/engine/engine.h @@ -18,7 +18,7 @@ struct DivChannelState { int vibratoDepth, vibratoRate, vibratoPos, vibratoDir, vibratoFine; int tremoloDepth, tremoloRate, tremoloPos; unsigned char arp, arpStage, arpTicks; - bool doNote, legato, portaStop; + bool doNote, legato, portaStop, keyOn; DivChannelState(): note(-1), @@ -40,7 +40,7 @@ struct DivChannelState { arp(0), arpStage(-1), arpTicks(1), - doNote(false), legato(false), portaStop(false) {} + doNote(false), legato(false), portaStop(false), keyOn(false) {} }; class DivEngine { diff --git a/src/engine/playback.cpp b/src/engine/playback.cpp index 910e09169..6d220e3dd 100644 --- a/src/engine/playback.cpp +++ b/src/engine/playback.cpp @@ -163,6 +163,7 @@ void DivEngine::processRow(int i, bool afterDelay) { // note if (pat->data[curRow][0]==100) { chan[i].note=-1; + chan[i].keyOn=false; dispatchCmd(DivCommand(DIV_CMD_NOTE_OFF,i)); } else if (!(pat->data[curRow][0]==0 && pat->data[curRow][1]==0)) { chan[i].note=pat->data[curRow][0]+pat->data[curRow][1]*12; @@ -303,6 +304,13 @@ void DivEngine::processRow(int i, bool afterDelay) { dispatchCmd(DivCommand(DIV_CMD_NOTE_ON,i,chan[i].note,chan[i].volume>>8)); } chan[i].doNote=false; + if (!chan[i].keyOn) { + if (chan[i].portaStop) { + chan[i].portaNote=-1; + chan[i].portaSpeed=-1; + } + } + chan[i].keyOn=true; } // post effects