generic powerful effect-framework

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@397 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Tobias Doerffel
2006-09-17 12:45:09 +00:00
parent d8214879d1
commit 9c41572504
62 changed files with 2972 additions and 427 deletions

View File

@@ -38,13 +38,9 @@
#endif
#include "ladspa_manager.h"
#ifdef LADSPA_SUPPORT
#include "effect_chain.h"
#endif
#include "mixer.h"
#include "effect_board.h"
#include "effect_chain.h"
class audioPort : public engineObject
@@ -80,12 +76,10 @@ public:
return( m_nextFxChannel );
}
#ifdef LADSPA_SUPPORT
inline effectChain * getEffects( void )
{
return( m_effects );
}
#endif
void setNextFxChannel( const fx_ch_t _chnl )
{
@@ -106,9 +100,7 @@ public:
NONE, FIRST, BOTH
} m_bufferUsage;
#ifdef LADSPA_SUPPORT
inline bool processEffects( void ) { return( m_effects->processAudioBuffer( m_firstBuffer, m_frames ) ); };
#endif
private:
surroundSampleFrame * m_firstBuffer;
@@ -118,10 +110,8 @@ private:
QString m_name;
#ifdef LADSPA_SUPPORT
effectChain * m_effects;
fpab_t m_frames;
#endif
} ;

67
include/dummy_effect.h Normal file
View File

