split off effectControlDialog into effectControlDialog and effectControls, made work with M/V as well as rewritten effect-framework, fixed bug in songEditor-engine

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/branches/lmms-mv@664 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Tobias Doerffel
2008-01-14 23:10:53 +00:00
parent add39dffbd
commit 382d7d44b0
17 changed files with 381 additions and 207 deletions

View File

@@ -1,5 +1,29 @@
2008-01-14 Tobias Doerffel <tobydox/at/users/dot/sourceforge/dot/net>
* plugins/bass_booster/bassbooster_controls.h:
* plugins/bass_booster/bass_booster.cpp:
* plugins/bass_booster/bassbooster_control_dialog.cpp:
* plugins/bass_booster/Makefile.am:
* plugins/bass_booster/bassbooster_controls.cpp:
* plugins/bass_booster/bass_booster.h:
* plugins/bass_booster/bassbooster_control_dialog.h:
made work with M/V as well as rewritten effect-framework
* include/effect.h:
* include/effect_control_dialog.h:
* include/dummy_effect.h:
* include/effect_controls.h:
* src/widgets/effect_view.cpp:
* src/core/effect_control_dialog.cpp:
* src/core/effect.cpp:
* Makefile.am:
split off effectControlDialog into effectControlDialog and
effectControls
* src/core/song_editor.cpp:
also connect to dataUnchanged()-signal of tempo-model in order to
setup everything correct by connected slot
* configure.in:
- removed single-source-compile-feature
- made FASTCALL-usage optional for the time being

View File

@@ -370,6 +370,7 @@ lmms_SOURCES = \
$(srcdir)/include/engine.h \
$(srcdir)/include/effect.h \
$(srcdir)/include/effect_chain.h \
$(srcdir)/include/effect_controls.h \
$(srcdir)/include/effect_control_dialog.h \
$(srcdir)/include/effect_label.h \
$(srcdir)/include/effect_rack_view.h \

View File

@@ -27,14 +27,30 @@
#define _DUMMY_EFFECT_H
#include "effect.h"
#include "effect_controls.h"
#include "effect_control_dialog.h"
class dummyEffectControlDialog : public effectControlDialog
{
public:
dummyEffectControlDialog( effect * _eff ) :
effectControlDialog( NULL, _eff )
dummyEffectControlDialog( effectControls * _controls ) :
effectControlDialog( _controls )
{
}
} ;
class dummyEffectControls : public effectControls
{
public:
dummyEffectControls( effect * _eff ) :
effectControls( _eff )
{
}
virtual ~dummyEffectControls()
{
}
@@ -43,28 +59,6 @@ public:
return( 0 );
}
inline virtual QString nodeName( void ) const
{
return( "dummycontrols" );
}
} ;
class dummyEffect : public effect
{
public:
inline dummyEffect( model * _parent ) :
effect( NULL, _parent, NULL )
{
}
inline virtual ~dummyEffect()
{
}
inline virtual void saveSettings( QDomDocument &, QDomElement & )
{
}
@@ -75,13 +69,37 @@ public:
inline virtual QString nodeName( void ) const
{
return( "dummyeffect" );
return( "dummycontrols" );
}
inline virtual effectControlDialog * createControlDialog( track * )
virtual effectControlDialog * createView( void )
{
return( new dummyEffectControlDialog( this ) );
}
} ;
class dummyEffect : public effect
{
public:
inline dummyEffect( model * _parent ) :
effect( NULL, _parent, NULL ),
m_controls( this )
{
}
inline virtual ~dummyEffect()
{
}
inline virtual effectControls * getControls( void )
{
return( &m_controls );
}
private:
dummyEffectControls m_controls;
} ;

View File

