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:
18
ChangeLog
18
ChangeLog
@@ -1,3 +1,21 @@
|
||||
2008-01-17 Tobias Doerffel <tobydox/at/users/dot/sourceforge/dot/net>
|
||||
|
||||
* plugins/ladspa_effect/Makefile.am:
|
||||
* plugins/ladspa_effect/ladspa_effect.h:
|
||||
* plugins/ladspa_effect/ladspa_effect.cpp:
|
||||
* plugins/ladspa_effect/ladspa_controls.h:
|
||||
* plugins/ladspa_effect/ladspa_controls.cpp:
|
||||
* plugins/ladspa_effect/ladspa_control_dialog.h:
|
||||
* plugins/ladspa_effect/ladspa_control_dialog.cpp:
|
||||
made work again after all the changes in the last days...
|
||||
|
||||
* Makefile.am:
|
||||
* include/ladspa_control.h:
|
||||
* include/ladspa_control_view.h:
|
||||
* src/core/ladspa_control.cpp:
|
||||
* src/core/ladspa_control_view.cpp:
|
||||
splitted ladspaControl-class into ladspaControl and ladspaControlView
|
||||
|
||||
2008-01-14 Tobias Doerffel <tobydox/at/users/dot/sourceforge/dot/net>
|
||||
|
||||
* plugins/bass_booster/bassbooster_controls.h:
|
||||
|
||||
@@ -169,6 +169,7 @@ lmms_SOURCES = \
|
||||
$(srcdir)/src/core/ladspa_2_lmms.cpp \
|
||||
$(srcdir)/src/core/ladspa_manager.cpp \
|
||||
$(srcdir)/src/core/ladspa_control.cpp \
|
||||
$(srcdir)/src/core/ladspa_control_view.cpp \
|
||||
$(srcdir)/src/core/main_window.cpp \
|
||||
$(srcdir)/src/core/main.cpp \
|
||||
$(srcdir)/src/core/meter_dialog.cpp \
|
||||
@@ -384,6 +385,7 @@ lmms_SOURCES = \
|
||||
$(srcdir)/include/ladspa_manager.h \
|
||||
$(srcdir)/include/ladspa_2_lmms.h \
|
||||
$(srcdir)/include/ladspa_control.h \
|
||||
$(srcdir)/include/ladspa_control_view.h \
|
||||
$(srcdir)/include/ladspa_base.h \
|
||||
$(THIRD_PARTY_CODE)
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* ladspa_control.h - widget for controlling a LADSPA port
|
||||
* ladspa_control.h - model for controlling a LADSPA port
|
||||
*
|
||||
* Copyright (c) 2006-2007 Danny McRae <khjklujn/at/users.sourceforge.net>
|
||||
* Copyright (c) 2006-2008 Danny McRae <khjklujn/at/users.sourceforge.net>
|
||||
*
|
||||
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
|
||||
*
|
||||
@@ -25,9 +25,6 @@
|
||||
#ifndef _LADSPA_CONTROL_H
|
||||
#define _LADSPA_CONTROL_H
|
||||
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtGui/QLayout>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
@@ -43,25 +40,24 @@
|
||||
#include "knob.h"
|
||||
|
||||
|
||||
class ledCheckBox;
|
||||
class track;
|
||||
|
||||
|
||||
typedef struct portDescription port_desc_t;
|
||||
|
||||
|
||||
class ladspaControl : public QWidget, public journallingObject
|
||||
class ladspaControl : public model, public journallingObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ladspaControl( QWidget * _parent, port_desc_t * _port, track * _track,
|
||||
ladspaControl( model * _parent, port_desc_t * _port, track * _track,
|
||||
bool _link = FALSE );
|
||||
~ladspaControl();
|
||||
|
||||
|
||||
LADSPA_Data getValue( void );
|
||||
void FASTCALL setValue( LADSPA_Data _value );
|
||||
void FASTCALL setLink( bool _state );
|
||||
|
||||
|
||||
void FASTCALL linkControls( ladspaControl * _control );
|
||||
void FASTCALL unlinkControls( ladspaControl * _control );
|
||||
|
||||
@@ -69,12 +65,12 @@ public:
|
||||
{
|
||||
return( &m_toggledModel );
|
||||
}
|
||||
|
||||
|
||||
inline knobModel * getKnobModel( void )
|
||||
{
|
||||
return( &m_knobModel );
|
||||
}
|
||||
|
||||
|
||||
inline port_desc_t * getPort( void )
|
||||
{
|
||||
return( m_port );
|
||||
@@ -102,17 +98,16 @@ protected slots:
|
||||
|
||||
|
||||
private:
|
||||
bool m_link;
|
||||
port_desc_t * m_port;
|
||||
track * m_track;
|
||||
QHBoxLayout * m_layout;
|
||||
ledCheckBox * m_link;
|
||||
ledCheckBox * m_toggle;
|
||||
knob * m_knob;
|
||||
|
||||
boolModel m_linkEnabledModel;
|
||||
boolModel m_toggledModel;
|
||||
knobModel m_knobModel;
|
||||
|
||||
|
||||
friend class ladspaControlView;
|
||||
|
||||
} ;
|
||||
|
||||
#endif
|
||||
|
||||
47
include/ladspa_control_view.h
Normal file
47
include/ladspa_control_view.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* ladspa_control_view.h - widget for controlling a LADSPA port
|
||||
*
|
||||
* Copyright (c) 2006-2008 Danny McRae <khjklujn/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_CONTROL_VIEW_H
|
||||
#define _LADSPA_CONTROL_VIEW_H
|
||||
|
||||
#include <QtGui/QWidget>
|
||||
|
||||
#include "mv_base.h"
|
||||
|
||||
|
||||
class ladspaControl;
|
||||
|
||||
|
||||
class ladspaControlView : public QWidget, public modelView
|
||||
{
|
||||
public:
|
||||
ladspaControlView( QWidget * _parent, ladspaControl * _ctl );
|
||||
virtual ~ladspaControlView();
|
||||
|
||||
private:
|
||||
ladspaControl * m_ctl;
|
||||
|
||||
} ;
|
||||
|
||||
#endif
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
185
plugins/ladspa_effect/ladspa_controls.cpp
Normal file
185
plugins/ladspa_effect/ladspa_controls.cpp
Normal 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"
|
||||
|
||||
83
plugins/ladspa_effect/ladspa_controls.h
Normal file
83
plugins/ladspa_effect/ladspa_controls.h
Normal 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
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* ladspa_control.cpp - widget for controlling a LADSPA port
|
||||
* ladspa_control.cpp - model for controlling a LADSPA port
|
||||
*
|
||||
* Copyright (c) 2006-2007 Danny McRae <khjklujn/at/users.sourceforge.net>
|
||||
* Copyright (c) 2006-2008 Danny McRae <khjklujn/at/users.sourceforge.net>
|
||||
*
|
||||
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
|
||||
*
|
||||
@@ -23,144 +23,76 @@
|
||||
*/
|
||||
|
||||
|
||||
#include <QtGui/QWhatsThis>
|
||||
|
||||
#include "ladspa_control.h"
|
||||
#include "automatable_model_templates.h"
|
||||
#include "ladspa_base.h"
|
||||
#include "led_checkbox.h"
|
||||
#include "tempo_sync_knob.h"
|
||||
#include "tooltip.h"
|
||||
|
||||
|
||||
ladspaControl::ladspaControl( QWidget * _parent,
|
||||
port_desc_t * _port,
|
||||
track * _track,
|
||||
bool _link) :
|
||||
QWidget( _parent ),
|
||||
ladspaControl::ladspaControl( model * _parent, port_desc_t * _port,
|
||||
track * _track, bool _link ) :
|
||||
model( _parent ),
|
||||
m_port( _port ),
|
||||
m_track( _track ),
|
||||
m_link( NULL ),
|
||||
m_toggle( NULL ),
|
||||
m_knob( NULL ),
|
||||
m_linkEnabledModel( FALSE, FALSE, TRUE ),
|
||||
m_toggledModel( FALSE, FALSE, TRUE ),
|
||||
m_knobModel()
|
||||
m_linkEnabledModel( FALSE, FALSE, TRUE, boolModel::defaultRelStep(),
|
||||
this ),
|
||||
m_toggledModel( FALSE, FALSE, TRUE, boolModel::defaultRelStep(),
|
||||
this ),
|
||||
m_knobModel( 0, 0, 0, 1, this )
|
||||
{
|
||||
m_layout = new QHBoxLayout( this );
|
||||
|
||||
if( _link )
|
||||
{
|
||||
m_link = new ledCheckBox( "", this );
|
||||
toolTip::add( m_link, tr( "Link channels" ) );
|
||||
|
||||
m_linkEnabledModel.setValue( FALSE );
|
||||
m_linkEnabledModel.setTrack( _track );
|
||||
m_link->setModel( &m_linkEnabledModel );
|
||||
connect( &m_linkEnabledModel, SIGNAL( dataChanged() ),
|
||||
this, SLOT( linkStateChanged() ) );
|
||||
|
||||
m_layout->addWidget( m_link );
|
||||
}
|
||||
|
||||
switch( m_port->data_type )
|
||||
{
|
||||
case TOGGLED:
|
||||
m_toggledModel.setTrack( m_track );
|
||||
m_toggle = new ledCheckBox( m_port->name, this,
|
||||
QString::null,
|
||||
ledCheckBox::GREEN );
|
||||
m_toggle->setModel( &m_toggledModel );
|
||||
m_toggledModel.setTrack( _track );
|
||||
connect( &m_toggledModel, SIGNAL( dataChanged() ),
|
||||
this, SLOT( ledChanged() ) );
|
||||
setFixedSize( m_toggle->width(), m_toggle->height() );
|
||||
if( m_port->def == 1.0f )
|
||||
{
|
||||
m_toggledModel.setValue( TRUE );
|
||||
}
|
||||
if( _link )
|
||||
{
|
||||
m_layout->addWidget( m_toggle );
|
||||
setFixedSize( m_link->width() +
|
||||
m_toggle->width(),
|
||||
m_toggle->height() );
|
||||
}
|
||||
break;
|
||||
|
||||
case INTEGER:
|
||||
m_knobModel.setTrack( m_track );
|
||||
m_knobModel.setTrack( _track );
|
||||
m_knobModel.setRange( static_cast<int>( m_port->max ),
|
||||
static_cast<int>( m_port->min ),
|
||||
1 + static_cast<int>( m_port->max -
|
||||
m_port->min ) / 400 );
|
||||
m_knobModel.setInitValue(
|
||||
static_cast<int>( m_port->def ) );
|
||||
m_knob = new knob( knobBright_26, this, m_port->name );
|
||||
m_knob->setModel( &m_knobModel );
|
||||
connect( &m_knobModel, SIGNAL( dataChanged() ),
|
||||
this, SLOT( knobChanged() ) );
|
||||
|
||||
m_knob->setLabel( m_port->name );
|
||||
setFixedSize( m_knob->width(), m_knob->height() );
|
||||
m_knob->setHintText( tr( "Value:" ) + " ", "" );
|
||||
m_knob->setWhatsThis(
|
||||
tr( "Sorry, no help available." ) );
|
||||
if( _link )
|
||||
{
|
||||
m_layout->addWidget( m_knob );
|
||||
setFixedSize( m_link->width() +
|
||||
m_knob->width(),
|
||||
m_knob->height() );
|
||||
}
|
||||
break;
|
||||
|
||||
case FLOAT:
|
||||
m_knobModel.setTrack( m_track );
|
||||
m_knobModel.setTrack( _track );
|
||||
m_knobModel.setRange( m_port->min, m_port->max,
|
||||
( m_port->max - m_port->min )
|
||||
/ ( m_port->name.toUpper() == "GAIN"
|
||||
&& m_port->max == 10.0f ? 4000.0f :
|
||||
400.0f ) );
|
||||
m_knobModel.setInitValue( m_port->def );
|
||||
m_knob = new knob( knobBright_26, this, m_port->name );
|
||||
m_knob->setModel( &m_knobModel );
|
||||
connect( &m_knobModel, SIGNAL( dataChanged() ),
|
||||
this, SLOT( knobChanged() ) );
|
||||
m_knob->setLabel( m_port->name );
|
||||
m_knob->setHintText( tr( "Value:" ) + " ", "" );
|
||||
m_knob->setWhatsThis(
|
||||
tr( "Sorry, no help available." ) );
|
||||
setFixedSize( m_knob->width(), m_knob->height() );
|
||||
if( _link )
|
||||
{
|
||||
m_layout->addWidget( m_knob );
|
||||
setFixedSize( m_link->width() +
|
||||
m_knob->width(),
|
||||
m_knob->height() );
|
||||
}
|
||||
break;
|
||||
|
||||
case TIME:
|
||||
m_knobModel.setTrack( m_track );
|
||||
m_knobModel.setTrack( _track );
|
||||
m_knobModel.setRange( m_port->min, m_port->max,
|
||||
( m_port->max -
|
||||
m_port->min ) / 400.0f );
|
||||
m_knobModel.setInitValue( m_port->def );
|
||||
m_knob = new tempoSyncKnob( knobBright_26, this,
|
||||
m_port->name );
|
||||
m_knob->setModel( &m_knobModel );
|
||||
connect( &m_knobModel, SIGNAL( dataChanged() ),
|
||||
this, SLOT( knobChanged() ) );
|
||||
m_knob->setLabel( m_port->name );
|
||||
m_knob->setHintText( tr( "Value:" ) + " ", "" );
|
||||
m_knob->setWhatsThis(
|
||||
tr( "Sorry, no help available." ) );
|
||||
setFixedSize( m_knob->width(), m_knob->height() );
|
||||
if( _link )
|
||||
{
|
||||
m_layout->addWidget( m_knob );
|
||||
setFixedSize( m_link->width() +
|
||||
m_knob->width(),
|
||||
m_knob->height() );
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -230,7 +162,7 @@ void FASTCALL ladspaControl::saveSettings( QDomDocument & _doc,
|
||||
QDomElement & _this,
|
||||
const QString & _name )
|
||||
{
|
||||
if( m_link != NULL )
|
||||
if( m_link )
|
||||
{
|
||||
m_linkEnabledModel.saveSettings( _doc, _this, _name + "link" );
|
||||
}
|
||||
@@ -255,7 +187,7 @@ void FASTCALL ladspaControl::saveSettings( QDomDocument & _doc,
|
||||
void FASTCALL ladspaControl::loadSettings( const QDomElement & _this,
|
||||
const QString & _name )
|
||||
{
|
||||
if( m_link != NULL )
|
||||
if( m_link )
|
||||
{
|
||||
m_linkEnabledModel.loadSettings( _this, _name + "link" );
|
||||
}
|
||||
|
||||
115
src/core/ladspa_control_view.cpp
Normal file
115
src/core/ladspa_control_view.cpp
Normal file
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* ladspa_control_view.cpp - widget for controlling a LADSPA port
|
||||
*
|
||||
* Copyright (c) 2006-2008 Danny McRae <khjklujn/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 <QtGui/QLayout>
|
||||
|
||||
#include "ladspa_control.h"
|
||||
#include "ladspa_control_view.h"
|
||||
#include "ladspa_base.h"
|
||||
#include "led_checkbox.h"
|
||||
#include "tempo_sync_knob.h"
|
||||
#include "tooltip.h"
|
||||
|
||||
|
||||
ladspaControlView::ladspaControlView( QWidget * _parent,
|
||||
ladspaControl * _ctl ) :
|
||||
QWidget( _parent ),
|
||||
modelView( _ctl ),
|
||||
m_ctl( _ctl )
|
||||
{
|
||||
QHBoxLayout * layout = new QHBoxLayout( this );
|
||||
|
||||
ledCheckBox * link = NULL;
|
||||
|
||||
if( m_ctl->m_link )
|
||||
{
|
||||
link = new ledCheckBox( "", this );
|
||||
link->setModel( &m_ctl->m_linkEnabledModel );
|
||||
toolTip::add( link, tr( "Link channels" ) );
|
||||
layout->addWidget( link );
|
||||
}
|
||||
|
||||
knob * knb = NULL;
|
||||
|
||||
switch( m_ctl->getPort()->data_type )
|
||||
{
|
||||
case TOGGLED:
|
||||
{
|
||||
ledCheckBox * toggle = new ledCheckBox(
|
||||
m_ctl->getPort()->name, this,
|
||||
QString::null,
|
||||
ledCheckBox::GREEN );
|
||||
toggle->setModel( m_ctl->getToggledModel() );
|
||||
setFixedSize( toggle->width(), toggle->height() );
|
||||
if( m_ctl->m_link )
|
||||
{
|
||||
layout->addWidget( toggle );
|
||||
setFixedSize( link->width() + toggle->width(),
|
||||
toggle->height() );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case INTEGER:
|
||||
case FLOAT:
|
||||
knb = new knob( knobBright_26, this,
|
||||
m_ctl->getPort()->name );
|
||||
break;
|
||||
|
||||
case TIME:
|
||||
knb = new tempoSyncKnob( knobBright_26, this,
|
||||
m_ctl->getPort()->name );
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if( knb != NULL )
|
||||
{
|
||||
knb->setModel( m_ctl->getKnobModel() );
|
||||
knb->setLabel( m_ctl->getPort()->name );
|
||||
knb->setHintText( tr( "Value:" ) + " ", "" );
|
||||
knb->setWhatsThis( tr( "Sorry, no help available." ) );
|
||||
setFixedSize( knb->width(), knb->height() );
|
||||
if( m_ctl->m_link )
|
||||
{
|
||||
layout->addWidget( knb );
|
||||
setFixedSize( link->width() + knb->width(),
|
||||
knb->height() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ladspaControlView::~ladspaControlView()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user