account for non-beginning loop point location

Ig I will optimize some of the calculations later when account for fadeout is added
This commit is contained in:
LTVA1 2024-08-20 22:45:21 +03:00 committed by tildearrow
parent 481a5710df
commit 17f6ea5c6a
2 changed files with 28 additions and 6 deletions

View file

@ -2582,12 +2582,21 @@ int FurnaceGUI::loadStream(String path) {
void FurnaceGUI::exportAudio(String path, DivAudioExportModes mode) { void FurnaceGUI::exportAudio(String path, DivAudioExportModes mode) {
songOrdersLengths.clear();
int loopOrder=0; int loopOrder=0;
int loopRow=0; int loopRow=0;
int loopEnd=0; int loopEnd=0;
e->walkSong(loopOrder,loopRow,loopEnd); e->walkSong(loopOrder,loopRow,loopEnd);
e->findSongLength(songHasSongEndCommand, songOrdersLengths, songLength, loopOrder, loopRow, loopEnd); //for progress estimation 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); e->saveAudio(path.c_str(),audioExportOptions);
displayExporting=true; displayExporting=true;
} }
@ -5839,24 +5848,36 @@ bool FurnaceGUI::loop() {
int loopsLeft = 0; int loopsLeft = 0;
int totalLoops = 0; int totalLoops = 0;
if(!songHasSongEndCommand)
{
e->getLoopsLeft(loopsLeft);
e->getTotalLoops(totalLoops);
}
int curRow = 0; int curRow = 0;
int curOrder = 0; int curOrder = 0;
e->getCurSongPos(curRow, curOrder); e->getCurSongPos(curRow, curOrder);
int curFile = 0; int curFile = 0;
e->getCurFileIndex(curFile); e->getCurFileIndex(curFile);
int lengthOfOneFile = songLength;
int curPosInRows = curRow; int curPosInRows = curRow;
for(int i = 0; i < curOrder; i++) for(int i = 0; i < curOrder; i++)
{ {
curPosInRows += songOrdersLengths[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; int totalLength = lengthOfOneFile * totalFiles;
*progressLambda = (float)(curPosInRows + *progressLambda = (float)(curPosInRows +

View file

@ -1725,6 +1725,7 @@ class FurnaceGUI {
std::vector<int> songOrdersLengths; //lengths of all orders (for drawing song export progress) std::vector<int> songOrdersLengths; //lengths of all orders (for drawing song export progress)
int songLength; //length of all the song in rows 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) bool songHasSongEndCommand; //song has "Song end" command (FFxx)
struct Settings { struct Settings {