@@ -40,7 +40,7 @@
class effectChain;
class effectControlDialog;
class effectControls;
class track;
@@ -161,7 +161,7 @@ public:
return( m_key );
}
virtual effectControlDialog * createControlDialog( track * _track ) = 0;
virtual effectControls * getControls( void ) = 0;
static effect * instantiate( const QString & _plugin_name,
model * _parent,

View File

@@ -29,22 +29,18 @@
#include <QtGui/QWidget>
#include "mv_base.h"
#include "types.h"
class effect;
class track;
class effectControls;
class effectControlDialog : public QWidget, public modelView
{
Q_OBJECT
public:
effectControlDialog( QWidget * _parent, effect * _eff );
effectControlDialog( effectControls * _controls );
virtual ~effectControlDialog();
virtual ch_cnt_t getControlCount( void ) = 0;
signals:
void closed();
@@ -52,15 +48,10 @@ signals:
protected:
virtual void closeEvent( QCloseEvent * _ce );
template<class T>
T * getEffect( void )
{
return( dynamic_cast<T *>( m_effect ) );
}
private:
effect * m_effect;
effectControls * m_effectControls;
} ;

68
include/effect_controls.h Normal file
View File

@@ -0,0 +1,68 @@
/*
* effect_controls.h - model for effect-controls
*
* Copyright (c) 2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program (see COPYING); if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
*/
#ifndef _EFFECT_CONTROLS_H
#define _EFFECT_CONTROLS_H
#include "mv_base.h"
#include "journalling_object.h"
#include "effect.h"
class track;
class effectControlDialog;
class effectControls : public journallingObject, public model
{
public:
effectControls( effect * _eff ) :
journallingObject(),
model( _eff ),
m_effect( _eff )
{
}
virtual ~effectControls()
{
}
virtual ch_cnt_t getControlCount( void ) = 0;
virtual effectControlDialog * createView( void ) = 0;
// template<class T>
effect * getEffect( void )
{
return( m_effect );
//return( dynamic_cast<T *>( m_effect ) );
}
private:
effect * m_effect;
} ;
#endif

View File

@@ -11,7 +11,7 @@ AM_CXXFLAGS := $(AM_CXXFLAGS) $(QT_CXXFLAGS) -DPLUGIN_NAME="bassbooster"
$(MOC) -o $@ $<
MOC_FILES = ./bassbooster_control_dialog.moc
MOC_FILES = ./bassbooster_controls.moc
BUILT_SOURCES = $(MOC_FILES) ./embedded_resources.h
EMBEDDED_RESOURCES = $(wildcard *png)
@@ -30,6 +30,8 @@ pkglib_LTLIBRARIES= libbassbooster.la
libbassbooster_la_SOURCES = bass_booster.cpp \
bass_booster.h \
bassbooster_controls.cpp \
bassbooster_controls.h \
bassbooster_control_dialog.cpp \
bassbooster_control_dialog.h

View File

@@ -54,7 +54,8 @@ plugin::descriptor bassbooster_plugin_descriptor =
bassBoosterEffect::bassBoosterEffect( model * _parent,
const descriptor::subPluginFeatures::key * _key ) :
effect( &bassbooster_plugin_descriptor, _parent, _key ),
m_bbFX( effectLib::fastBassBoost<>( 70.0f, 1.0f, 2.8f ) )
m_bbFX( effectLib::fastBassBoost<>( 70.0f, 1.0f, 2.8f ) ),
m_bbControls( this )
{
}

View File

@@ -33,7 +33,7 @@
#include "effect_lib.h"
#include "engine.h"
#include "main_window.h"
#include "bassbooster_control_dialog.h"
#include "bassbooster_controls.h"
@@ -45,23 +45,25 @@ public:
virtual ~bassBoosterEffect();
virtual bool FASTCALL processAudioBuffer( surroundSampleFrame * _buf,
const fpp_t _frames );
inline virtual QString nodeName( void ) const
virtual effectControls * getControls( void )
{
return( "bassboostereffect" );
return( &m_bbControls );
}
virtual inline effectControlDialog * createControlDialog( track * )
/* inline virtual QString nodeName( void ) const
{
return( new bassBoosterControlDialog(
NULL /*engine::getMainWindow()->workspace()*/,
this ) );
}
return( "bassboostereffect" );
}*/
private:
effectLib::monoToStereoAdaptor<effectLib::fastBassBoost<> > m_bbFX;
friend class bassBoosterControlDialog;
bassBoosterControls m_bbControls;
friend class bassBoosterControls;
} ;

View File

