From ad8d1b50604ac3ca0ccdae2a30e51cd5bd1dd2cf Mon Sep 17 00:00:00 2001 From: tildearrow Date: Tue, 11 Mar 2025 04:03:05 -0500 Subject: [PATCH] GUI: improve note input timing during playback, it rounds to nearest cell now this greatly enhances the recording experience to-do: test on higher latencies and see if we have to compensate somehow... --- src/engine/engine.cpp | 9 +++++++++ src/engine/engine.h | 1 + src/gui/gui.cpp | 15 ++++++++++++++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp index da5e35c96..a9d004355 100644 --- a/src/engine/engine.cpp +++ b/src/engine/engine.cpp @@ -2393,6 +2393,15 @@ void DivEngine::getPlayPos(int& order, int& row) { playPosLock.unlock(); } +void DivEngine::getPlayPosTick(int& order, int& row, int& tick, int& speed) { + playPosLock.lock(); + order=prevOrder; + row=prevRow; + tick=ticks; + speed=nextSpeed; + playPosLock.unlock(); +} + int DivEngine::getElapsedBars() { return elapsedBars; } diff --git a/src/engine/engine.h b/src/engine/engine.h index 0c7b94d43..9dfbec181 100644 --- a/src/engine/engine.h +++ b/src/engine/engine.h @@ -965,6 +965,7 @@ class DivEngine { // synchronous get order/row void getPlayPos(int& order, int& row); + void getPlayPosTick(int& order, int& row, int& tick, int& speed); // get beat/bar int getElapsedBars(); diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 1e982db9d..1f43e0647 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -1257,11 +1257,24 @@ void FurnaceGUI::noteInput(int num, int key, int vol) { int ch=cursor.xCoarse; int ord=curOrder; int y=cursor.y; + int tick=0; + int speed=0; if (e->isPlaying()) { - e->getPlayPos(ord,y); + e->getPlayPosTick(ord,y,tick,speed); + if (tick<=(speed/2)) { // round + // TODO: detect 0Dxx/0Bxx? + if (++y>=e->curSubSong->patLen) { + y=0; + if (++ord>=e->curSubSong->ordersLen) { + ord=0; + } + } + } } + logV("chan %d, %d:%d %d/%d",ch,ord,y,tick,speed); + DivPattern* pat=e->curPat[ch].getPattern(e->curOrders->ord[ch][ord],true); bool removeIns=false;