Skip to content

Commit

Permalink
Fix wrong lengths of exported tracks, when tracks have different leng…
Browse files Browse the repository at this point in the history
…ths. (#5348)

* Fix wrong lengths of exported tracks, when tracks have different lengths.

Song::updateLength() was called in ProjectRenderer::run() after Song::startExport(),
updating m_length too late, resulting in it being used as the length of the wrong track.

* Fix "Export as loop" resetting after rendering the first track

Co-authored-by: Hyunjin Song <tteu.ingog@gmail.com>
  • Loading branch information
Cyp and PhysSong authored May 19, 2020
1 parent 7f9b4c2 commit 8a190e4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
1 change: 0 additions & 1 deletion src/core/ProjectRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ void ProjectRenderer::run()
PerfLogTimer perfLog("Project Render");

Engine::getSong()->startExport();
Engine::getSong()->updateLength();
// Skip first empty buffer.
Engine::mixer()->nextBuffer();

Expand Down
4 changes: 2 additions & 2 deletions src/core/RenderManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ void RenderManager::renderNextTrack()
m_tracksToRender.pop_back();

// mute everything but the track we are about to render
for( auto it = m_unmuted.begin(); it != m_unmuted.end(); ++it )
for (auto track : m_unmuted)
{
(*it)->setMuted( (*it) != renderTrack );
track->setMuted(track != renderTrack);
}

// for multi-render, prefix each output file with a different number
Expand Down
15 changes: 7 additions & 8 deletions src/core/Song.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -612,16 +612,14 @@ void Song::updateLength()
{
m_length = 0;
m_tracksMutex.lockForRead();
for( TrackList::const_iterator it = tracks().begin();
it != tracks().end(); ++it )
for (auto track : tracks())
{
if( Engine::getSong()->isExporting() &&
( *it )->isMuted() )
if (m_exporting && track->isMuted())
{
continue;
}

const bar_t cur = ( *it )->length();
const bar_t cur = track->length();
if( cur > m_length )
{
m_length = cur;
Expand Down Expand Up @@ -744,6 +742,10 @@ void Song::stop()
void Song::startExport()
{
stop();

m_exporting = true;
updateLength();

if (m_renderBetweenMarkers)
{
m_exportSongBegin = m_exportLoopBegin = m_playPos[Mode_PlaySong].m_timeLine->loopBegin();
Expand Down Expand Up @@ -781,8 +783,6 @@ void Song::startExport()

playSong();

m_exporting = true;

m_vstSyncController.setPlaybackState( true );
}

Expand All @@ -793,7 +793,6 @@ void Song::stopExport()
{
stop();
m_exporting = false;
m_exportLoop = false;

m_vstSyncController.setPlaybackState( m_playing );
}
Expand Down

0 comments on commit 8a190e4

Please sign in to comment.