Fix loading/saving for peakController

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@1199 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Paul Giblock
2008-06-29 08:32:27 +00:00
parent 941c3cdc78
commit d83b15ae14
8 changed files with 72 additions and 8 deletions

View File

@@ -1,4 +1,4 @@
2008-06-28 Paul Giblock <drfaygo/at/gmail/dot/com>
2008-06-29 Paul Giblock <drfaygo/at/gmail/dot/com>
* 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 <tobydox/at/users/dot/sourceforge/dot/net>
* plugins/Makefile.am:

View File

@@ -36,6 +36,7 @@ class automatableButtonGroup;
class knob;
class peakControllerEffect;
typedef QVector<peakControllerEffect *> 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 );

View File

@@ -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 *> 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 );
}
}

View File

@@ -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;
} ;

View File

@@ -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 );
}

View File

@@ -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<effect *>( p ) != NULL )
{
// everything ok, so return pointer
return( dynamic_cast<effect *>( 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 ) );
}

View File

@@ -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;
}
}
}

View File

@@ -1144,6 +1144,7 @@ void song::removeController( controller * _controller )
{
engine::getSong()->setModified();
}
emit dataChanged();
}
}