From e5b3975b12420ec7f403dfcceeca3351e00b8e55 Mon Sep 17 00:00:00 2001 From: Paul Giblock Date: Fri, 23 Mar 2012 13:21:26 -0400 Subject: [PATCH 1/4] Initialize line-drawer in AutomationEditor Possible endless loop if these two state variables are not intialized. Now a line will have the origin of (0,0) if drawn (shift-click) without previously clicking on a starting spot. Perhaps not the best fix, but it works. And I think allowing this first line (instead of blocking it) is better for the enabling the user to accidently discover the feature. Conflicts: src/gui/AutomationEditor.cpp --- src/gui/AutomationEditor.cpp | 3 +++ 1 file changed, 3 insertions(+) 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 ), From b2dc6375b982a08c3855d83c796820b632fc1ef5 Mon Sep 17 00:00:00 2001 From: Paul Giblock Date: Wed, 27 Feb 2013 13:41:08 -0500 Subject: [PATCH 2/4] Update copyright date to 2013 in usage Conflicts: src/core/main.cpp --- src/core/main.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/main.cpp b/src/core/main.cpp index 090f032ef..64d0f7324 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -1,8 +1,8 @@ /* * main.cpp - just main.cpp which is starting up app... * - * Copyright (c) 2004-2011 Tobias Doerffel - * + * Copyright (c) 2004-2013 Tobias Doerffel + * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or @@ -130,7 +130,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 +143,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" From 8bbbdacfcba8da3ef8c527d2bbfb1be412b3f5ca Mon Sep 17 00:00:00 2001 From: Paul Giblock Date: Mon, 28 May 2012 00:57:18 -0400 Subject: [PATCH 3/4] Add support for upgrading presets This is in addition to songs. Simply use multimediaProject. Don't screw around with Song(). Also, needed to move creation of xml preamble (processing instruction) due to duplicate entry when doing a load/save. Conflicts: src/core/main.cpp --- src/core/main.cpp | 53 ++++++++++++++++++++++------------------------- src/core/mmp.cpp | 4 +++- 2 files changed, 28 insertions(+), 29 deletions(-) diff --git a/src/core/main.cpp b/src/core/main.cpp index 64d0f7324..c94898b15 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -2,6 +2,7 @@ * main.cpp - just main.cpp which is starting up app... * * Copyright (c) 2004-2013 Tobias Doerffel + * Copyright (c) 2012-2013 Paul Giblock

* * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -61,6 +62,7 @@ #include "ImportFilter.h" #include "MainWindow.h" #include "ProjectRenderer.h" +#include "mmp.h" #include "song.h" #warning TODO: move somewhere else @@ -176,9 +178,12 @@ 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+1) + { + mmp.writeFile(argv[i + 2]); + } + return( EXIT_SUCCESS ); } else if( argc > i && ( QString( argv[i] ) == "--dump" || QString( argv[i] ) == "-d" ) ) @@ -187,7 +192,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 +376,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 +484,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..cd71651f7 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 ) ); @@ -189,7 +191,7 @@ bool multimediaProject::writeFile( const QString & _fn ) ).arg( fn ) ); return false; } - QString xml = "\n" + toString( 2 ); + QString xml = toString( 2 ); if( fn.section( '.', -1 ) == "mmpz" ) { outfile.write( qCompress( xml.toUtf8() ) ); From 867b13691d5e550db03b3268d67c7acf27688372 Mon Sep 17 00:00:00 2001 From: Paul Giblock Date: Mon, 28 May 2012 02:37:29 -0400 Subject: [PATCH 4/4] Add support for upgrading to standard output Useful for me to initially import LMMS presets for use in lmms-lv2. --- include/mmp.h | 3 +++ src/core/main.cpp | 13 ++++++++++--- src/core/mmp.cpp | 17 ++++++++++++++--- 3 files changed, 27 insertions(+), 6 deletions(-) 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 c94898b15..55490628d 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -168,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", @@ -179,9 +180,15 @@ int main( int argc, char * * argv ) QString( argv[i] ) == "-u" ) ) { multimediaProject mmp( QString( argv[i + 1] ) ); - if (argc > i+1) + if (argc > i+2) { - mmp.writeFile(argv[i + 2]); + mmp.writeFile( argv[i + 2] ); + } + else + { + QTextStream ts( stdout ); + mmp.write( ts ); + fflush( stdout ); } return( EXIT_SUCCESS ); } diff --git a/src/core/mmp.cpp b/src/core/mmp.cpp index cd71651f7..adc438fdf 100644 --- a/src/core/mmp.cpp +++ b/src/core/mmp.cpp @@ -165,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 ) @@ -173,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 ) ) @@ -191,14 +198,18 @@ bool multimediaProject::writeFile( const QString & _fn ) ).arg( fn ) ); return false; } - QString xml = 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();