diff --git a/ChangeLog b/ChangeLog index e12d0bfb8..0dfce93f5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,4 @@ -2008-06-28 Paul Giblock +2008-06-29 Paul Giblock * plugins/sf2_player/sf2_player.cpp: Initialize gain at 1.0 @@ -14,6 +14,16 @@ * src/gui/widgets/tempo_sync_knob.cpp: Make tempoSyncKnob really sync to tempo again + * plugins/peak_controller_effect/peak_controller_effect.cpp: + * plugins/peak_controller_effect/peak_controller_effect_controls.cpp: + * plugins/peak_controller_effect/peak_controller_effect.h: + * include/peak_controller.h: + * src/core/peak_controller.cpp: + Fix loading/saving for peak controller + + * src/core/effect.cpp: + Correct comments + 2008-06-28 Tobias Doerffel * plugins/Makefile.am: diff --git a/include/peak_controller.h b/include/peak_controller.h index 768c9ec0d..f2c13c28a 100644 --- a/include/peak_controller.h +++ b/include/peak_controller.h @@ -36,6 +36,7 @@ class automatableButtonGroup; class knob; class peakControllerEffect; +typedef QVector peakControllerEffectVector; class EXPORT peakController : public controller @@ -57,6 +58,9 @@ public: virtual void loadSettings( const QDomElement & _this ); virtual QString nodeName( void ) const; + static peakControllerEffectVector s_effects; + static int s_lastEffectId; + public slots: virtual controllerDialog * createDialog( QWidget * _parent ); diff --git a/plugins/peak_controller_effect/peak_controller_effect.cpp b/plugins/peak_controller_effect/peak_controller_effect.cpp index bbdf999de..36e6f4308 100644 --- a/plugins/peak_controller_effect/peak_controller_effect.cpp +++ b/plugins/peak_controller_effect/peak_controller_effect.cpp @@ -51,15 +51,23 @@ plugin::descriptor PLUGIN_EXPORT peakcontroller_effect_plugin_descriptor = } +// We have to keep a list of all the peakController effects so that we can save +// an peakEffect-ID to the project. This ID is referenced in the peakController +// settings and is used to set the peakControllerEffect pointer upon load +//QVector peakControllerEffect::s_effects; peakControllerEffect::peakControllerEffect( model * _parent, const descriptor::subPluginFeatures::key * _key ) : effect( &peakcontroller_effect_plugin_descriptor, _parent, _key ), - m_peakControls( this ) + m_effectId( ++peakController::s_lastEffectId ), + m_peakControls( this ), + m_autoController( NULL ) { - engine::getSong()->addController( new peakController( engine::getSong(), this ) ); + m_autoController = new peakController( engine::getSong(), this ); + engine::getSong()->addController( m_autoController ); + peakController::s_effects.append( this ); } @@ -67,6 +75,11 @@ peakControllerEffect::peakControllerEffect( peakControllerEffect::~peakControllerEffect() { + int idx = peakController::s_effects.indexOf( this ); + if( idx >= 0 ) + { + peakController::s_effects.remove( idx ); + } } diff --git a/plugins/peak_controller_effect/peak_controller_effect.h b/plugins/peak_controller_effect/peak_controller_effect.h index ebdc6feaf..626c0def6 100644 --- a/plugins/peak_controller_effect/peak_controller_effect.h +++ b/plugins/peak_controller_effect/peak_controller_effect.h @@ -53,6 +53,7 @@ public: return m_lastSample; } + int m_effectId; private: peakControllerEffectControls m_peakControls; @@ -60,6 +61,8 @@ private: friend class peakControllerEffectControls; float m_lastSample; + + controller * m_autoController; } ; diff --git a/plugins/peak_controller_effect/peak_controller_effect_controls.cpp b/plugins/peak_controller_effect/peak_controller_effect_controls.cpp index c71ad2e0a..06aa7d744 100644 --- a/plugins/peak_controller_effect/peak_controller_effect_controls.cpp +++ b/plugins/peak_controller_effect/peak_controller_effect_controls.cpp @@ -22,6 +22,7 @@ * */ +#include "peak_controller.h" #include "peak_controller_effect_controls.h" #include "peak_controller_effect.h" @@ -41,9 +42,23 @@ peakControllerEffectControls( peakControllerEffect * _eff ) : void peakControllerEffectControls::loadSettings( const QDomElement & _this ) { + printf("peakControllerEffect loadSettings\n"); m_baseModel.setValue( _this.attribute( "base" ).toFloat() ); m_amountModel.setValue( _this.attribute( "amount" ).toFloat() ); m_muteModel.setValue( _this.attribute( "mute" ).toFloat() ); + + int effectId = _this.attribute( "effectId" ).toInt(); + if( effectId > peakController::s_lastEffectId ) + { + peakController::s_lastEffectId = effectId; + } + m_effect->m_effectId = effectId; + + if( m_effect->m_autoController ) + { + delete m_effect->m_autoController; + m_effect->m_autoController = 0; + } } @@ -55,6 +70,7 @@ void peakControllerEffectControls::saveSettings( QDomDocument & _doc, _this.setAttribute( "base", m_baseModel.value() ); _this.setAttribute( "amount", m_amountModel.value() ); _this.setAttribute( "mute", m_muteModel.value() ); + _this.setAttribute( "effectId", m_effect->m_effectId ); } diff --git a/src/core/effect.cpp b/src/core/effect.cpp index a6b7eff09..97bce83e1 100644 --- a/src/core/effect.cpp +++ b/src/core/effect.cpp @@ -103,14 +103,14 @@ effect * effect::instantiate( const QString & _plugin_name, descriptor::subPluginFeatures::key * _key ) { plugin * p = plugin::instantiate( _plugin_name, _parent, _key ); - // check whether instantiated plugin is an instrument + // check whether instantiated plugin is an effect if( dynamic_cast( p ) != NULL ) { // everything ok, so return pointer return( dynamic_cast( p ) ); } - // not quite... so delete plugin and return dummy instrument + // not quite... so delete plugin and return dummy effect delete p; return( new dummyEffect( _parent ) ); } diff --git a/src/core/peak_controller.cpp b/src/core/peak_controller.cpp index 09441f15e..0959eed88 100644 --- a/src/core/peak_controller.cpp +++ b/src/core/peak_controller.cpp @@ -38,6 +38,9 @@ #include "controller_dialog.h" #include "plugins/peak_controller_effect/peak_controller_effect.h" +int peakController::s_lastEffectId = 0; +peakControllerEffectVector peakController::s_effects; + peakController::peakController( model * _parent, peakControllerEffect * _peak_effect ) : @@ -69,15 +72,29 @@ float peakController::value( int _offset ) void peakController::saveSettings( QDomDocument & _doc, QDomElement & _this ) { - // Probably not the best idea.. -// controller::saveSettings( _doc, _this ); + controller::saveSettings( _doc, _this ); + + _this.setAttribute( "effectId", m_peakEffect->m_effectId ); } void peakController::loadSettings( const QDomElement & _this ) { -// controller::loadSettings( _this ); + printf("peakController loadSettings\n"); + int effectId = _this.attribute( "effectId" ).toInt(); + + peakControllerEffectVector::iterator i; + for( i = s_effects.begin(); i != s_effects.end(); ++i ) + { + printf( "%d %d\n", (*i)->m_effectId , effectId ); + if( (*i)->m_effectId == effectId ) + { + if( (*i)->m_effectId == effectId ) + m_peakEffect = *i; + return; + } + } } diff --git a/src/core/song.cpp b/src/core/song.cpp index ed3ab26f6..42f36d4d4 100644 --- a/src/core/song.cpp +++ b/src/core/song.cpp @@ -1144,6 +1144,7 @@ void song::removeController( controller * _controller ) { engine::getSong()->setModified(); } + emit dataChanged(); } }