@@ -1,7 +1,7 @@
/*
* bassbooster_control_dialog.cpp - control-dialog for bassbooster-effect
*
* Copyright (c) 2006-2007 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2006-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -25,126 +25,35 @@
#include <QtGui/QLayout>
#include "bass_booster.h"
#include "knob.h"
#include "bassbooster_control_dialog.h"
#include "bassbooster_controls.h"
bassBoosterControlDialog::bassBoosterControlDialog( QWidget * _parent,
bassBoosterEffect * _eff ) :
effectControlDialog( _parent, _eff ),
m_effect( _eff )
bassBoosterControlDialog::bassBoosterControlDialog(
bassBoosterControls * _controls ) :
effectControlDialog( _controls )
{
QHBoxLayout * l = new QHBoxLayout( this );
m_freqKnob = new knob( knobBright_26, this, tr( "Frequency" ), NULL );
m_freqKnob->setRange( 50.0f, 200.0f, 1.0f );
m_freqKnob->setInitValue( 100.0f );
m_freqKnob->setLabel( tr( "FREQ" ) );
m_freqKnob->setHintText( tr( "Frequency:" ) + " ", "Hz" );
connect( m_freqKnob, SIGNAL( valueChanged( float ) ),
this, SLOT( changeFrequency( void ) ) );
knob * freqKnob = new knob( knobBright_26, this, tr( "Frequency" ) );
freqKnob->setModel( &_controls->m_freqModel );
freqKnob->setLabel( tr( "FREQ" ) );
freqKnob->setHintText( tr( "Frequency:" ) + " ", "Hz" );
m_gainKnob = new knob( knobBright_26, this, tr( "Gain" ), NULL );
m_gainKnob->setRange( 0.1f, 5.0f, 0.1f );
m_gainKnob->setInitValue( 1.0f );
m_gainKnob->setLabel( tr( "GAIN" ) );
m_gainKnob->setHintText( tr( "Gain:" ) + " ", "" );
connect( m_gainKnob, SIGNAL( valueChanged( float ) ),
this, SLOT( changeGain( void ) ) );
knob * gainKnob = new knob( knobBright_26, this, tr( "Gain" ) );
gainKnob->setModel( &_controls->m_gainModel );
gainKnob->setLabel( tr( "GAIN" ) );
gainKnob->setHintText( tr( "Gain:" ) + " ", "" );
m_ratioKnob = new knob( knobBright_26, this, tr( "Ratio" ), NULL );
m_ratioKnob->setRange( 0.1f, 10.0f, 0.1f );
m_ratioKnob->setInitValue( 2.0f );
m_ratioKnob->setLabel( tr( "RATIO" ) );
m_ratioKnob->setHintText( tr( "Ratio:" ) + " ", "" );
connect( m_ratioKnob, SIGNAL( valueChanged( float ) ),
this, SLOT( changeRatio( void ) ) );
knob * ratioKnob = new knob( knobBright_26, this, tr( "Ratio" ) );
ratioKnob->setModel( &_controls->m_ratioModel );
ratioKnob->setLabel( tr( "RATIO" ) );
ratioKnob->setHintText( tr( "Ratio:" ) + " ", "" );
l->addWidget( m_freqKnob );
l->addWidget( m_gainKnob );
l->addWidget( m_ratioKnob );
changeFrequency();
changeGain();
changeRatio();
l->addWidget( freqKnob );
l->addWidget( gainKnob );
l->addWidget( ratioKnob );
}
void bassBoosterControlDialog::changeFrequency( void )
{
m_effect->m_bbFX.leftFX().setFrequency( m_freqKnob->value() );
m_effect->m_bbFX.rightFX().setFrequency( m_freqKnob->value() );
}
void bassBoosterControlDialog::changeGain( void )
{
m_effect->m_bbFX.leftFX().setGain( m_gainKnob->value() );
m_effect->m_bbFX.rightFX().setGain( m_gainKnob->value() );
}
void bassBoosterControlDialog::changeRatio( void )
{
m_effect->m_bbFX.leftFX().setRatio( m_ratioKnob->value() );
m_effect->m_bbFX.rightFX().setRatio( m_ratioKnob->value() );
}
/*
void bassBoosterControlDialog::updateEffect( void )
{
//m_effect->m_bbFX = effectLib::bassBoost<>( m_freqKnob->value(),
// m_gainKnob->value(), m_ratioKnob->value() );
m_effect->m_bbFX = effectLib::monoToStereoAdaptor<
effectLib::bassBoost<> >(
effectLib::bassBoost<>( m_freqKnob->value(),
m_gainKnob->value(), m_ratioKnob->value(),
m_effect->m_bbFX.leftFX() ),
effectLib::bassBoost<>( m_freqKnob->value(),
m_gainKnob->value(), m_ratioKnob->value(),
m_effect->m_bbFX.rightFX() )
);
m_effect->m_bbFX.leftFX().setSelectivity( m_freqKnob->value() );
m_effect->m_bbFX.rightFX().setSelectivity( m_freqKnob->value() );
m_effect->m_bbFX.leftFX().setGain( m_gainKnob->value() );
m_effect->m_bbFX.rightFX().setGain( m_gainKnob->value() );
m_effect->m_bbFX.leftFX().setRatio( m_ratioKnob->value() );
m_effect->m_bbFX.rightFX().setRatio( m_ratioKnob->value() );
}
*/
void FASTCALL bassBoosterControlDialog::loadSettings(
const QDomElement & _this )
{
m_freqKnob->setValue( _this.attribute( "freq" ).toFloat() );
m_gainKnob->setValue( _this.attribute( "gain" ).toFloat() );
m_ratioKnob->setValue( _this.attribute( "ratio" ).toFloat() );
}
void FASTCALL bassBoosterControlDialog::saveSettings( QDomDocument & _doc,
QDomElement & _this )
{
_this.setAttribute( "freq", m_freqKnob->value() );
_this.setAttribute( "gain", m_gainKnob->value() );
_this.setAttribute( "ratio", m_ratioKnob->value() );
}
#include "bassbooster_control_dialog.moc"

