From bac2b28ad723abfc5980c7b38045481ca69b16d4 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Thu, 2 Sep 2010 17:12:50 +0200 Subject: [PATCH] ZynAddSubFX: save which controllers were modified and restore them We must not only restore the controller knobs but also send updates to ZynAddSubFX. However this only applies to knobs that were modified. Therefore save and remember which knobs this applies for. (cherry picked from commit b2cc802528f61530707d8fcb888f8f75ea14256d) --- plugins/zynaddsubfx/ZynAddSubFx.cpp | 36 +++++++++++++++++++++++++++++ plugins/zynaddsubfx/ZynAddSubFx.h | 4 +++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/plugins/zynaddsubfx/ZynAddSubFx.cpp b/plugins/zynaddsubfx/ZynAddSubFx.cpp index 743c9edb3..200a202ff 100644 --- a/plugins/zynaddsubfx/ZynAddSubFx.cpp +++ b/plugins/zynaddsubfx/ZynAddSubFx.cpp @@ -158,6 +158,18 @@ void ZynAddSubFxInstrument::saveSettings( QDomDocument & _doc, m_fmGainModel.saveSettings( _doc, _this, "fmgain" ); m_resCenterFreqModel.saveSettings( _doc, _this, "rescenterfreq" ); m_resBandwidthModel.saveSettings( _doc, _this, "resbandwidth" ); + + QString modifiedControllers; + for( QMap::ConstIterator it = m_modifiedControllers.begin(); + it != m_modifiedControllers.end(); ++it ) + { + if( it.value() ) + { + modifiedControllers += QString( "%1," ).arg( it.key() ); + } + } + _this.setAttribute( "modifiedcontrollers", modifiedControllers ); + m_forwardMidiCcModel.saveSettings( _doc, _this, "forwardmidicc" ); QTemporaryFile tf; @@ -242,6 +254,27 @@ void ZynAddSubFxInstrument::loadSettings( const QDomElement & _this ) } m_pluginMutex.unlock(); + m_modifiedControllers.clear(); + foreach( const QString & c, + _this.attribute( "modifiedcontrollers" ).split( ',' ) ) + { + if( !c.isEmpty() ) + { + switch( c.toInt() ) + { + case C_portamento: updatePortamento(); break; + case C_filtercutoff: updateFilterFreq(); break; + case C_filterq: updateFilterQ(); break; + case C_bandwidth: updateBandwidth(); break; + case C_fmamp: updateFmGain(); break; + case C_resonance_center: updateResCenterFreq(); break; + case C_resonance_bandwidth: updateResBandwidth(); break; + default: + break; + } + } + } + emit settingsChanged(); } } @@ -267,6 +300,8 @@ void ZynAddSubFxInstrument::loadFile( const QString & _file ) m_pluginMutex.unlock(); } + m_modifiedControllers.clear(); + emit settingsChanged(); } @@ -354,6 +389,7 @@ void ZynAddSubFxInstrument::reloadPlugin() void ZynAddSubFxInstrument::slotname() \ { \ sendControlChange( midictl, modelname.value() ); \ + m_modifiedControllers[midictl] = true; \ } diff --git a/plugins/zynaddsubfx/ZynAddSubFx.h b/plugins/zynaddsubfx/ZynAddSubFx.h index 11110acc6..f37ba857b 100644 --- a/plugins/zynaddsubfx/ZynAddSubFx.h +++ b/plugins/zynaddsubfx/ZynAddSubFx.h @@ -25,6 +25,7 @@ #ifndef _ZYNADDSUBFX_H #define _ZYNADDSUBFX_H +#include #include #include "AutomatableModel.h" @@ -118,6 +119,8 @@ private: FloatModel m_resBandwidthModel; BoolModel m_forwardMidiCcModel; + QMap m_modifiedControllers; + friend class ZynAddSubFxView; @@ -161,5 +164,4 @@ private slots: } ; - #endif