account for fadeout length, optimize some progress bar calc

This commit is contained in:
LTVA1 2024-08-21 15:11:11 +03:00 committed by tildearrow
parent 17f6ea5c6a
commit a4dae5302b
7 changed files with 180 additions and 28 deletions

View file

@ -2588,7 +2588,8 @@ void FurnaceGUI::exportAudio(String path, DivAudioExportModes mode) {
int loopRow=0;
int loopEnd=0;
e->walkSong(loopOrder,loopRow,loopEnd);
e->findSongLength(songHasSongEndCommand, songOrdersLengths, songLength, loopOrder, loopRow, loopEnd); //for progress estimation
e->findSongLength(loopOrder, loopRow, audioExportOptions.fadeOut, songFadeoutSectionLength, songHasSongEndCommand, songOrdersLengths, songLength); //for progress estimation
songLoopedSectionLength = songLength;
for(int i = 0; i < loopOrder; i++)
@ -2598,9 +2599,74 @@ void FurnaceGUI::exportAudio(String path, DivAudioExportModes mode) {
songLoopedSectionLength -= loopRow;
e->saveAudio(path.c_str(),audioExportOptions);
int totalFiles = 0;
e->getTotalAudioFiles(totalFiles);
int totalLoops = 0;
lengthOfOneFile = songLength;
if(!songHasSongEndCommand)
{
e->getTotalLoops(totalLoops);
lengthOfOneFile += songLoopedSectionLength * totalLoops;
lengthOfOneFile += songFadeoutSectionLength; //account for fadeout
}
totalLength = lengthOfOneFile * totalFiles;
curProgress = 0.0f;
displayExporting=true;
}
/*e->lockEngine([this, progressLambda]()
{
int totalFiles = 0;
e->getTotalAudioFiles(totalFiles);
int loopsLeft = 0;
int totalLoops = 0;
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];
}
if(!songHasSongEndCommand)
{
e->getLoopsLeft(loopsLeft);
e->getTotalLoops(totalLoops);
lengthOfOneFile += songLoopedSectionLength * totalLoops;
lengthOfOneFile += songFadeoutSectionLength; //account for fadeout
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 +
(totalLoops - loopsLeft) * songLength +
lengthOfOneFile * curFile)
/ (float)totalLength;
});*/
void FurnaceGUI::editStr(String* which) {
editString=which;
displayEditString=true;
@ -5837,14 +5903,11 @@ bool FurnaceGUI::loop() {
centerNextWindow(_("Rendering..."),canvasW,canvasH);
if (ImGui::BeginPopupModal(_("Rendering..."),NULL,ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove)) {
ImGui::Text(_("Please wait..."));
float progress = 0.0f;
float* progressLambda = &progress;
float* progressLambda = &curProgress;
if(e->isExporting())
{
e->lockEngine([this, progressLambda]()
{
int totalFiles = 0;
e->getTotalAudioFiles(totalFiles);
int loopsLeft = 0;
int totalLoops = 0;
@ -5854,8 +5917,6 @@ bool FurnaceGUI::loop() {
int curFile = 0;
e->getCurFileIndex(curFile);
int lengthOfOneFile = songLength;
int curPosInRows = curRow;
for(int i = 0; i < curOrder; i++)
@ -5868,26 +5929,24 @@ bool FurnaceGUI::loop() {
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?
}
if(e->getIsFadingOut()) //we are in fadeout??? why it works like that bruh
{
curPosInRows -= (songLength - songLoopedSectionLength); //a hack so progress bar does not jump?
}
}
//int lengthOfOneFile = songLength * (totalLoops + 1);
//songLoopedSectionLength
int totalLength = lengthOfOneFile * totalFiles;
*progressLambda = (float)(curPosInRows +
(totalLoops - loopsLeft) * songLength +
lengthOfOneFile * curFile)
/ (float)totalLength;
});
}
ImGui::Text(_("%f"), progress);
ImGui::ProgressBar(progress,ImVec2(-FLT_MIN,0));
ImGui::Text(_("%f"), curProgress);
ImGui::ProgressBar(curProgress,ImVec2(-FLT_MIN,0));
if (ImGui::Button(_("Abort"))) {
if (e->haltAudioFile()) {
ImGui::CloseCurrentPopup();