From 97a00c7efd86d53eff4b85d35abd0c0b7d5e7c09 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sun, 19 Dec 2021 00:02:48 -0500 Subject: [PATCH] improve 03xx accuracy portamento stops if same note --- src/engine/engine.h | 3 ++- src/engine/playback.cpp | 12 ++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/engine/engine.h b/src/engine/engine.h index f5cdc18dc..1a2da9ef9 100644 --- a/src/engine/engine.h +++ b/src/engine/engine.h @@ -23,7 +23,7 @@ enum DivAudioEngines { struct DivChannelState { std::vector delayed; - int note, pitch, portaSpeed, portaNote; + int note, oldNote, pitch, portaSpeed, portaNote; int volume, volSpeed, cut, rowDelay, volMax; int delayOrder, delayRow; int vibratoDepth, vibratoRate, vibratoPos, vibratoDir, vibratoFine; @@ -33,6 +33,7 @@ struct DivChannelState { DivChannelState(): note(-1), + oldNote(-1), pitch(0), portaSpeed(-1), portaNote(-1), diff --git a/src/engine/playback.cpp b/src/engine/playback.cpp index ac708bd51..8f4cfe9f3 100644 --- a/src/engine/playback.cpp +++ b/src/engine/playback.cpp @@ -348,6 +348,7 @@ void DivEngine::processRow(int i, bool afterDelay) { } dispatchCmd(DivCommand(DIV_CMD_NOTE_OFF,i)); } else if (!(pat->data[whatRow][0]==0 && pat->data[whatRow][1]==0)) { + chan[i].oldNote=chan[i].note; chan[i].note=pat->data[whatRow][0]+pat->data[whatRow][1]*12; if (!chan[i].keyOn) { if (dispatch->keyOffAffectsArp(i)) { @@ -428,8 +429,13 @@ void DivEngine::processRow(int i, bool afterDelay) { chan[i].portaSpeed=-1; dispatchCmd(DivCommand(DIV_CMD_PRE_PORTA,i,false)); } else { - chan[i].portaNote=chan[i].note; - chan[i].portaSpeed=effectVal; + if (chan[i].note==chan[i].oldNote) { + chan[i].portaNote=chan[i].note; + chan[i].portaSpeed=0; + } else { + chan[i].portaNote=chan[i].note; + chan[i].portaSpeed=effectVal; + } chan[i].portaStop=true; chan[i].doNote=false; chan[i].stopOnOff=true; @@ -727,12 +733,14 @@ bool DivEngine::nextTick() { if (chan[i].portaSpeed>0) { if (dispatchCmd(DivCommand(DIV_CMD_NOTE_PORTA,i,chan[i].portaSpeed,chan[i].portaNote))==2 && chan[i].portaStop) { chan[i].portaSpeed=0; + chan[i].oldNote=chan[i].note; chan[i].note=chan[i].portaNote; dispatchCmd(DivCommand(DIV_CMD_LEGATO,i,chan[i].note)); } } if (chan[i].cut>0) { if (--chan[i].cut<1) { + chan[i].oldNote=chan[i].note; chan[i].note=-1; dispatchCmd(DivCommand(DIV_CMD_NOTE_OFF,i)); }