View File

@@ -1,7 +1,7 @@
/*
* bassbooster_control_dialog.h - control-dialog for bassbooster-effect
*
* Copyright (c) 2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2006-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -27,45 +27,18 @@
#include "effect_control_dialog.h"
class knob;
class bassBoosterEffect;
class bassBoosterControls;
class bassBoosterControlDialog : public effectControlDialog
{
Q_OBJECT
public:
bassBoosterControlDialog( QWidget * _parent, bassBoosterEffect * _eff );
bassBoosterControlDialog( bassBoosterControls * _controls );
virtual ~bassBoosterControlDialog()
{
}
virtual void FASTCALL saveSettings( QDomDocument & _doc,
QDomElement & _parent );
virtual void FASTCALL loadSettings( const QDomElement & _this );
inline virtual QString nodeName( void ) const
{
return( "bassboostercontrols" );
}
virtual ch_cnt_t getControlCount( void )
{
return( 3 );
}
private slots:
void changeFrequency( void );
void changeGain( void );
void changeRatio( void );
private:
bassBoosterEffect * m_effect;
knob * m_freqKnob;
knob * m_gainKnob;
knob * m_ratioKnob;
} ;
#endif

View File

@@ -0,0 +1,103 @@
/*
* bassbooster_controls.cpp - controls for bassbooster-effect
*
* Copyright (c) 2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program (see COPYING); if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
*/
#include "bassbooster_controls.h"
#include "bass_booster.h"
bassBoosterControls::bassBoosterControls( bassBoosterEffect * _eff ) :
effectControls( _eff ),
m_effect( _eff ),
m_freqModel( 100.0f, 50.0f, 200.0f, 1.0f, this ),
m_gainModel( 1.0f, 0.1f, 5.0f, 0.05f, this ),
m_ratioModel( 2.0f, 0.1f, 10.0f, 0.1f, this )
{
connect( &m_freqModel, SIGNAL( dataChanged( void ) ),
this, SLOT( changeFrequency( void ) ) );
connect( &m_gainModel, SIGNAL( dataChanged( void ) ),
this, SLOT( changeGain( void ) ) );
connect( &m_ratioModel, SIGNAL( dataChanged( void ) ),
this, SLOT( changeRatio( void ) ) );
changeFrequency();
changeGain();
changeRatio();
}
void bassBoosterControls::changeFrequency( void )
{
m_effect->m_bbFX.leftFX().setFrequency( m_freqModel.value() );
m_effect->m_bbFX.rightFX().setFrequency( m_freqModel.value() );
}
void bassBoosterControls::changeGain( void )
{
m_effect->m_bbFX.leftFX().setGain( m_gainModel.value() );
m_effect->m_bbFX.rightFX().setGain( m_gainModel.value() );
}
void bassBoosterControls::changeRatio( void )
{
m_effect->m_bbFX.leftFX().setRatio( m_ratioModel.value() );
m_effect->m_bbFX.rightFX().setRatio( m_ratioModel.value() );
}
void bassBoosterControls::loadSettings( const QDomElement & _this )
{
m_freqModel.setValue( _this.attribute( "freq" ).toFloat() );
m_gainModel.setValue( _this.attribute( "gain" ).toFloat() );
m_ratioModel.setValue( _this.attribute( "ratio" ).toFloat() );
}
void bassBoosterControls::saveSettings( QDomDocument & _doc,
QDomElement & _this )
{
_this.setAttribute( "freq", m_freqModel.value() );
_this.setAttribute( "gain", m_gainModel.value() );
_this.setAttribute( "ratio", m_ratioModel.value() );
}
#include "bassbooster_controls.moc"

