Export percentage calc now takes considers loop markers as necessary

This commit is contained in:
Colin Wallace
2015-07-14 01:53:47 +00:00
parent 3ff55d755c
commit ffba37c7f2
3 changed files with 30 additions and 4 deletions

View File

@@ -25,6 +25,8 @@
#ifndef SONG_H
#define SONG_H
#include <utility>
#include <QtCore/QSharedMemory>
#include <QtCore/QVector>
@@ -163,6 +165,7 @@ public:
}
bool isExportDone() const;
std::pair<MidiTime, MidiTime> getExportEndpoints() const;
inline void setRenderBetweenMarkers( bool renderBetweenMarkers )
{

View File

@@ -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<MidiTime, MidiTime> 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;

View File

@@ -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<MidiTime, MidiTime> Song::getExportEndpoints() const
{
if ( m_renderBetweenMarkers )
{
return std::pair<MidiTime, MidiTime>(
m_playPos[Mode_PlaySong].m_timeLine->loopBegin(),
m_playPos[Mode_PlaySong].m_timeLine->loopEnd()
);
}
else if ( m_exportLoop )
{
return std::pair<MidiTime, MidiTime>( 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, MidiTime>( MidiTime(0, 0), MidiTime(m_length+1, 0) );
}
}