From ffba37c7f2a895e8b80098d5612cee6f461bfa54 Mon Sep 17 00:00:00 2001 From: Colin Wallace Date: Tue, 14 Jul 2015 01:53:47 +0000 Subject: [PATCH] Export percentage calc now takes considers loop markers as necessary --- include/Song.h | 3 +++ src/core/ProjectRenderer.cpp | 9 ++++++--- src/core/Song.cpp | 22 +++++++++++++++++++++- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/include/Song.h b/include/Song.h index 7c65641ec..8f33a208b 100644 --- a/include/Song.h +++ b/include/Song.h @@ -25,6 +25,8 @@ #ifndef SONG_H #define SONG_H +#include + #include #include @@ -163,6 +165,7 @@ public: } bool isExportDone() const; + std::pair getExportEndpoints() const; inline void setRenderBetweenMarkers( bool renderBetweenMarkers ) { diff --git a/src/core/ProjectRenderer.cpp b/src/core/ProjectRenderer.cpp index 2aaf5665a..b9a9ead73 100644 --- a/src/core/ProjectRenderer.cpp +++ b/src/core/ProjectRenderer.cpp @@ -163,17 +163,20 @@ void ProjectRenderer::run() //skip first empty buffer Engine::mixer()->nextBuffer(); - const Song::PlayPos & pp = Engine::getSong()->getPlayPos( + const Song::PlayPos & exportPos = Engine::getSong()->getPlayPos( Song::Mode_PlaySong ); m_progress = 0; - const int sl = ( Engine::getSong()->length() + 1 ) * 192; + std::pair exportEndpoints = Engine::getSong()->getExportEndpoints(); + tick_t startTick = exportEndpoints.first.getTicks(); + tick_t lengthTicks = exportEndpoints.second.getTicks() - startTick; + // Continually track and emit progress percentage to listeners while( Engine::getSong()->isExportDone() == false && Engine::getSong()->isExporting() == true && !m_abort ) { m_fileDev->processNextBuffer(); - const int nprog = pp * 100 / sl; + const int nprog = lengthTicks == 0 ? 100 : (exportPos.getTicks()-startTick) * 100 / lengthTicks; if( m_progress != nprog ) { m_progress = nprog; diff --git a/src/core/Song.cpp b/src/core/Song.cpp index fb9bd3e59..21ab0ed49 100644 --- a/src/core/Song.cpp +++ b/src/core/Song.cpp @@ -416,7 +416,7 @@ bool Song::isExportDone() const m_playPos[Mode_PlaySong].m_timeLine->loopEnd().getTicks(); } - if( m_exportLoop) + if( m_exportLoop ) { return m_exporting == true && m_playPos[Mode_PlaySong].getTicks() >= @@ -430,6 +430,26 @@ bool Song::isExportDone() const } } +std::pair Song::getExportEndpoints() const +{ + if ( m_renderBetweenMarkers ) + { + return std::pair( + m_playPos[Mode_PlaySong].m_timeLine->loopBegin(), + m_playPos[Mode_PlaySong].m_timeLine->loopEnd() + ); + } + else if ( m_exportLoop ) + { + return std::pair( MidiTime(0, 0), MidiTime(m_length, 0) ); + } + else + { + // if not exporting as a loop, we leave one bar of padding at the end of the song to accomodate reverb, etc. + return std::pair( MidiTime(0, 0), MidiTime(m_length+1, 0) ); + } +} +