splitted ladspaControl-class, made ladspa-effect-plugin work again

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/branches/lmms-mv@665 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Tobias Doerffel
2008-01-17 22:02:56 +00:00
parent 382d7d44b0
commit 3e93586a66
13 changed files with 541 additions and 335 deletions

View File

@@ -15,7 +15,7 @@ AM_CXXFLAGS := $(AM_CXXFLAGS) $(QT_CXXFLAGS) -DPLUGIN_NAME="ladspaeffect"
$(MOC) -o $@ $<
MOC_FILES = ./ladspa_control_dialog.moc
MOC_FILES = ./ladspa_controls.moc
BUILT_SOURCES = $(MOC_FILES) ./embedded_resources.h
@@ -34,9 +34,11 @@ CLEANFILES = $(MOC_FILES) ./embedded_resources.h
pkglib_LTLIBRARIES = libladspaeffect.la
libladspaeffect_la_SOURCES = ladspa_effect.cpp \
ladspa_controls.cpp \
ladspa_control_dialog.cpp \
ladspa_subplugin_features.cpp \
ladspa_effect.h \
ladspa_controls.h \
ladspa_control_dialog.h \
ladspa_subplugin_features.h

View File

@@ -24,119 +24,89 @@
*/
#include <QtGui/QMessageBox>
#include <QtGui/QGroupBox>
#include <QtGui/QLayout>
#include "ladspa_effect.h"
#include "ladspa_control_dialog.h"
#include "ladspa_control_view.h"
#include "led_checkbox.h"
ladspaControlDialog::ladspaControlDialog( QWidget * _parent,
ladspaEffect * _eff,
track * _track ) :
effectControlDialog( _parent, _eff ),
m_effect( _eff ),
m_processors( _eff->getProcessorCount() ),
m_track( _track ),
m_noLink( FALSE )
ladspaControlDialog::ladspaControlDialog( ladspaControls * _ctl ) :
effectControlDialog( _ctl )
{
m_mainLay = new QVBoxLayout( this );
m_effectLay = new QHBoxLayout();
m_mainLay->addLayout( m_effectLay );
QVBoxLayout * mainLay = new QVBoxLayout( this );
QHBoxLayout * effectLay = new QHBoxLayout();
mainLay->addLayout( effectLay );
multi_proc_t controls = m_effect->getControls();
m_controlCount = controls.count();
int rows = static_cast<int>( sqrt(
static_cast<double>( m_controlCount ) ) );
static_cast<double>( _ctl->m_controlCount ) ) );
for( ch_cnt_t proc = 0; proc < m_processors; proc++ )
for( ch_cnt_t proc = 0; proc < _ctl->m_processors; proc++ )
{
control_list_t p;
bool linked_control = FALSE;
control_list_t & controls = _ctl->m_controls[proc];
int row_cnt = 0;
buffer_data_t last_port = NONE;
QGroupBox * grouper;
if( m_processors > 1 )
if( _ctl->m_processors > 1 )
{
grouper = new QGroupBox( tr( "Channel " ) +
QString::number( proc + 1 ),
this );
grouper->setAlignment( Qt::Vertical );
if( proc == 0 )
{
linked_control = TRUE;
}
}
else
{
grouper = new QGroupBox( this );
grouper->setAlignment( Qt::Vertical );
}
for( multi_proc_t::iterator it = controls.begin();
grouper->setAlignment( Qt::Vertical );
for( control_list_t::iterator it = controls.begin();
it != controls.end(); it++ )
{
if( (*it)->proc == proc )
if( (*it)->getPort()->proc == proc )
{
if( last_port == NONE ||
(*it)->data_type != TOGGLED ||
( (*it)->data_type == TOGGLED &&
(*it)->getPort()->data_type != TOGGLED ||
( (*it)->getPort()->data_type == TOGGLED &&
last_port == TOGGLED ) )
{
(*it)->control =
new ladspaControl( grouper, *it,
m_track,
linked_control );
new ladspaControlView( grouper, *it );
}
else
{
while( row_cnt < rows )
{
m_blanks.append(
new QWidget( grouper ) );
new QWidget( grouper );
row_cnt++;
}
(*it)->control = new ladspaControl(
grouper, (*it),
m_track,
linked_control );
new ladspaControlView( grouper, *it );
row_cnt = 0;
}
row_cnt++;
if( row_cnt == ( rows - 1 ) )
{
row_cnt = 0;
}
last_port = (*it)->data_type;
p.append( (*it)->control );
if( linked_control )
{
connect( (*it)->control,
SIGNAL( linkChanged( Uint16, bool ) ),
this,
SLOT( linkPort( Uint16, bool ) ) );
}
last_port = (*it)->getPort()->data_type;
}
}
m_controls.append( p );
m_effectLay->addWidget( grouper );
effectLay->addWidget( grouper );
}
if( m_processors > 1 )
if( _ctl->m_processors > 1 )
{
m_mainLay->addSpacing( 3 );
mainLay->addSpacing( 3 );
QHBoxLayout * center = new QHBoxLayout();
m_mainLay->addLayout( center );
m_stereoLink = new ledCheckBox( tr( "Link Channels" ), this );
connect( m_stereoLink, SIGNAL( dataChanged() ),
this, SLOT( updateChannelLinkState() ) );
m_stereoLink->setChecked( TRUE );
center->addWidget( m_stereoLink );
mainLay->addLayout( center );
ledCheckBox * stereoLink = new ledCheckBox(
tr( "Link Channels" ), this );
stereoLink->setModel( &_ctl->m_stereoLinkModel );
center->addWidget( stereoLink );
}
}
@@ -145,108 +115,6 @@ ladspaControlDialog::ladspaControlDialog( QWidget * _parent,
ladspaControlDialog::~ladspaControlDialog()
{
for( ch_cnt_t proc = 0; proc < m_processors; proc++ )
{
m_controls[proc].clear();
}
m_controls.clear();
}
void FASTCALL ladspaControlDialog::saveSettings( QDomDocument & _doc,
QDomElement & _this )
{
if( m_processors > 1 )
{
_this.setAttribute( "link", m_stereoLink->model()->value() );
}
multi_proc_t controls = m_effect->getControls();
_this.setAttribute( "ports", controls.count() );
for( multi_proc_t::iterator it = controls.begin();
it != controls.end(); it++ )
{
QString n = "port" + QString::number( (*it)->proc ) +
QString::number( (*it)->port_id );
(*it)->control->saveSettings( _doc, _this, n );
}
}
void FASTCALL ladspaControlDialog::loadSettings( const QDomElement & _this )
{
if( m_processors > 1 )
{
m_stereoLink->model()->setValue(
_this.attribute( "link" ).toInt() );
}
multi_proc_t controls = m_effect->getControls();
for( multi_proc_t::iterator it = controls.begin();
it != controls.end(); it++ )
{
QString n = "port" + QString::number( (*it)->proc ) +
QString::number( (*it)->port_id );
(*it)->control->loadSettings( _this, n );
}
}
void ladspaControlDialog::linkPort( Uint16 _port, bool _state )
{
ladspaControl * first = m_controls[0][_port];
if( _state )
{
for( ch_cnt_t proc = 1; proc < m_processors; proc++ )
{
first->linkControls( m_controls[proc][_port] );
}
}
else
{
for( ch_cnt_t proc = 1; proc < m_processors; proc++ )
{
first->unlinkControls( m_controls[proc][_port] );
}
m_noLink = TRUE;
m_stereoLink->setChecked( FALSE );
}
}
void ladspaControlDialog::updateChannelLinkState( void )
{
if( m_stereoLink->model()->value() )
{
for( Uint16 port = 0;
port < m_controlCount / m_processors;
port++ )
{
m_controls[0][port]->setLink( TRUE );
}
}
else if( !m_noLink )
{
for( Uint16 port = 0;
port < m_controlCount / m_processors;
port++ )
{
m_controls[0][port]->setLink( FALSE );
}
}
else
{
m_noLink = FALSE;
}
}
#include "ladspa_control_dialog.moc"

View File

@@ -26,59 +26,19 @@
#ifndef _LADSPA_CONTROL_DIALOG_H
#define _LADSPA_CONTROL_DIALOG_H
#include <QtGui/QGroupBox>
#include <QtGui/QLayout>
#include "effect_control_dialog.h"
#include "ladspa_control.h"
#include "led_checkbox.h"
typedef QVector<ladspaControl *> control_list_t;
class ladspaEffect;
class ladspaControls;
class ladspaControlDialog : public effectControlDialog
{
Q_OBJECT
public:
ladspaControlDialog( QWidget * _parent, ladspaEffect * _eff,
track * _track );
virtual ~ladspaControlDialog();
inline ch_cnt_t getControlCount( void )
{
return( m_controlCount );
}
virtual void FASTCALL saveSettings( QDomDocument & _doc,
QDomElement & _parent );
virtual void FASTCALL loadSettings( const QDomElement & _this );
inline virtual QString nodeName( void ) const
{
return( "ladspacontrols" );
}
ladspaControlDialog( ladspaControls * _ctl );
~ladspaControlDialog();
protected slots:
void updateChannelLinkState( void );
void linkPort( Uint16 _port, bool _state );
private:
ladspaEffect * m_effect;
ch_cnt_t m_processors;
ch_cnt_t m_controlCount;
track * m_track;
bool m_noLink;
audioPort * m_port;
ledCheckBox * m_stereoLink;
QVector<QWidget *> m_blanks;
QVector<control_list_t> m_controls;
QVBoxLayout * m_mainLay;
QHBoxLayout * m_effectLay;
} ;

View File

@@ -0,0 +1,185 @@
/*
* ladspa_controls.cpp - model for LADSPA-plugin 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.
*
*/
#include "ladspa_effect.h"
ladspaControls::ladspaControls( ladspaEffect * _eff,
track * _track ) :
effectControls( _eff ),
m_effect( _eff ),
m_processors( _eff->getProcessorCount() ),
m_track( _track ),
m_noLink( FALSE ),
m_stereoLinkModel( TRUE, FALSE, TRUE, boolModel::defaultRelStep(),
this )
{
multi_proc_t controls = m_effect->getPortControls();
m_controlCount = controls.count();
for( ch_cnt_t proc = 0; proc < m_processors; proc++ )
{
control_list_t p;
bool linked_control = ( m_processors > 1 && proc == 0 );
buffer_data_t last_port = NONE;
for( multi_proc_t::iterator it = controls.begin();
it != controls.end(); it++ )
{
if( (*it)->proc == proc )
{
(*it)->control = new ladspaControl( this, *it,
m_track,
linked_control );
last_port = (*it)->data_type;
p.append( (*it)->control );
if( linked_control )
{
connect( (*it)->control,
SIGNAL( linkChanged( Uint16, bool ) ),
this,
SLOT( linkPort( Uint16, bool ) ) );
}
}
}
m_controls.append( p );
}
}
ladspaControls::~ladspaControls()
{
for( ch_cnt_t proc = 0; proc < m_processors; proc++ )
{
m_controls[proc].clear();
}
m_controls.clear();
}
void FASTCALL ladspaControls::saveSettings( QDomDocument & _doc,
QDomElement & _this )
{
if( m_processors > 1 )
{
_this.setAttribute( "link", m_stereoLinkModel.value() );
}
multi_proc_t controls = m_effect->getPortControls();
_this.setAttribute( "ports", controls.count() );
for( multi_proc_t::iterator it = controls.begin();
it != controls.end(); it++ )
{
QString n = "port" + QString::number( (*it)->proc ) +
QString::number( (*it)->port_id );
(*it)->control->saveSettings( _doc, _this, n );
}
}
void FASTCALL ladspaControls::loadSettings( const QDomElement & _this )
{
if( m_processors > 1 )
{
m_stereoLinkModel.setValue( _this.attribute( "link" ).toInt() );
}
multi_proc_t controls = m_effect->getPortControls();
for( multi_proc_t::iterator it = controls.begin();
it != controls.end(); it++ )
{
QString n = "port" + QString::number( (*it)->proc ) +
QString::number( (*it)->port_id );
(*it)->control->loadSettings( _this, n );
}
}
void ladspaControls::linkPort( Uint16 _port, bool _state )
{
ladspaControl * first = m_controls[0][_port];
if( _state )
{
for( ch_cnt_t proc = 1; proc < m_processors; proc++ )
{
first->linkControls( m_controls[proc][_port] );
}
}
else
{
for( ch_cnt_t proc = 1; proc < m_processors; proc++ )
{
first->unlinkControls( m_controls[proc][_port] );
}
m_noLink = TRUE;
m_stereoLinkModel.setValue( FALSE );
}
}
void ladspaControls::updateChannelLinkState( void )
{
if( m_stereoLinkModel.value() )
{
for( Uint16 port = 0;
port < m_controlCount / m_processors;
port++ )
{
m_controls[0][port]->setLink( TRUE );
}
}
else if( !m_noLink )
{
for( Uint16 port = 0;
port < m_controlCount / m_processors;
port++ )
{
m_controls[0][port]->setLink( FALSE );
}
}
else
{
m_noLink = FALSE;
}
}
#include "ladspa_controls.moc"

View File

@@ -0,0 +1,83 @@
/*
* ladspa_controls.h - model for LADSPA-plugin 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 _LADSPA_CONTROLS_H
#define _LADSPA_CONTROLS_H
#include "effect_controls.h"
#include "ladspa_control.h"
#include "ladspa_control_dialog.h"
typedef QVector<ladspaControl *> control_list_t;
class ladspaEffect;
class ladspaControls : public effectControls
{
Q_OBJECT
public:
ladspaControls( ladspaEffect * _eff, track * _track );
virtual ~ladspaControls();
inline ch_cnt_t getControlCount( void )
{
return( m_controlCount );
}
virtual void FASTCALL saveSettings( QDomDocument & _doc,
QDomElement & _parent );
virtual void FASTCALL loadSettings( const QDomElement & _this );
inline virtual QString nodeName( void ) const
{
return( "ladspacontrols" );
}
virtual effectControlDialog * createView( void )
{
return( new ladspaControlDialog( this ) );
}
protected slots:
void updateChannelLinkState( void );
void linkPort( Uint16 _port, bool _state );
private:
ladspaEffect * m_effect;
ch_cnt_t m_processors;
ch_cnt_t m_controlCount;
track * m_track;
bool m_noLink;
boolModel m_stereoLinkModel;
QVector<control_list_t> m_controls;
friend class ladspaControlDialog;
} ;
#endif

View File

@@ -62,10 +62,9 @@ plugin::descriptor ladspaeffect_plugin_descriptor =
ladspaEffect::ladspaEffect( model * _parent,
const descriptor::subPluginFeatures::key * _key ) :
effect( &ladspaeffect_plugin_descriptor, _parent, _key ),
m_controls( NULL ),
m_effName( "none" ),
m_key( ladspaSubPluginFeatures::subPluginKeyToLadspaKey( _key )
/* ladspa_key_t( _cdata->settings.attribute( "label" ),
_cdata->settings.attribute( "lib" ) )*/ )
m_key( ladspaSubPluginFeatures::subPluginKeyToLadspaKey( _key ) )
{
ladspa2LMMS * manager = engine::getLADSPAManager();
if( manager->getDescription( m_key ) == NULL )
@@ -230,8 +229,8 @@ ladspaEffect::ladspaEffect( model * _parent,
if( p->rate == AUDIO_RATE_INPUT ||
p->rate == CONTROL_RATE_INPUT )
{
p->control_id = m_controls.count();
m_controls.append( p );
p->control_id = m_portControls.count();
m_portControls.append( p );
}
}
m_ports.append( ports );
@@ -293,6 +292,8 @@ ladspaEffect::ladspaEffect( model * _parent,
{
manager->activate( m_key, m_handles[proc] );
}
m_controls = new ladspaControls( this, NULL /* TODO!! */ );
}
@@ -461,7 +462,7 @@ void FASTCALL ladspaEffect::setControl( Uint16 _control, LADSPA_Data _value )
{
return;
}
m_controls[_control]->value = _value;
m_portControls[_control]->value = _value;
}

View File

@@ -30,8 +30,7 @@
#include "effect.h"
#include "engine.h"
#include "ladspa_base.h"
#include "ladspa_control.h"
#include "ladspa_control_dialog.h"
#include "ladspa_controls.h"
#include "main_window.h"
#include "mixer.h"
@@ -50,11 +49,16 @@ public:
void FASTCALL setControl( Uint16 _control, LADSPA_Data _data );
inline const multi_proc_t & getControls( void )
virtual effectControls * getControls( void )
{
return( m_controls );
}
inline const multi_proc_t & getPortControls( void )
{
return( m_portControls );
}
virtual inline QString publicName( void ) const
{
return( m_effName );
@@ -65,14 +69,6 @@ public:
m_effName = _name;
}
virtual inline effectControlDialog * createControlDialog(
track * _track )
{
return( new ladspaControlDialog(
NULL /*engine::getMainWindow()->workspace()*/,
this, _track ) );
}
inline virtual QString nodeName( void ) const
{
return( "ladspaeffect" );
@@ -80,6 +76,8 @@ public:
private:
ladspaControls * m_controls;
QString m_effName;
ladspa_key_t m_key;
Uint16 m_effectChannels;
@@ -90,7 +88,7 @@ private:
QVector<LADSPA_Handle> m_handles;
QVector<multi_proc_t> m_ports;
multi_proc_t m_controls;
multi_proc_t m_portControls;
} ;
#endif