@@ -0,0 +1,67 @@
/*
* dummy_effect.h - effect used as fallback if an effect couldn't be loaded
*
* Copyright (c) 2006 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 _DUMMY_EFFECT_H
#define _DUMMY_EFFECT_H
#include "effect.h"
class dummyEffect : public effect
{
public:
inline dummyEffect( void ) :
effect( NULL, NULL )
{
}
inline virtual ~dummyEffect()
{
}
inline virtual void saveSettings( QDomDocument &, QDomElement & )
{
}
inline virtual void loadSettings( const QDomElement & )
{
}
inline virtual QString nodeName( void ) const
{
return( "dummyeffect" );
}
inline virtual effectControlDialog * createControlDialog( track * )
{
// TODO: setup a dummy control-dialog for not crashing LMMS
return( NULL );
}
} ;
#endif

View File

@@ -2,6 +2,7 @@
* effect.h - base class for effects
*
* Copyright (c) 2006 Danny McRae <khjklujn/at/users.sourceforge.net>
* Copyright (c) 2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -22,12 +23,10 @@
*
*/
#ifndef _EFFECT_H
#define _EFFECT_H
#include "ladspa_manager.h"
#ifdef LADSPA_SUPPORT
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -35,24 +34,37 @@
#ifdef QT4
#include <QtCore/QMutex>
#include <Qt/QtXml>
#else
#include<qmutex.h>
#include <qmutex.h>
#include <qdom.h>
#endif
#include "qt3support.h"
#include "engine.h"
#include "plugin.h"
#include "mixer.h"
class effect: public engineObject
class effectControlDialog;
class track;
class effect : public plugin
{
public:
effect( engine * _engine );
struct constructionData
{
engine * eng;
descriptor::subPluginFeatures::key key;
} ;
effect( const plugin::descriptor * _desc, constructionData * _cdata );
virtual ~effect();
virtual bool FASTCALL processAudioBuffer(
@@ -129,17 +141,6 @@ public:
{
m_wetDry = _wet;
}
inline const QString & getName( void )
{
return( m_name );
}
inline void setName( QString _name )
{
m_name = _name;
}
inline float getGate( void )
{
return( m_gate );
@@ -186,9 +187,21 @@ public:
{
m_noRun = _state;
}
inline const descriptor::subPluginFeatures::key & getKey( void )
{
return( m_key );
}
virtual effectControlDialog * createControlDialog( track * _track ) = 0;
static effect * FASTCALL instantiate( const QString & _plugin_name,
constructionData & _cdata );
private:
QString m_name;
descriptor::subPluginFeatures::key m_key;
ch_cnt_t m_processors;
bool m_okay;
@@ -202,8 +215,12 @@ private:
float m_wetDry;
float m_gate;
QMutex m_processLock;
};
#endif
} ;
typedef effect::descriptor::subPluginFeatures::key effectKey;
typedef effect::descriptor::subPluginFeatures::keyList effectKeyList;
#endif

View File

@@ -25,9 +25,6 @@
#ifndef _EFFECT_CHAIN_H
#define _EFFECT_CHAIN_H
#include "ladspa_manager.h"
#ifdef LADSPA_SUPPORT
#ifdef QT4
#include <QtCore/QMutex>
@@ -49,7 +46,7 @@ class effectChain: public engineObject
{
public:
effectChain( engine * _engine );
~effectChain();
virtual ~effectChain();
void FASTCALL appendEffect( effect * _effect );
void FASTCALL deleteEffect( effect * _effect );
@@ -79,9 +76,3 @@ private:
#endif
#endif

View File

@@ -0,0 +1,76 @@
/*
* effect_control_dialog.h - base-class for effect-dialogs for displaying and
* editing control port values
*
* Copyright (c) 2006 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_CONTROL_DIALOG_H
#define _EFFECT_CONTROL_DIALOG_H
#ifdef QT4
#include <QtGui/QWidget>
#else
#include <qwidget.h>
#endif
#include "qt3support.h"
#include "journalling_object.h"
#include "effect.h"
class track;
class effectControlDialog : public QWidget, public journallingObject
{
Q_OBJECT
public:
effectControlDialog( QWidget * _parent, effect * _eff );
virtual ~effectControlDialog();
virtual ch_cnt_t getControlCount( void ) = 0;
signals:
void closed();
protected:
virtual void closeEvent( QCloseEvent * _ce );
template<class T>
T * getEffect( void )
{
return( dynamic_cast<T *>( m_effect ) );
}
private:
effect * m_effect;
} ;
#endif

View File

@@ -26,8 +26,7 @@
#ifndef _EFFECT_LABEL_H
#define _EFFECT_LABEL_H
#include "ladspa_manager.h"
#ifdef LADSPA_SUPPORT
#include "qt3support.h"
#ifdef QT4
@@ -101,5 +100,3 @@ private:
};
#endif
#endif

View File

@@ -0,0 +1,108 @@
/*
* effect_select_dialog.h - dialog to choose effect plugin
*
* Copyright (c) 2006 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_SELECT_DIALOG_H
#define _EFFECT_SELECT_DIALOG_H
#include "qt3support.h"
#ifdef QT4
#include <QtGui/QDialog>
#include <Qt3Support/Q3ListBox>
#define QListBoxItem Q3ListBoxItem
#else
#include <qdialog.h>
#include <qlistbox.h>
#define Q3ListBox QListBox
#endif
#include "engine.h"
#include "effect.h"
class effectSelectDialog : public QDialog, public engineObject
{
Q_OBJECT
public:
effectSelectDialog( QWidget * _parent, engine * _engine );
virtual ~effectSelectDialog();
effect * instantiateSelectedPlugin( void );
public slots:
void showPorts( void );
void setSelection( const effectKey & _selection );
void selectPlugin( void );
private:
effectKey m_currentSelection;
} ;
class effectList : public QWidget, public engineObject
{
Q_OBJECT
public:
effectList( QWidget * _parent, engine * _engine );
virtual ~effectList();
inline effectKey getSelected( void )
{
return( m_currentSelection );
}
signals:
void highlighted( const effectKey & _key );
void addPlugin( const effectKey & _key );
void doubleClicked( const effectKey & _key );
protected slots:
void onHighlighted( int _plugin );
void onAddButtonReleased();
void onDoubleClicked( QListBoxItem * _item );
private:
vvector<plugin::descriptor> m_pluginDescriptors;
effectKeyList m_effectKeys;
effectKey m_currentSelection;
Q3ListBox * m_pluginList;
QWidget * m_descriptionWidgetParent;
QWidget * m_descriptionWidget;
} ;
#endif

View File

@@ -27,9 +27,6 @@
#ifndef _EFFECT_TAB_WIDGET_H
#define _EFFECT_TAB_WIDGET_H
#include "ladspa_manager.h"
#ifdef LADSPA_SUPPORT
#include "qt3support.h"
#ifdef QT4
@@ -108,7 +105,4 @@ private:
} ;
#endif
#endif

View File

@@ -96,7 +96,7 @@ public:
// instantiate instrument-plugin with given name or return NULL
// on failure
static instrument * FASTCALL instantiate( const QString & _plugin_name,
instrumentTrack * _channel_track );
instrumentTrack * _channel_track );
protected:
inline instrumentTrack * getInstrumentTrack( void ) const

View File

@@ -69,12 +69,8 @@ class notePlayHandle;
class pianoWidget;
class presetPreviewPlayHandle;
class surroundArea;
class flpImport;
#ifdef LADSPA_SUPPORT
class effectTabWidget;
#endif
class instrumentTrack : public QWidget, public track, public midiEventProcessor
@@ -248,9 +244,7 @@ private:
envelopeTabWidget * m_envWidget;
arpAndChordsTabWidget * m_arpWidget;
midiTabWidget * m_midiWidget;
#ifdef LADSPA_SUPPORT
effectTabWidget * m_effWidget;
#endif
// test-piano at the bottom of every instrument-settings-window
pianoWidget * m_pianoWidget;

94
include/ladspa_base.h Normal file
View File

@@ -0,0 +1,94 @@
/*
* ladspa_base.h - basic declarations concerning LADSPA
*
* Copyright (c) 2006 Danny McRae <khjklujn/at/users.sourceforge.net>
* Copyright (c) 2006 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_BASE_H
#define _LADSPA_BASE_H
#include "ladspa_manager.h"
#ifdef LADSPA_SUPPORT
#include "plugin.h"
class ladspaControl;
typedef enum bufferRates
{
CHANNEL_IN,
CHANNEL_OUT,
AUDIO_RATE_INPUT,
AUDIO_RATE_OUTPUT,
CONTROL_RATE_INPUT,
CONTROL_RATE_OUTPUT
} buffer_rate_t;
typedef enum bufferData
{
TOGGLED,
INTEGER,
FLOAT,
TIME,
NONE
} buffer_data_t;
typedef struct portDescription
{
QString name;
ch_cnt_t proc;
Uint16 port_id;
Uint16 control_id;
buffer_rate_t rate;
buffer_data_t data_type;
float scale;
LADSPA_Data max;
LADSPA_Data min;
LADSPA_Data def;
LADSPA_Data value;
LADSPA_Data * buffer;
ladspaControl * control;
} port_desc_t;
inline ladspa_key_t subPluginKeyToLadspaKey(
const plugin::descriptor::subPluginFeatures::key & _key )
{
return( ladspa_key_t( _key.user.toStringList().first(),
_key.user.toStringList().last() ) );
}
inline plugin::descriptor::subPluginFeatures::key ladspaKeyToSubPluginKey(
plugin::descriptor * _desc,
const QString & _name,
const ladspa_key_t & _key )
{
return( plugin::descriptor::subPluginFeatures::key( _desc, _name,
QVariant( QStringList() << _key.first << _key.second ) ) );
}
#endif
#endif

View File

@@ -1,3 +1,4 @@
#if 0
/*
* ladspa_browser.h - dialog to display information about installed LADSPA
* plugins
@@ -73,3 +74,6 @@ private:
#endif
#endif
#endif

View File

@@ -58,7 +58,7 @@
#include "types.h"
#include "qt3support.h"
//#include "qt3support.h"
class engine;
@@ -82,7 +82,7 @@ calls using:
as the plug-in key. */
enum pluginType
enum ladspaPluginType
{
SOURCE,
TRANSFER,
@@ -96,7 +96,7 @@ typedef struct ladspaManagerStorage
{
LADSPA_Descriptor_Function descriptorFunction;
Uint32 index;
pluginType type;
ladspaPluginType type;
Uint16 inputChannels;
Uint16 outputChannels;
} ladspaManagerDescription;

View File

@@ -0,0 +1,68 @@
/*
* ladspa_subplugin_features.h - derivation from
* plugin::descriptor::subPluginFeatures for
* hosting LADSPA-plugins
*
* Copyright (c) 2006 Danny McRae <khjklujn/at/users.sourceforge.net>
* Copyright (c) 2006 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_SUBPLUGIN_FEATURES_H
#define _LADSPA_SUBPLUGIN_FEATURES_H
#include "plugin.h"
#include "ladspa_2_lmms.h"
#ifdef LADSPA_SUPPORT
class QLabel;
class ladspa2LMMS;
class ladspaSubPluginDescriptionWidget : public QWidget
{
public:
ladspaSubPluginDescriptionWidget( QWidget * _parent, engine * _engine,
const ladspa_key_t & _key );
} ;
class ladspaSubPluginFeatures : public plugin::descriptor::subPluginFeatures
{
public:
ladspaSubPluginFeatures( plugin::pluginTypes _type );
virtual QWidget * createDescriptionWidget( QWidget * _parent,
engine * _eng,
const key & _key );
virtual void listSubPluginKeys( engine * _eng,
plugin::descriptor * _desc, keyList & _kl );
} ;
#endif
#endif

View File

@@ -119,7 +119,7 @@ public slots:
void showSettingsDialog( void );
void aboutLMMS( void );
void help( void );
void ladspaPluginBrowser( void );
// void ladspaPluginBrowser( void );
void toggleAutomationEditorWin( void );
void toggleBBEditorWin( void );
void toggleSongEditorWin( void );

View File

@@ -49,6 +49,7 @@
#include "types.h"
#include "journalling_object.h"
#include "embed.h"
#include "base64.h"
#define STRINGIFY_PLUGIN_NAME(s) STR(s)
@@ -56,6 +57,7 @@
class QPixmap;
class QWidget;
class plugin : public journallingObject
@@ -63,11 +65,13 @@ class plugin : public journallingObject
public:
enum pluginTypes
{
INSTRUMENT, // instrument being used in channel-track
EFFECT, // effect-plugin for effect-board
IMPORT_FILTER, // filter for importing a file
EXPORT_FILTER, // filter for exporting a file
UNDEFINED = 255
Instrument, // instrument being used in channel-track
Effect, // effect-plugin for effect-board
ImportFilter, // filter for importing a file
ExportFilter, // filter for exporting a file
AnalysisTools, // analysis-tools (level-meter etc)
Other,
Undefined = 255
} ;
// descriptor holds information about a plugin - every external plugin
@@ -82,6 +86,68 @@ public:
int version;
pluginTypes type;
const QPixmap * logo;
class subPluginFeatures
{
public:
struct key
{
inline key( plugin::descriptor * _desc = NULL,
const QString & _name = QString::null,
const QVariant & _user = QVariant() )
:
desc( _desc ),
name( _name ),
user( _user )
{
}
inline key( const QString & _dump_data )
:
desc( NULL )
{
const vlist<QVariant> l =
base64::decode( _dump_data ).
toList();
name = l[0].toString();
user = l[1];
}
inline QString dumpBase64( void ) const
{
return( base64::encode(
vlist<QVariant>()
<< name << user ) );
}
plugin::descriptor * desc;
QString name;
QVariant user;
};
typedef vlist<key> keyList;
subPluginFeatures( plugin::pluginTypes _type ) :
m_type( _type )
{
}
virtual ~subPluginFeatures()
{
}
virtual QWidget * createDescriptionWidget(
QWidget *, engine *, const key & )
{
return( NULL );
}
virtual void listSubPluginKeys( engine *,
plugin::descriptor *,
keyList & )
{
}
protected:
const plugin::pluginTypes m_type;
}
* sub_plugin_features;
} ;
// contructor of a plugin
@@ -89,7 +155,7 @@ public:
virtual ~plugin();
// returns public-name out of descriptor
inline QString publicName( void ) const
virtual inline QString publicName( void ) const
{
return( m_descriptor->public_name );
}

View File

@@ -1,6 +1,6 @@
/*
* effect_tab_widget.h - tab-widget in channel-track-window for setting up
* effects
* rack_plugin.h - tab-widget in channel-track-window for setting up
* effects
*
* Copyright (c) 2006 Danny McRae <khjklujn/at/users.sourceforge.net>
*
@@ -25,9 +25,6 @@
#ifndef _RACK_PLUGIN_H
#define _RACK_PLUGIN_H
#include "ladspa_manager.h"
#ifdef LADSPA_SUPPORT
#ifdef QT4
#include <QtGui/QWidget>
@@ -48,13 +45,12 @@
#include "journalling_object.h"
#include "led_checkbox.h"
#include "track.h"
#include "ladspa_effect.h"
#include "ladspa_control_dialog.h"
#include "audio_port.h"
class knob;
class tempoSyncKnob;
class effectControlDialog;
class rackPlugin: public QWidget, public journallingObject
@@ -62,20 +58,15 @@ class rackPlugin: public QWidget, public journallingObject
Q_OBJECT
public:
rackPlugin( QWidget * _parent, ladspa_key_t _key,
track * _track, engine * _engine, audioPort * _port );
~rackPlugin();
rackPlugin( QWidget * _parent, effect * _eff, track * _track,
audioPort * _port );
virtual ~rackPlugin();
inline effect * getEffect()
{
return( m_effect );
}
inline const ladspa_key_t & getKey( void )
{
return( m_key );
}
virtual void FASTCALL saveSettings( QDomDocument & _doc,
QDomElement & _parent );
virtual void FASTCALL loadSettings( const QDomElement & _this );
@@ -113,16 +104,13 @@ private:
QGroupBox * m_controls;
QLabel * m_label;
QPushButton * m_editButton;
ladspaEffect * m_effect;
ladspaControlDialog * m_controlView;
effect * m_effect;
effectControlDialog * m_controlView;
track * m_track;
audioPort * m_port;
QMenu * m_contextMenu;
ladspa_key_t m_key;
QString m_name;
bool m_show;
};
#endif
} ;
#endif

View File

@@ -21,11 +21,8 @@
* Boston, MA 02110-1301 USA.
*
*/
#ifndef _RIGHT_FRAME_H
#define _RIGHT_FRAME_H
#include "ladspa_manager.h"
#ifdef LADSPA_SUPPORT
#ifndef _RACK_VIEW_H
#define _RACK_VIEW_H
#ifdef QT4
@@ -48,7 +45,6 @@
#include "journalling_object.h"
#include "rack_plugin.h"
#include "track.h"
#include "ladspa_2_lmms.h"
#include "audio_port.h"
@@ -61,7 +57,7 @@ public:
track * _track, audioPort * _port );
~rackView();
void addPlugin( ladspa_key_t _key );
void addEffect( effect * _e );
virtual void FASTCALL saveSettings( QDomDocument & _doc,
QDomElement & _parent );
@@ -88,10 +84,7 @@ private:
audioPort * m_port;
Uint32 m_lastY;
ladspa2LMMS * m_ladspa;
};
#endif
} ;
#endif

View File

@@ -45,12 +45,7 @@
#include "volume_knob.h"
#include "ladspa_manager.h"
#ifdef LADSPA_SUPPORT
class effectLabel;
#else
class nameLabel;
#endif
class audioPort;
class QLabel;
@@ -160,11 +155,7 @@ public:
private:
#ifdef LADSPA_SUPPORT
effectLabel * m_trackLabel;
#else
nameLabel * m_trackLabel;
#endif
audioPort * m_audioPort;
volumeKnob * m_volumeKnob;