From b2cc802528f61530707d8fcb888f8f75ea14256d 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. --- 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 ac69300f1..59a3dba96 100644 --- a/plugins/zynaddsubfx/ZynAddSubFx.cpp +++ b/plugins/zynaddsubfx/ZynAddSubFx.cpp @@ -163,6 +163,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; @@ -247,6 +259,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(); } } @@ -273,6 +306,8 @@ void ZynAddSubFxInstrument::loadResource( const ResourceItem * _item ) m_pluginMutex.unlock(); } + m_modifiedControllers.clear(); + emit settingsChanged(); } @@ -360,6 +395,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 583ca7acd..ad26ed9a6 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; @@ -156,5 +159,4 @@ private slots: } ; - #endif