View File

@@ -0,0 +1,79 @@
/*
* bassbooster_controls.h - controls for bassbooster-effect
*
* Copyright (c) 2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program (see COPYING); if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
*/
#ifndef _BASSBOOSTER_CONTROLS_H
#define _BASSBOOSTER_CONTROLS_H
#include "effect_controls.h"
#include "bassbooster_control_dialog.h"
#include "knob.h"
class bassBoosterEffect;
class bassBoosterControls : public effectControls
{
Q_OBJECT
public:
bassBoosterControls( bassBoosterEffect * _eff );
virtual ~bassBoosterControls()
{
}
virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent );
virtual void loadSettings( const QDomElement & _this );
inline virtual QString nodeName( void ) const
{
return( "bassboostercontrols" );
}
virtual ch_cnt_t getControlCount( void )
{
return( 3 );
}
virtual effectControlDialog * createView( void )
{
return( new bassBoosterControlDialog( this ) );
}
private slots:
void changeFrequency( void );
void changeGain( void );
void changeRatio( void );
private:
bassBoosterEffect * m_effect;
knobModel m_freqModel;
knobModel m_gainModel;
knobModel m_ratioModel;
friend class bassBoosterControlDialog;
} ;
#endif

View File

@@ -65,7 +65,7 @@ void effect::saveSettings( QDomDocument & _doc, QDomElement & _this )
_this.setAttribute( "wet", m_wetDryModel.value() );
_this.setAttribute( "autoquit", m_autoQuitModel.value() );
_this.setAttribute( "gate", m_gateModel.value() );
// m_controlView->saveState( _doc, _this );
getControls()->saveState( _doc, _this );
}
@@ -77,20 +77,19 @@ void effect::loadSettings( const QDomElement & _this )
m_wetDryModel.setValue( _this.attribute( "wet" ).toFloat() );
m_autoQuitModel.setValue( _this.attribute( "autoquit" ).toFloat() );
m_gateModel.setValue( _this.attribute( "gate" ).toFloat() );
/*
QDomNode node = _this.firstChild();
while( !node.isNull() )
{
if( node.isElement() )
{
if( m_controlView->nodeName() == node.nodeName() )
if( getControls()->nodeName() == node.nodeName() )
{
m_controlView->restoreState(
node.toElement() );
getControls()->restoreState( node.toElement() );
}
}
node = node.nextSibling();
}*/
}
}

View File

@@ -30,15 +30,16 @@
#include <QtGui/QCloseEvent>
#include "effect_control_dialog.h"
#include "effect_controls.h"
#include "effect.h"
effectControlDialog::effectControlDialog( QWidget * _parent, effect * _eff ) :
QWidget( _parent ),
modelView( _eff ),
m_effect( _eff )
effectControlDialog::effectControlDialog( effectControls * _controls ) :
QWidget( NULL ),
modelView( _controls ),
m_effectControls( _controls )
{
setWindowTitle( m_effect->publicName() );
setWindowTitle( m_effectControls->getEffect()->publicName() );
}

View File

@@ -128,6 +128,8 @@ songEditor::songEditor( void ) :
connect( &m_tempoModel, SIGNAL( dataChanged() ),
this, SLOT( setTempo() ) );
connect( &m_tempoModel, SIGNAL( dataUnchanged() ),
this, SLOT( setTempo() ) );
connect( m_tempoSpinBox, SIGNAL( manualChange() ), this,
SLOT( setModified() ) );

View File

@@ -35,6 +35,7 @@
#include "audio_port.h"
#include "caption_menu.h"
#include "effect_controls.h"
#include "effect_control_dialog.h"
#include "embed.h"
#include "engine.h"
@@ -112,7 +113,7 @@ effectView::effectView( effect * _model, QWidget * _parent ) :
bg.toImage().copy( 5, 44, 195, 10 ) ) );
m_label->setPalette( pal );
m_controlView = getEffect()->createControlDialog( NULL );
m_controlView = getEffect()->getControls()->createView();
m_subWindow = engine::getMainWindow()->workspace()->addSubWindow(
m_controlView );
connect( m_controlView, SIGNAL( closed() ),
@@ -120,7 +121,7 @@ effectView::effectView( effect * _model, QWidget * _parent ) :
m_subWindow->hide();
if( m_controlView->getControlCount() == 0 )
if( getEffect()->getControls()->getControlCount() == 0 )
{
m_editButton->hide();
}