From 17f6ea5c6a2f9aad15c52c2f163c95ae3ab96232 Mon Sep 17 00:00:00 2001 From: LTVA1 <87536432+LTVA1@users.noreply.github.com> Date: Tue, 20 Aug 2024 22:45:21 +0300 Subject: [PATCH] account for non-beginning loop point location Ig I will optimize some of the calculations later when account for fadeout is added --- src/gui/gui.cpp | 33 +++++++++++++++++++++++++++------ src/gui/gui.h | 1 + 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index ead92f80d..4e314959d 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -2582,12 +2582,21 @@ int FurnaceGUI::loadStream(String path) { void FurnaceGUI::exportAudio(String path, DivAudioExportModes mode) { + songOrdersLengths.clear(); + int loopOrder=0; int loopRow=0; int loopEnd=0; e->walkSong(loopOrder,loopRow,loopEnd); e->findSongLength(songHasSongEndCommand, songOrdersLengths, songLength, loopOrder, loopRow, loopEnd); //for progress estimation + songLoopedSectionLength = songLength; + for(int i = 0; i < loopOrder; i++) + { + songLoopedSectionLength -= songOrdersLengths[i]; + } + songLoopedSectionLength -= loopRow; + e->saveAudio(path.c_str(),audioExportOptions); displayExporting=true; } @@ -5839,24 +5848,36 @@ bool FurnaceGUI::loop() { int loopsLeft = 0; int totalLoops = 0; - if(!songHasSongEndCommand) - { - e->getLoopsLeft(loopsLeft); - e->getTotalLoops(totalLoops); - } int curRow = 0; int curOrder = 0; e->getCurSongPos(curRow, curOrder); int curFile = 0; e->getCurFileIndex(curFile); + int lengthOfOneFile = songLength; + int curPosInRows = curRow; for(int i = 0; i < curOrder; i++) { curPosInRows += songOrdersLengths[i]; } - int lengthOfOneFile = songLength * (totalLoops + 1); + + if(!songHasSongEndCommand) + { + e->getLoopsLeft(loopsLeft); + e->getTotalLoops(totalLoops); + + lengthOfOneFile += songLoopedSectionLength * totalLoops; + + if(totalLoops != loopsLeft) //we are going 2nd, 3rd, etc. time through the song + { + curPosInRows -= (songLength - songLoopedSectionLength); //a hack so progress bar does not jump? + } + } + + //int lengthOfOneFile = songLength * (totalLoops + 1); + //songLoopedSectionLength int totalLength = lengthOfOneFile * totalFiles; *progressLambda = (float)(curPosInRows + diff --git a/src/gui/gui.h b/src/gui/gui.h index 87f72a815..46ec9f592 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -1725,6 +1725,7 @@ class FurnaceGUI { std::vector songOrdersLengths; //lengths of all orders (for drawing song export progress) int songLength; //length of all the song in rows + int songLoopedSectionLength; //length of looped part of the song bool songHasSongEndCommand; //song has "Song end" command (FFxx) struct Settings {