Add --render-tracks CLI command.

This command allows rendering each track of a song to a different file.
It should provide the same functionality as the "Export Tracks" GUI option.

Usage could look like:
lmms --render-tracks project.mmpz -f ogg -o output/
This commit is contained in:
Ryan Roden-Corrent
2015-09-03 12:20:51 -04:00
parent c462261433
commit 795d42987f

View File

@@ -66,6 +66,7 @@
#include "ImportFilter.h"
#include "MainWindow.h"
#include "ProjectRenderer.h"
#include "RenderManager.h"
#include "DataFile.h"
#include "Song.h"
@@ -172,6 +173,7 @@ int main( int argc, char * * argv )
bool exitAfterImport = false;
bool allowRoot = false;
bool renderLoop = false;
bool renderTracks = false;
QString fileToLoad, fileToImport, renderOut, profilerOutputFile;
// first of two command-line parsing stages
@@ -185,6 +187,11 @@ int main( int argc, char * * argv )
{
coreOnly = true;
}
else if( arg == "--render-tracks" )
{
coreOnly = true;
renderTracks = true;
}
else if( arg == "--allowroot" )
{
allowRoot = true;
@@ -288,7 +295,7 @@ int main( int argc, char * * argv )
return EXIT_SUCCESS;
}
else if( arg == "--render" || arg == "-r" )
else if( arg == "--render" || arg == "-r" || arg == "--render-tracks" )
{
++i;
@@ -301,7 +308,7 @@ int main( int argc, char * * argv )
fileToLoad = QString::fromLocal8Bit( argv[i] );
renderOut = baseName( fileToLoad ) + ".";
renderOut = baseName( fileToLoad );
}
else if( arg == "--loop" || arg == "-l" )
{
@@ -319,7 +326,7 @@ int main( int argc, char * * argv )
}
renderOut = baseName( QString::fromLocal8Bit( argv[i] ) ) + ".";
renderOut = baseName( QString::fromLocal8Bit( argv[i] ) );
}
else if( arg == "--format" || arg == "-f" )
{
@@ -588,9 +595,15 @@ int main( int argc, char * * argv )
Engine::getSong()->setExportLoop( renderLoop );
// when rendering multiple tracks, renderOut is a directory
// otherwise, it is a file, so we need to append the file extension
if ( !renderTracks )
{
renderOut = renderOut + ProjectRenderer::getFileExtensionFromFormat(eff);
}
// create renderer
QString extension = ( eff == ProjectRenderer::WaveFile ) ? "wav" : "ogg";
ProjectRenderer * r = new ProjectRenderer( qs, os, eff, renderOut + extension );
RenderManager * r = new RenderManager( qs, os, eff, renderOut );
QCoreApplication::instance()->connect( r,
SIGNAL( finished() ), SLOT( quit() ) );
@@ -606,7 +619,14 @@ int main( int argc, char * * argv )
}
// start now!
r->startProcessing();
if ( renderTracks )
{
r->renderTracks();
}
else
{
r->renderProject();
}
}
else // otherwise, start the GUI
{