diff --git a/include/mmp.h b/include/mmp.h index 55f289427..403f90f5e 100644 --- a/include/mmp.h +++ b/include/mmp.h @@ -2,6 +2,7 @@ * mmp.h - class for reading and writing multimedia-project-files * * Copyright (c) 2004-2009 Tobias Doerffel + * Copyright (c) 2012-2013 Paul Giblock

* * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -27,6 +28,7 @@ #define _MMP_H #include +#include #include "export.h" #include "lmms_basics.h" @@ -59,6 +61,7 @@ public: QString nameWithExtension( const QString & _fn ) const; + void write( QTextStream & _strm ); bool writeFile( const QString & _fn ); inline QDomElement & content() diff --git a/src/core/main.cpp b/src/core/main.cpp index 090f032ef..55490628d 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -1,8 +1,9 @@ /* * main.cpp - just main.cpp which is starting up app... * - * Copyright (c) 2004-2011 Tobias Doerffel - * + * Copyright (c) 2004-2013 Tobias Doerffel + * Copyright (c) 2012-2013 Paul Giblock

+ * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or @@ -61,6 +62,7 @@ #include "ImportFilter.h" #include "MainWindow.h" #include "ProjectRenderer.h" +#include "mmp.h" #include "song.h" #warning TODO: move somewhere else @@ -130,7 +132,7 @@ int main( int argc, char * * argv ) QString( argv[i] ) == "-v" ) { printf( "\nLinux MultiMedia Studio %s\n\n" - "Copyright (c) 2004-2008 LMMS developers.\n\n" + "Copyright (c) 2004-2013 LMMS developers.\n\n" "This program is free software; you can redistribute it and/or\n" "modify it under the terms of the GNU General Public\n" "License as published by the Free Software Foundation; either\n" @@ -143,7 +145,7 @@ int main( int argc, char * * argv ) QString( argv[i] ) == "-h" ) ) { printf( "\nLinux MultiMedia Studio %s\n" - "Copyright (c) 2004-2008 LMMS developers.\n\n" + "Copyright (c) 2004-2013 LMMS developers.\n\n" "usage: lmms [ -r ] [ options ]\n" " [ -u ]\n" " [ -d ]\n" @@ -166,7 +168,8 @@ int main( int argc, char * * argv ) "-x, --oversampling specify oversampling\n" " possible values: 1, 2, 4, 8\n" " default: 2\n" - "-u, --upgrade upgrade file and save as \n" + "-u, --upgrade [out] upgrade file and save as \n" + " standard out is used if no output file is specifed\n" "-d, --dump dump XML of compressed file \n" "-v, --version show version information and exit.\n" "-h, --help show this usage information and exit.\n\n", @@ -176,9 +179,18 @@ int main( int argc, char * * argv ) else if( argc > i+1 && ( QString( argv[i] ) == "--upgrade" || QString( argv[i] ) == "-u" ) ) { - file_to_load = argv[i + 1]; - file_to_save = argv[i + 2]; - i += 2; + multimediaProject mmp( QString( argv[i + 1] ) ); + if (argc > i+2) + { + mmp.writeFile( argv[i + 2] ); + } + else + { + QTextStream ts( stdout ); + mmp.write( ts ); + fflush( stdout ); + } + return( EXIT_SUCCESS ); } else if( argc > i && ( QString( argv[i] ) == "--dump" || QString( argv[i] ) == "-d" ) ) @@ -187,7 +199,7 @@ int main( int argc, char * * argv ) f.open( QIODevice::ReadOnly ); QString d = qUncompress( f.readAll() ); printf( "%s\n", d.toUtf8().constData() ); - return( 0 ); + return( EXIT_SUCCESS ); } else if( argc > i && ( QString( argv[i] ) == "--render" || QString( argv[i] ) == "-r" ) ) @@ -371,7 +383,7 @@ int main( int argc, char * * argv ) configManager::inst()->loadConfigFile(); - if( render_out.isEmpty() && file_to_save.isEmpty() ) + if( render_out.isEmpty() ) { // init style and palette QApplication::setStyle( new lmmsStyle() ); @@ -479,31 +491,23 @@ int main( int argc, char * * argv ) engine::getSong()->loadProject( file_to_load ); printf( "done\n" ); - if( !render_out.isEmpty() ) - { - // create renderer - ProjectRenderer * r = new ProjectRenderer( qs, os, eff, - render_out + - QString( ( eff == - ProjectRenderer::WaveFile ) ? - "wav" : "ogg" ) ); - QCoreApplication::instance()->connect( r, - SIGNAL( finished() ), SLOT( quit() ) ); + // create renderer + ProjectRenderer * r = new ProjectRenderer( qs, os, eff, + render_out + + QString( ( eff == + ProjectRenderer::WaveFile ) ? + "wav" : "ogg" ) ); + QCoreApplication::instance()->connect( r, + SIGNAL( finished() ), SLOT( quit() ) ); - // timer for progress-updates - QTimer * t = new QTimer( r ); - r->connect( t, SIGNAL( timeout() ), - SLOT( updateConsoleProgress() ) ); - t->start( 200 ); + // timer for progress-updates + QTimer * t = new QTimer( r ); + r->connect( t, SIGNAL( timeout() ), + SLOT( updateConsoleProgress() ) ); + t->start( 200 ); - // start now! - r->startProcessing(); - } - else - { - engine::getSong()->saveProjectFile( file_to_save ); - return( 0 ); - } + // start now! + r->startProcessing(); } const int ret = app->exec(); diff --git a/src/core/mmp.cpp b/src/core/mmp.cpp index 8200aeb50..adc438fdf 100644 --- a/src/core/mmp.cpp +++ b/src/core/mmp.cpp @@ -2,6 +2,7 @@ * mmp.cpp - implementation of class multimediaProject * * Copyright (c) 2004-2009 Tobias Doerffel + * Copyright (c) 2012-2013 Paul Giblock

* * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -66,6 +67,7 @@ multimediaProject::multimediaProject( ProjectTypes _project_type ) : m_head(), m_type( _project_type ) { + appendChild( createProcessingInstruction("xml", "version=\"1.0\"")); QDomElement root = createElement( "multimedia-project" ); root.setAttribute( "version", MMP_VERSION_STRING ); root.setAttribute( "type", typeName( _project_type ) ); @@ -163,7 +165,7 @@ QString multimediaProject::nameWithExtension( const QString & _fn ) const -bool multimediaProject::writeFile( const QString & _fn ) +void multimediaProject::write( QTextStream & _strm ) { if( type() == SongProject || type() == SongProjectTemplate || type() == InstrumentTrackSettings ) @@ -171,7 +173,14 @@ bool multimediaProject::writeFile( const QString & _fn ) cleanMetaNodes( documentElement() ); } + save(_strm, 2); +} + + + +bool multimediaProject::writeFile( const QString & _fn ) +{ QString fn = nameWithExtension( _fn ); QFile outfile( fn ); if( !outfile.open( QIODevice::WriteOnly | QIODevice::Truncate ) ) @@ -189,14 +198,18 @@ bool multimediaProject::writeFile( const QString & _fn ) ).arg( fn ) ); return false; } - QString xml = "\n" + toString( 2 ); + if( fn.section( '.', -1 ) == "mmpz" ) { + QString xml; + QTextStream ts( &xml ); + write( ts ); outfile.write( qCompress( xml.toUtf8() ) ); } else { - QTextStream( &outfile ) << xml; + QTextStream ts( &outfile ); + write( ts ); } outfile.close(); diff --git a/src/gui/AutomationEditor.cpp b/src/gui/AutomationEditor.cpp index d87b7bf09..7e249bf1b 100644 --- a/src/gui/AutomationEditor.cpp +++ b/src/gui/AutomationEditor.cpp @@ -3,6 +3,7 @@ * actual setting of dynamic values * * Copyright (c) 2008-2013 Tobias Doerffel + * Copyright (c) 2008-2013 Paul Giblock * Copyright (c) 2006-2008 Javier Serrano Polo * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net @@ -89,6 +90,8 @@ AutomationEditor::AutomationEditor() : m_action( NONE ), m_moveStartLevel( 0 ), m_moveStartTick( 0 ), + m_drawLastLevel( 0.0f ), + m_drawLastTick( 0 ), m_ppt( DEFAULT_PPT ), m_y_delta( DEFAULT_Y_DELTA ), m_y_auto( TRUE ),