From ecfea6033aa42c1aa2a21dbeba1319fea7443795 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Wed, 29 Oct 2025 02:39:52 -0500 Subject: [PATCH] DivSongTimestamps, part 3 --- src/engine/song.cpp | 18 +++++++++--------- src/engine/song.h | 2 ++ src/gui/debugWindow.cpp | 26 ++++++++++++++++++++++++++ src/gui/gui.cpp | 1 + src/gui/gui.h | 2 +- src/gui/pattern.cpp | 9 +++++++++ 6 files changed, 48 insertions(+), 10 deletions(-) diff --git a/src/engine/song.cpp b/src/engine/song.cpp index de61d6a8a..f9810b8b4 100644 --- a/src/engine/song.cpp +++ b/src/engine/song.cpp @@ -621,6 +621,15 @@ void DivSubSong::calcTimestamps(int chans, std::vector& groove break; } + // log row time here + if (!endOfSong) { + if (rowChanged) { + if (ts.orders[prevOrder]==NULL) ts.orders[prevOrder]=new DivSongTimestamps::Timestamp[DIV_MAX_ROWS]; + ts.orders[prevOrder][prevRow]=DivSongTimestamps::Timestamp(ts.totalSeconds,ts.totalMicros); + rowChanged=false; + } + } + // update playback time double dt=divider*((double)virtualTempoN/(double)MAX(1,virtualTempoD)); ts.totalTicks++; @@ -636,15 +645,6 @@ void DivSubSong::calcTimestamps(int chans, std::vector& groove // who's gonna play a song for 68 years? if (ts.totalSeconds<0x7fffffff) ts.totalSeconds++; } - - // log row time here - if (!endOfSong) { - if (rowChanged) { - if (ts.orders[curOrder]==NULL) ts.orders[curOrder]=new DivSongTimestamps::Timestamp[DIV_MAX_ROWS]; - ts.orders[curOrder][curRow]=DivSongTimestamps::Timestamp(ts.totalSeconds,ts.totalMicros); - rowChanged=false; - } - } if (ts.maxRow[curOrder]calcSongTimestamps(); + } + + DivSongTimestamps& ts=e->curSubSong->ts; + + ImGui::Text("song duration: %d.%06d (%d ticks; %d rows)",ts.totalSeconds,ts.totalMicros,ts.totalTicks,ts.totalRows); + if (ts.isLoopDefined) { + ImGui::Text("loop region is defined"); + } else { + ImGui::Text("no loop region"); + } + if (ts.isLoopable) { + ImGui::Text("song can loop"); + } else { + ImGui::Text("song will stop"); + } + + ImGui::Text("loop region: %d:%d - %d:%d",ts.loopStart.order,ts.loopStart.row,ts.loopEnd.order,ts.loopEnd.row); + ImGui::Text("loop start time: %d.%06d",ts.loopStartTime.seconds,ts.loopStartTime.micros); + + ImGui::Checkbox("Enable row timestamps (in pattern view)",&debugRowTimestamps); + + ImGui::TreePop(); + } if (ImGui::TreeNode("Sample Debug")) { for (int i=0; isong.sampleLen; i++) { DivSample* sample=e->getSample(i); diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 12aa83ffc..1df5551ce 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -8636,6 +8636,7 @@ FurnaceGUI::FurnaceGUI(): audioEngineChanged(false), settingsChanged(false), debugFFT(false), + debugRowTimestamps(false), vgmExportVersion(0x171), vgmExportTrailingTicks(-1), vgmExportCorrectedRate(44100), diff --git a/src/gui/gui.h b/src/gui/gui.h index 1d96a7047..39bb08435 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -1726,7 +1726,7 @@ class FurnaceGUI { bool safeMode; bool midiWakeUp; bool makeDrumkitMode; - bool audioEngineChanged, settingsChanged, debugFFT; + bool audioEngineChanged, settingsChanged, debugFFT, debugRowTimestamps; bool willExport[DIV_MAX_CHIPS]; int vgmExportVersion; int vgmExportTrailingTicks; diff --git a/src/gui/pattern.cpp b/src/gui/pattern.cpp index 94564817d..bd19d5f01 100644 --- a/src/gui/pattern.cpp +++ b/src/gui/pattern.cpp @@ -406,6 +406,15 @@ inline void FurnaceGUI::patternRow(int i, bool isPlaying, float lineHeight, int for (int k=mustSetXOf; k<=chans; k++) { patChanX[k]=ImGui::GetCursorScreenPos().x; } + + if (debugRowTimestamps) { + DivSongTimestamps::Timestamp rowTS=e->curSubSong->ts.getTimes(ord,i); + if (rowTS.seconds==-1) { + ImGui::Text("---"); + } else { + ImGui::Text("%d.%06d",rowTS.seconds,rowTS.micros); + } + } } void FurnaceGUI::drawPattern() {