From 3c106f78611ca756b99bc00e6d49806ec6942e50 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Thu, 30 Oct 2025 01:49:02 -0500 Subject: [PATCH] improve time tracking on step play now it fetches row time from song timestamps also syncs file player! --- src/engine/engine.cpp | 4 ++++ src/engine/playback.cpp | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp index 0616f4f3b..9c1825f4e 100644 --- a/src/engine/engine.cpp +++ b/src/engine/engine.cpp @@ -2060,6 +2060,10 @@ bool DivEngine::playToRow(int row) { } void DivEngine::stepOne(int row) { + if (curFilePlayer && filePlayerSync) { + curFilePlayer->stop(); + } + if (!isPlaying()) { BUSY_BEGIN_SOFT; freelance=false; diff --git a/src/engine/playback.cpp b/src/engine/playback.cpp index 7d1217d51..70595e3b0 100644 --- a/src/engine/playback.cpp +++ b/src/engine/playback.cpp @@ -2169,6 +2169,14 @@ bool DivEngine::nextTick(bool noAccum, bool inhibitLowLat) { prevOrder=curOrder; prevRow=curRow; playPosLock.unlock(); + + // also set the playback position and sync file player if necessary + DivSongTimestamps::Timestamp rowTS=curSubSong->ts.getTimes(curOrder,curRow); + totalSeconds=rowTS.seconds; + totalTicks=rowTS.micros; + if (curFilePlayer && filePlayerSync) { + syncFilePlayer(); + } } // ...and now process the next row! nextRow(); @@ -3295,6 +3303,7 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi // only if the player window is open if (curFilePlayer->getActive()) { refPlayerVol=1.0f-curFilePlayer->getVolume(); + if (refPlayerVol<0.0f) refPlayerVol=0.0f; if (refPlayerVol>1.0f) refPlayerVol=1.0f; } }