diff --git a/include/Song.h b/include/Song.h index 08c99af4712..cc7431ee50d 100644 --- a/include/Song.h +++ b/include/Song.h @@ -265,6 +265,16 @@ class EXPORT Song : public TrackContainer return false; } + inline void setDisconnectMidiControllersOnLoad( bool val ) + { + m_disconnectMidiControllersOnLoad = val; + } + + inline bool getDisconnectMidiControllersOnLoad() + { + return m_disconnectMidiControllersOnLoad; + } + void addController( Controller * c ); void removeController( Controller * c ); @@ -378,6 +388,8 @@ private slots: volatile bool m_playing; volatile bool m_paused; + bool m_disconnectMidiControllersOnLoad; + bool m_loadingProject; bool m_isCancelled; diff --git a/src/core/ControllerConnection.cpp b/src/core/ControllerConnection.cpp index 45e36e12fc0..9cc74d993e2 100644 --- a/src/core/ControllerConnection.cpp +++ b/src/core/ControllerConnection.cpp @@ -198,9 +198,19 @@ void ControllerConnection::saveSettings( QDomDocument & _doc, QDomElement & _thi void ControllerConnection::loadSettings( const QDomElement & _this ) { QDomNode node = _this.firstChild(); + + bool disconnectMidiControllers = Engine::getSong()->getDisconnectMidiControllersOnLoad(); + if( !node.isNull() ) { - setController( Controller::create( node.toElement(), Engine::getSong() ) ); + if ( disconnectMidiControllers ) + { + deleteConnection(); + } + else + { + setController( Controller::create( node.toElement(), Engine::getSong() ) ); + } } else { diff --git a/src/core/main.cpp b/src/core/main.cpp index cc9cb4f2a73..b351946d254 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -127,6 +127,8 @@ void printHelp() " --allowroot Bypass root user startup check (use with\n" " caution).\n" " -c, --config Get the configuration from \n" + " --disconnect-midi-controllers\n" + " Disconnect all MIDI inputs and controllers.\n" " -h, --help Show this usage information and exit.\n" " -v, --version Show version information and exit.\n" "\nOptions if no action is given:\n" @@ -208,6 +210,7 @@ int main( int argc, char * * argv ) bool allowRoot = false; bool renderLoop = false; bool renderTracks = false; + bool disconnectMidiControllers = false; QString fileToLoad, fileToImport, renderOut, profilerOutputFile, configFile; // first of two command-line parsing stages @@ -616,6 +619,10 @@ int main( int argc, char * * argv ) configFile = QString::fromLocal8Bit( argv[i] ); } + else if( arg == "--disconnect-midi-controllers" ) + { + disconnectMidiControllers = true; + } else { if( argv[i][0] == '-' ) @@ -877,6 +884,7 @@ int main( int argc, char * * argv ) } else { + Engine::getSong()->setDisconnectMidiControllersOnLoad( disconnectMidiControllers ); Engine::getSong()->loadProject( fileToLoad ); } } diff --git a/src/core/midi/MidiPort.cpp b/src/core/midi/MidiPort.cpp index 9e3cdb13d83..37572a59592 100644 --- a/src/core/midi/MidiPort.cpp +++ b/src/core/midi/MidiPort.cpp @@ -235,7 +235,9 @@ void MidiPort::loadSettings( const QDomElement& thisElement ) // restore connections - if( isInputEnabled() ) + bool disconnectMidiControllers = Engine::getSong()->getDisconnectMidiControllersOnLoad(); + + if( isInputEnabled() && !disconnectMidiControllers ) { QStringList rp = thisElement.attribute( "inports" ).split( ',' ); for( Map::ConstIterator it = m_readablePorts.begin(); it != m_readablePorts.end(); ++it )