From 50da20f22e632bd9c7e65be1e277d3e878e277fc Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Wed, 27 Feb 2008 17:53:39 +0000 Subject: [PATCH] rendering from commandline is now done without creating main-window and all the other UI-stuff git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/branches/lmms-mv@727 0778d3d1-df1d-0410-868b-ea421aaaa00d --- ChangeLog | 76 ++++++++++++++++++ include/export_project_dialog.h | 12 +-- src/core/automation_pattern.cpp | 5 +- src/core/engine.cpp | 42 +++++----- src/core/export_project_dialog.cpp | 48 ++++++----- src/core/main.cpp | 124 ++++++++++++++++------------- src/core/song.cpp | 81 ++++++++++++------- 7 files changed, 253 insertions(+), 135 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7636dba3b..0c77143eb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,81 @@ 2008-02-27 Tobias Doerffel + * plugins/ladspa_effect/caps/Compress.cc: + * plugins/ladspa_effect/caps/ToneStack.cc: + * plugins/ladspa_effect/caps/Compress.h: + * plugins/ladspa_effect/caps/ToneStack.h: + * plugins/ladspa_effect/caps/Roessler.h: + * plugins/ladspa_effect/caps/HRTF.cc: + * plugins/ladspa_effect/caps/HRTF.h: + * plugins/ladspa_effect/caps/basics.h: + * plugins/ladspa_effect/caps/Lorenz.cc: + * plugins/ladspa_effect/caps/Lorenz.h: + * plugins/ladspa_effect/caps/Amp.cc: + * plugins/ladspa_effect/caps/Amp.h: + * plugins/ladspa_effect/caps/Pan.h: + * plugins/ladspa_effect/caps/Phaser.cc: + * plugins/ladspa_effect/caps/White.h: + * plugins/ladspa_effect/caps/Preamp.cc: + * plugins/ladspa_effect/caps/Click.cc: + * plugins/ladspa_effect/caps/VCO.cc: + * plugins/ladspa_effect/caps/Clip.cc: + * plugins/ladspa_effect/caps/Click.h: + * plugins/ladspa_effect/caps/VCO.h: + * plugins/ladspa_effect/caps/ToneControls.cc: + * plugins/ladspa_effect/caps/Sin.cc: + * plugins/ladspa_effect/caps/Clip.h: + * plugins/ladspa_effect/caps/Sin.h: + * plugins/ladspa_effect/caps/Scape.cc: + * plugins/ladspa_effect/caps/Scape.h: + * plugins/ladspa_effect/caps/Roessler.cc: + * plugins/ladspa_effect/caps/interface.cc: + * plugins/ladspa_effect/caps/waves/click.h: + * plugins/ladspa_effect/caps/waves/money.h: + * plugins/ladspa_effect/caps/dsp/ToneStack.h: + * plugins/ladspa_effect/caps/dsp/LatFilt.h: + * plugins/ladspa_effect/caps/dsp/TDFII.h: + * plugins/ladspa_effect/caps/dsp/RMS.h: + * plugins/ladspa_effect/caps/dsp/OnePole.h: + * plugins/ladspa_effect/caps/dsp/tonestack/tables.h: + * plugins/ladspa_effect/caps/dsp/tonestack/vs_tab.h: + * plugins/ladspa_effect/caps/dsp/tonestack/ks_tab.h: + * plugins/ladspa_effect/caps/dsp/Eq.h: + * plugins/ladspa_effect/caps/dsp/BiQuad.h: + * plugins/ladspa_effect/caps/dsp/util.h: + * plugins/ladspa_effect/caps/dsp/FPTruncateMode.h: + * plugins/ladspa_effect/caps/dsp/TwelveAX7.h: + * plugins/ladspa_effect/caps/Chorus.cc: + * plugins/ladspa_effect/caps/Cabinet.cc: + * plugins/ladspa_effect/caps/Chorus.h: + * plugins/ladspa_effect/caps/Eq.cc: + * plugins/ladspa_effect/caps/Cabinet.h: + * plugins/ladspa_effect/caps/Eq.h: + * plugins/ladspa_effect/caps/README: + * plugins/ladspa_effect/caps/Pan.cc: + * plugins/ladspa_effect/caps/SweepVF.cc: + * plugins/ladspa_effect/caps/Descriptor.h: + * plugins/ladspa_effect/caps/White.cc: + * plugins/ladspa_effect/caps/SweepVF.h: + * plugins/ladspa_effect/caps/Phaser.h: + * plugins/ladspa_effect/caps/Reverb.cc: + * plugins/ladspa_effect/caps/Makefile.am: + * plugins/ladspa_effect/caps/Reverb.h: + integrated new version of CAPS and fixed miscompilation with GCC 4.3 + + * include/audio_port.h: + * src/audio/audio_port.cpp: + * src/core/mixer.cpp: + lock audioPort-buffers before writing them + + * include/export_project_dialog.h: + * src/core/song.cpp: + * src/core/main.cpp: + * src/core/export_project_dialog.cpp: + * src/core/engine.cpp: + * src/core/automation_pattern.cpp: + rendering from commandline is now done without creating main-window + and all the other UI-stuff + * include/mixer.h: * src/core/mixer.cpp: distribute whole job-queue instead of single jobs and re-assign diff --git a/include/export_project_dialog.h b/include/export_project_dialog.h index ffc0b30f7..cfef9c42a 100644 --- a/include/export_project_dialog.h +++ b/include/export_project_dialog.h @@ -31,14 +31,13 @@ #include "export.h" #include "automatable_model.h" +#include "combobox.h" class QLabel; class QPushButton; class QProgressBar; -class comboBox; -class comboBoxModel; class ledCheckBox; class pixmapButton; @@ -73,16 +72,17 @@ private: static Sint16 s_availableBitrates[]; + comboBoxModel m_typeModel; + comboBoxModel m_kbpsModel; + boolModel m_vbrEnabledModel; + boolModel m_hqmEnabledModel; + QLabel * m_typeLbl; comboBox * m_typeCombo; - comboBoxModel * m_typeModel; QLabel * m_kbpsLbl; comboBox * m_kbpsCombo; - comboBoxModel * m_kbpsModel; ledCheckBox * m_vbrCb; - boolModel * m_vbrEnabledModel; ledCheckBox * m_hqmCb; - boolModel * m_hqmEnabledModel; QLabel * m_hourglassLbl; QPushButton * m_exportBtn; QPushButton * m_cancelBtn; diff --git a/src/core/automation_pattern.cpp b/src/core/automation_pattern.cpp index ead23b6a7..37ffcd5c4 100644 --- a/src/core/automation_pattern.cpp +++ b/src/core/automation_pattern.cpp @@ -139,7 +139,7 @@ midiTime automationPattern::length( void ) const midiTime automationPattern::putValue( const midiTime & _time, const int _value, const bool _quant_pos ) { - midiTime new_time = _quant_pos ? + midiTime new_time = _quant_pos && engine::getAutomationEditor() ? note::quantized( _time, engine::getAutomationEditor()->quantization() ) : _time; @@ -185,7 +185,8 @@ void automationPattern::removeValue( const midiTime & _time ) void automationPattern::clear( void ) { m_time_map.clear(); - if( engine::getAutomationEditor()->currentPattern() == this ) + if( engine::getAutomationEditor() && + engine::getAutomationEditor()->currentPattern() == this ) { engine::getAutomationEditor()->update(); } diff --git a/src/core/engine.cpp b/src/core/engine.cpp index fbfd03d3c..62879a351 100644 --- a/src/core/engine.cpp +++ b/src/core/engine.cpp @@ -43,17 +43,17 @@ bool engine::s_hasGUI = TRUE; float engine::s_framesPerTact64th; -mixer * engine::s_mixer; -mainWindow * engine::s_mainWindow; -bbTrackContainer * engine::s_bbTrackContainer; -song * engine::s_song; -songEditor * engine::s_songEditor; -automationEditor * engine::s_automationEditor; -bbEditor * engine::s_bbEditor; -pianoRoll * engine::s_pianoRoll; -projectNotes * engine::s_projectNotes; -projectJournal * engine::s_projectJournal; -ladspa2LMMS * engine::s_ladspaManager; +mixer * engine::s_mixer = NULL; +mainWindow * engine::s_mainWindow = NULL; +bbTrackContainer * engine::s_bbTrackContainer = NULL; +song * engine::s_song = NULL; +songEditor * engine::s_songEditor = NULL; +automationEditor * engine::s_automationEditor = NULL; +bbEditor * engine::s_bbEditor = NULL; +pianoRoll * engine::s_pianoRoll = NULL; +projectNotes * engine::s_projectNotes = NULL; +projectJournal * engine::s_projectJournal = NULL; +ladspa2LMMS * engine::s_ladspaManager = NULL; QMap engine::s_sampleExtensions; @@ -70,19 +70,25 @@ void engine::init( const bool _has_gui ) s_song = new song; s_bbTrackContainer = new bbTrackContainer; - s_mainWindow = new mainWindow; - s_songEditor = new songEditor( s_song ); - s_projectNotes = new projectNotes; - s_bbEditor = new bbEditor( s_bbTrackContainer ); - s_pianoRoll = new pianoRoll; - s_automationEditor = new automationEditor; + if( s_hasGUI ) + { + s_mainWindow = new mainWindow; + s_songEditor = new songEditor( s_song ); + s_projectNotes = new projectNotes; + s_bbEditor = new bbEditor( s_bbTrackContainer ); + s_pianoRoll = new pianoRoll; + s_automationEditor = new automationEditor; + } s_ladspaManager = new ladspa2LMMS; s_projectJournal->setJournalling( TRUE ); s_mixer->initDevices(); - s_mainWindow->finalize(); + if( s_hasGUI ) + { + s_mainWindow->finalize(); + } presetPreviewPlayHandle::init(); diff --git a/src/core/export_project_dialog.cpp b/src/core/export_project_dialog.cpp index ffe518cae..0946b24d8 100644 --- a/src/core/export_project_dialog.cpp +++ b/src/core/export_project_dialog.cpp @@ -117,10 +117,10 @@ Sint16 exportProjectDialog::s_availableBitrates[] = exportProjectDialog::exportProjectDialog( const QString & _file_name, QWidget * _parent ) : QDialog( _parent ), - m_typeModel( new comboBoxModel( /* this */ ) ), - m_kbpsModel( new comboBoxModel( /* this */ ) ), - m_vbrEnabledModel( new boolModel( /* this */ ) ), - m_hqmEnabledModel( new boolModel( /* this */ ) ), + m_typeModel( NULL /* this */ ), + m_kbpsModel( NULL /* this */ ), + m_vbrEnabledModel( TRUE, NULL /* this */ ), + m_hqmEnabledModel( FALSE, NULL/* this */ ), m_fileName( _file_name ), m_deleteFile( FALSE ) { @@ -138,18 +138,18 @@ exportProjectDialog::exportProjectDialog( const QString & _file_name, Uint8 idx = 0; while( fileEncodeDevices[idx].m_fileType != NullFile ) { - m_typeModel->addItem( + m_typeModel.addItem( tr( fileEncodeDevices[idx].m_description ) ); ++idx; } - m_typeModel->setValue( m_typeModel->findText( tr( + m_typeModel.setValue( m_typeModel.findText( tr( fileEncodeDevices[m_fileType].m_description ) ) ); m_typeCombo = new comboBox( this ); m_typeCombo->setGeometry( LABEL_X + LABEL_WIDTH+LABEL_MARGIN, TYPE_STUFF_Y, TYPE_COMBO_WIDTH, TYPE_HEIGHT ); - m_typeCombo->setModel( m_typeModel ); + m_typeCombo->setModel( &m_typeModel ); /* connect( m_typeCombo, SIGNAL( activated( const QString & ) ), this, SLOT( changedType( const QString & ) ) );*/ @@ -162,33 +162,31 @@ exportProjectDialog::exportProjectDialog( const QString & _file_name, idx = 0; while( s_availableBitrates[idx] != -1 ) { - m_kbpsModel->addItem( QString::number( + m_kbpsModel.addItem( QString::number( s_availableBitrates[idx] ) ); ++idx; } - m_kbpsModel->setValue( m_kbpsModel->findText( + m_kbpsModel.setValue( m_kbpsModel.findText( QString::number( 128 ) ) ); m_kbpsCombo = new comboBox( this ); - m_kbpsCombo->setModel( m_kbpsModel ); + m_kbpsCombo->setModel( &m_kbpsModel ); m_kbpsCombo->setGeometry( LABEL_X + LABEL_WIDTH + LABEL_MARGIN, KBPS_STUFF_Y, KBPS_COMBO_WIDTH, KBPS_HEIGHT ); m_vbrCb = new ledCheckBox( tr( "variable bitrate" ), this ); - m_vbrCb->setModel( m_vbrEnabledModel ); + m_vbrCb->setModel( &m_vbrEnabledModel ); m_vbrCb->setGeometry( LABEL_X + LABEL_WIDTH + 3 * LABEL_MARGIN + KBPS_COMBO_WIDTH, KBPS_STUFF_Y + 3, 190, 20 ); - m_vbrCb->setChecked( TRUE ); m_hqmCb = new ledCheckBox( tr( "use high-quality-mode (recommened)" ), this ); - m_hqmCb->setModel( m_hqmEnabledModel ); + m_hqmCb->setModel( &m_hqmEnabledModel ); m_hqmCb->setGeometry( LABEL_X, HQ_MODE_CB_Y + 3, HQ_MODE_CB_WIDTH, HQ_MODE_CB_HEIGHT ); - m_hqmCb->setChecked( TRUE ); m_exportBtn = new QPushButton( embed::getIconPixmap( "apply" ), @@ -315,9 +313,9 @@ void exportProjectDialog::exportBtnClicked( void ) success_ful, m_fileName, m_vbrCb->model()->value(), - m_kbpsModel->currentText().toInt(), - m_kbpsModel->currentText().toInt() - 64, - m_kbpsModel->currentText().toInt() + 64, + m_kbpsModel.currentText().toInt(), + m_kbpsModel.currentText().toInt() - 64, + m_kbpsModel.currentText().toInt() + 64, engine::getMixer() ); if( success_ful == FALSE ) { @@ -375,11 +373,14 @@ void exportProjectDialog::exportBtnClicked( void ) int pval = pp * 100 / ( ( engine::getSong()->lengthInTacts() + 1 ) * 64 ); m_exportProgressBar->setValue( pval ); - // update lmms-main-win-caption - engine::getMainWindow()->setWindowTitle( tr( "Rendering:" ) + if( engine::getMainWindow() ) + { + // update lmms-main-win-caption + engine::getMainWindow()->setWindowTitle( tr( "Rendering:" ) + " " + QString::number( pval ) + "%" ); + } // process paint-events etc. - qApp->processEvents(); + QCoreApplication::processEvents(); } finishProjectExport(); @@ -422,8 +423,11 @@ void exportProjectDialog::finishProjectExport( void ) QFile( m_fileName ).remove(); } - // restore window-title - engine::getMainWindow()->resetWindowTitle(); + if( engine::getMainWindow() ) + { + // restore window-title + engine::getMainWindow()->resetWindowTitle(); + } engine::getSong()->stopExport(); diff --git a/src/core/main.cpp b/src/core/main.cpp index 449b8c665..bf5fadc2c 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -93,7 +94,7 @@ int main( int argc, char * * argv ) QString( argv[i] ) == "-v" ) { printf( "\nLinux MultiMedia Studio %s\n\n" - "Copyright (c) 2004-2007 Tobias Doerffel and others.\n\n" + "Copyright (c) 2004-2008 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" @@ -106,7 +107,7 @@ int main( int argc, char * * argv ) QString( argv[i] ) == "-h" ) ) { printf( "\nLinux MultiMedia Studio %s\n" - "Copyright (c) 2004-2007 Tobias Doerffel and others.\n\n" + "Copyright (c) 2004-2008 LMMS developers.\n\n" "usage: lmms [ -r [ -o ] [ -h ] " "[ ]\n" "-r, --render render given file.\n" @@ -149,9 +150,11 @@ int main( int argc, char * * argv ) } } + bool gui_startup = TRUE; if( file_to_render != "" ) { file_to_render += extension; + gui_startup = FALSE; } @@ -170,68 +173,75 @@ int main( int argc, char * * argv ) return( EXIT_FAILURE ); } - // set palette - QPalette pal = app.palette(); - pal.setColor( QPalette::Background, QColor( 128, 128, 128 ) ); - pal.setColor( QPalette::Foreground, QColor( 240, 240, 240 ) ); - pal.setColor( QPalette::Base, QColor( 128, 128, 128 ) ); - pal.setColor( QPalette::Text, QColor( 224, 224, 224 ) ); - pal.setColor( QPalette::Button, QColor( 160, 160, 160 ) ); - pal.setColor( QPalette::ButtonText, QColor( 255, 255, 255 ) ); - pal.setColor( QPalette::Highlight, QColor( 224, 224, 224 ) ); - pal.setColor( QPalette::HighlightedText, QColor( 0, 0, 0 ) ); - app.setPalette( pal ); - - - // init splash screen - QPixmap splash = embed::getIconPixmap( "splash" ); - mainWindow::s_splashScreen = new QSplashScreen( splash ); - mainWindow::s_splashScreen->show(); - - mainWindow::s_splashScreen->showMessage( mainWindow::tr( - "Setting up main-" - "window and " - "workspace..." ), - splash_alignment_flags, - Qt::white ); - - engine::init(); - - // we try to load given file - if( file_to_load != "" ) + if( gui_startup ) { + // set palette + QPalette pal = app.palette(); + pal.setColor( QPalette::Background, QColor( 128, 128, 128 ) ); + pal.setColor( QPalette::Foreground, QColor( 240, 240, 240 ) ); + pal.setColor( QPalette::Base, QColor( 128, 128, 128 ) ); + pal.setColor( QPalette::Text, QColor( 224, 224, 224 ) ); + pal.setColor( QPalette::Button, QColor( 160, 160, 160 ) ); + pal.setColor( QPalette::ButtonText, QColor( 255, 255, 255 ) ); + pal.setColor( QPalette::Highlight, QColor( 224, 224, 224 ) ); + pal.setColor( QPalette::HighlightedText, QColor( 0, 0, 0 ) ); + app.setPalette( pal ); + + + // init splash screen + QPixmap splash = embed::getIconPixmap( "splash" ); + mainWindow::s_splashScreen = new QSplashScreen( splash ); + mainWindow::s_splashScreen->show(); + + mainWindow::s_splashScreen->showMessage( mainWindow::tr( + "Setting up main-" + "window and " + "workspace..." ), + splash_alignment_flags, + Qt::white ); + + engine::init(); + + // we try to load given file + if( file_to_load != "" ) + { + engine::getSong()->loadProject( file_to_load ); + } + else + { + engine::getSong()->createNewProject(); + } + + // MDI-mode? + if( engine::getMainWindow()->workspace() != NULL ) + { + // then maximize + engine::getMainWindow()->showMaximized(); + } + else + { + // otherwise arrange at top-left edge of screen + engine::getMainWindow()->show(); + engine::getMainWindow()->move( 0, 0 ); + engine::getMainWindow()->resize( 200, 500 ); + } + + + delete mainWindow::s_splashScreen; + mainWindow::s_splashScreen = NULL; + } + else + { + engine::init( FALSE ); engine::getSong()->loadProject( file_to_load ); - } - else - { - engine::getSong()->createNewProject(); - } - - // MDI-mode? - if( engine::getMainWindow()->workspace() != NULL ) - { - // then maximize - engine::getMainWindow()->showMaximized(); - } - else - { - // otherwise arrange at top-left edge of screen - engine::getMainWindow()->show(); - engine::getMainWindow()->move( 0, 0 ); - engine::getMainWindow()->resize( 200, 500 ); - } - - - delete mainWindow::s_splashScreen; - mainWindow::s_splashScreen = NULL; - - if( file_to_render != "" ) - { exportProjectDialog * e = new exportProjectDialog( file_to_render, engine::getMainWindow() ); e->show(); + QTime t; + t.start(); e->exportBtnClicked(); + printf("export took %d ms\n",t.elapsed()); } return( app.exec() ); diff --git a/src/core/song.cpp b/src/core/song.cpp index 50ee94962..508d47de6 100644 --- a/src/core/song.cpp +++ b/src/core/song.cpp @@ -691,14 +691,20 @@ void song::clearProject( void ) engine::getBBTrackContainer()->clearAllTracks(); clearAllTracks(); - engine::getAutomationEditor()->setCurrentPattern( NULL ); + if( engine::getAutomationEditor() ) + { + engine::getAutomationEditor()->setCurrentPattern( NULL ); + } m_tempoModel.getAutomationPattern()->clear(); m_masterVolumeModel.getAutomationPattern()->clear(); m_masterPitchModel.getAutomationPattern()->clear(); engine::getMixer()->unlock(); - engine::getProjectNotes()->clear(); + if( engine::getProjectNotes() ) + { + engine::getProjectNotes()->clear(); + } engine::getProjectJournal()->clearInvalidJournallingObjects(); engine::getProjectJournal()->clearJournal(); @@ -737,7 +743,10 @@ void song::createNewProject( void ) m_fileName = m_oldFileName = ""; - engine::getMainWindow()->resetWindowTitle(); + if( engine::getMainWindow() ) + { + engine::getMainWindow()->resetWindowTitle(); + } track * t; t = track::create( track::InstrumentTrack, this ); @@ -795,15 +804,21 @@ void FASTCALL song::loadProject( const QString & _file_name ) return; } - engine::getMainWindow()->resetWindowTitle(); + if( engine::getMainWindow() ) + { + engine::getMainWindow()->resetWindowTitle(); + } // get the header information from the DOM m_tempoModel.loadSettings( mmp.head(), "bpm" ); m_masterVolumeModel.loadSettings( mmp.head(), "mastervol" ); m_masterPitchModel.loadSettings( mmp.head(), "masterpitch" ); - // reset loop-point-state - m_playPos[Mode_PlaySong].m_timeLine->toggleLoopPoints( 0 ); + if( m_playPos[Mode_PlaySong].m_timeLine ) + { + // reset loop-point-state + m_playPos[Mode_PlaySong].m_timeLine->toggleLoopPoints( 0 ); + } QDomNode node = mmp.content().firstChild(); while( !node.isNull() ) @@ -815,30 +830,33 @@ void FASTCALL song::loadProject( const QString & _file_name ) ( (journallingObject *)( this ) )-> restoreState( node.toElement() ); } - else if( node.nodeName() == - engine::getPianoRoll()->nodeName() ) + else if( engine::hasGUI() ) { - engine::getPianoRoll()->restoreState( - node.toElement() ); - } - else if( node.nodeName() == - engine::getAutomationEditor()->nodeName() ) - { - engine::getAutomationEditor()->restoreState( - node.toElement() ); - } - else if( node.nodeName() == - engine::getProjectNotes()->nodeName() ) - { - ( (journallingObject *)( engine:: - getProjectNotes() ) )-> - restoreState( node.toElement() ); - } - else if( node.nodeName() == - m_playPos[Mode_PlaySong].m_timeLine->nodeName() ) - { - m_playPos[Mode_PlaySong].m_timeLine->restoreState( - node.toElement() ); + if( node.nodeName() == + engine::getPianoRoll()->nodeName() ) + { + engine::getPianoRoll()->restoreState( + node.toElement() ); + } + else if( node.nodeName() == + engine::getAutomationEditor()->nodeName() ) + { + engine::getAutomationEditor()->restoreState( + node.toElement() ); + } + else if( node.nodeName() == + engine::getProjectNotes()->nodeName() ) + { + ( (journallingObject *)( engine:: + getProjectNotes() ) )-> + restoreState( node.toElement() ); + } + else if( node.nodeName() == + m_playPos[Mode_PlaySong].m_timeLine->nodeName() ) + { + m_playPos[Mode_PlaySong].m_timeLine->restoreState( + node.toElement() ); + } } } node = node.nextSibling(); @@ -1008,7 +1026,10 @@ void song::setModified( void ) if( !m_loadingProject ) { m_modified = TRUE; - engine::getMainWindow()->resetWindowTitle(); + if( engine::getMainWindow() ) + { + engine::getMainWindow()->resetWindowTitle(); + } } }