LV2: fixed serious violations of coding style conventions

Unfortunately new LV2 code didn't respect coding style conventions
so I fixed most of it and did various other cleanups. Still needs some
work though.
This commit is contained in:
Tobias Doerffel
2009-04-30 00:53:03 +02:00
parent b40a9e1905
commit 324b5afb50
9 changed files with 384 additions and 957 deletions

View File

@@ -1,12 +1,10 @@
/*
* ladspa_manager.h - declaration of class lv2Manager
* a class to manage
* lv2 plugins
* lv2_manager.h - declaration of class lv2Manager a class to manage lv2 plugins
*
* Copyright (c) 2005-2008 Danny McRae <khjklujn@netscape.net>
* Copyright (c) 2009 Martin Andrews <mdda/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
@@ -28,11 +26,10 @@
#ifndef _LV2_MANAGER_H
#define _LV2_MANAGER_H
//#include <ladspa.h>
#include "slv2/world.h"
#include "slv2/plugin.h"
#include "slv2/scalepoint.h"
#include "slv2/scalepoints.h"
#include <slv2/world.h>
#include <slv2/plugin.h>
#include <slv2/scalepoint.h>
#include <slv2/scalepoints.h>
#include <QtCore/QMap>
#include <QtCore/QPair>
@@ -59,7 +56,7 @@ the filename the plug-in was loaded from and the label of the plug-in.
The can be retrieved by using lv2_key_t (which is really just the LV2 URI) :
// lv2_key_t key( "lalala" )
as the plug-in key. */
@@ -99,10 +96,9 @@ enum lv2PluginType
typedef struct lv2ManagerStorage
{
SLV2Plugin plugin;
// Uint32 index;
QString uri;
QString name;
SLV2Plugin plugin;
QString uri;
QString name;
lv2PluginType type;
Uint16 inputChannels;
Uint16 outputChannels;
@@ -112,16 +108,15 @@ typedef struct lv2ManagerStorage
class EXPORT lv2Manager
{
public:
lv2Manager( void );
virtual ~lv2Manager();
virtual ~lv2Manager();
void loadFromCacheFile();
void saveToCacheFile();
void loadFromCacheFile();
void saveToCacheFile();
l_sortable_plugin_t getSortedPlugins();
lv2ManagerDescription * getDescription( const lv2_key_t & _plugin );
/* This identifier can be used as a unique, case-sensitive
identifier for the plugin type within the plugin file. Plugin
types should be identified by file and label rather than by index
@@ -134,7 +129,7 @@ public:
be cached or subject to significant latency. */
// bool hasRealTimeDependency( const lv2_key_t & _plugin );
/* Indicates that the plugin may cease to work correctly if the
/* Indicates that the plugin may cease to work correctly if the
host elects to use the same data location for both input and output
(see connectPort). */
bool isInplaceBroken( const lv2_key_t & _plugin );
@@ -169,13 +164,13 @@ public:
/* Indicates that the port is an control. */
bool isPortControl( const lv2_key_t & _plugin, Uint32 _port );
/* Indicates that any bounds specified should be interpreted as
multiples of the sample rate. For instance, a frequency range from
0Hz to the Nyquist frequency (half the sample rate) could be requested
by this hint in conjunction with LowerBound = 0 and UpperBound = 0.5.
/* Indicates that any bounds specified should be interpreted as
multiples of the sample rate. For instance, a frequency range from
0Hz to the Nyquist frequency (half the sample rate) could be requested
by this hint in conjunction with LowerBound = 0 and UpperBound = 0.5.
Hosts that support bounds at all must support this hint to retain
meaning. */
// bool areHintsSampleRateDependent( const ladspa_key_t & _plugin,
// bool areHintsSampleRateDependent( const ladspa_key_t & _plugin,
// Uint32 _port );
/* Returns the lower boundary value for the given port. If
@@ -194,30 +189,30 @@ public:
the given port. */
float getDefaultSetting( const lv2_key_t & _plugin, Uint32 _port );
/* Indicates that a user interface would probably wish to provide a
stepped control taking only integer values. Any bounds set should be
/* Indicates that a user interface would probably wish to provide a
stepped control taking only integer values. Any bounds set should be
slightly wider than the actual integer range required to avoid floating
point rounding errors. For instance, the integer set {0,1,2,3} might
point rounding errors. For instance, the integer set {0,1,2,3} might
be described as [-0.1, 3.1]. */
bool isInteger( const lv2_key_t & _plugin, Uint32 _port );
/* Indicates whether the given port should be considered 0 or 1
boolean switch. */
bool isPortToggled( const lv2_key_t & _plugin, Uint32 _port );
/* return the labels to be applied on the UI */
QStringList listEnumeration( const lv2_key_t & _plugin, Uint32 _port );
QStringList listEnumeration( const lv2_key_t & _plugin, Uint32 _port );
/* Indicates that it is likely that the user will find it more
intuitive to view values using a logarithmic scale. This is
particularly useful for frequencies and gains. */
// bool isLogarithmic( const ladspa_key_t & _plugin, Uint32 _port );
/* Returns the name of the port. */
QString getPortName( const lv2_key_t & _plugin, Uint32 _port );
/* This may be used by the plugin developer to pass any custom
implementation data into an instantiate call. It must not be used
or interpreted by the host. It is expected that most plugin
@@ -225,24 +220,24 @@ public:
used to hold instance data. */
// const void * getImplementationData(
// const ladspa_key_t & _plugin );
/* Returns a pointer to the plug-in's descriptor from which control
of the plug-in is accessible */
// const LADSPA_Descriptor * getDescriptor(
// const ladspa_key_t & _plugin );
/* The following methods are convenience functions for use during
development. A real instrument should use the getDescriptor()
method and implement the plug-in manipulations internally to avoid
the overhead associated with QMap lookups. */
/* Returns a handle to an instantiation of the given plug-in. */
//LADSPA_Handle instantiate( const ladspa_key_t & _plugin,
//LADSPA_Handle instantiate( const ladspa_key_t & _plugin,
// Uint32 _sample_rate );
/* This method calls a function pointer that connects a port on an
instantiated plugin to a memory location at which a block of data
for the port will be read/written. The data location is expected
@@ -260,11 +255,11 @@ public:
connectPort() must be called at least once for each port before
run() or runAdding() is called. */
// bool connectPort( const ladspa_key_t & _plugin,
// LADSPA_Handle _instance,
// bool connectPort( const ladspa_key_t & _plugin,
// LADSPA_Handle _instance,
// Uint32 _port,
// LADSPA_Data * _data_location );
/* This method calls a function pointer that initialises a plugin
instance and activates it for use. This is separated from
instantiate() to aid real-time support and so that hosts can
@@ -297,7 +292,7 @@ public:
before run() or run_adding(). If deactivate() is called for a
plugin instance then the plugin instance may not be reused until
activate() has been called again. */
// bool run( const ladspa_key_t & _plugin,
// bool run( const ladspa_key_t & _plugin,
// LADSPA_Handle _instance,
// Uint32 _sample_count );
@@ -350,7 +345,7 @@ public:
/* Once an instance of a plugin has been finished with it can be
deleted using the following function. The instance handle passed
ceases to be valid after this call.
If activate() was called for a plugin instance then a
corresponding call to deactivate() must be made before cleanup()
is called. */
@@ -358,27 +353,29 @@ public:
// LADSPA_Handle _instance );
private:
void addPlugins( SLV2Plugin _plugin );
void ensureLV2DataExists( lv2ManagerDescription *desc );
void addPlugins( SLV2Plugin _plugin );
void ensureLV2DataExists( lv2ManagerDescription *desc );
bool isPortClass( const lv2_key_t & _plugin,
Uint32 _port, SLV2Value _class );
bool isPortClass( const lv2_key_t & _plugin,
Uint32 _port, SLV2Value _class );
void getRanges( const lv2_key_t & _plugin,
Uint32 _port, float * _def, float * _min, float * _max );
void getRanges( const lv2_key_t & _plugin,
Uint32 _port, float * _def, float * _min, float * _max );
SLV2Plugins m_plugin_list;
SLV2Plugins m_pluginList;
typedef QMap<lv2_key_t, lv2ManagerDescription *> lv2ManagerMapType;
lv2ManagerMapType m_lv2ManagerMap;
l_sortable_plugin_t m_sortedPlugins;
LV2World m_lv2_bundle;
LV2World m_lv2_bundle;
QString m_cacheFile;
QString m_cache_file;
} ;
// This is declared static in lv2_manager.cpp
// TODO: integrate into LMMS engine
extern lv2Manager * static_lv2_manager; // There is only one of these...
#endif

View File

@@ -1,9 +1,8 @@
/*
* lv2_browser.cpp - dialog to display information about installed LV2
* plugins
* lv2_browser.cpp - dialog to display information about installed LV2 plugins
*
* Copyright (c) 2009 Martin Andrews <mdda/at/users.sourceforge.net>
*
* Copyright (c) 2009-2009 Martin Andrews <mdda/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
@@ -66,7 +65,7 @@ plugin::descriptor PLUGIN_EXPORT lv2browser_plugin_descriptor =
// neccessary for getting instance out of shared lib
plugin * PLUGIN_EXPORT lmms_plugin_main( model * _parent, void * _data )
{
return( new lv2Browser );
return new lv2Browser;
}
}
@@ -77,10 +76,10 @@ plugin * PLUGIN_EXPORT lmms_plugin_main( model * _parent, void * _data )
lv2Browser::lv2Browser( void ) :
tool( &lv2browser_plugin_descriptor, NULL )
{
if( static_lv2_manager == NULL )
{
static_lv2_manager=new lv2Manager();
}
if( static_lv2_manager == NULL )
{
static_lv2_manager = new lv2Manager();
}
}
@@ -88,10 +87,10 @@ lv2Browser::lv2Browser( void ) :
lv2Browser::~lv2Browser()
{
if( static_lv2_manager != NULL )
{
delete static_lv2_manager;
}
if( static_lv2_manager != NULL )
{
delete static_lv2_manager;
}
}
@@ -99,7 +98,7 @@ lv2Browser::~lv2Browser()
QString lv2Browser::nodeName( void ) const
{
return( lv2browser_plugin_descriptor.name );
return lv2browser_plugin_descriptor.name;
}
@@ -115,34 +114,34 @@ lv2BrowserView::lv2BrowserView( tool * _tool ) :
hlayout->setMargin( 0 );
m_tabBar = new tabBar( this, QBoxLayout::TopToBottom );
m_tabBar->setExclusive( TRUE );
m_tabBar->setExclusive( true );
m_tabBar->setFixedWidth( 72 );
QWidget * ws = new QWidget( this );
ws->setFixedSize( 500, 480 );
QWidget * available = createTab( ws, tr( "Available Effects" ), VALID );
QWidget * available = createTab( ws, tr( "Available Effects" ), VALID );
QWidget * unavailable = createTab( ws, tr( "Unavailable Effects" ), INVALID );
QWidget * instruments = createTab( ws, tr( "Instruments" ), SOURCE );
QWidget * analysis = createTab( ws, tr( "Analysis Tools" ), SINK );
QWidget * other = createTab( ws, tr( "Don't know" ), OTHER );
m_tabBar->addTab( available, tr( "Available Effects" ),
0, FALSE, TRUE
m_tabBar->addTab( available, tr( "Available Effects" ),
0, false, true
)->setIcon( embed::getIconPixmap( "setup_audio" ) );
m_tabBar->addTab( unavailable, tr( "Unavailable Effects" ),
1, FALSE, TRUE
m_tabBar->addTab( unavailable, tr( "Unavailable Effects" ),
1, false, true
)->setIcon( embed::getIconPixmap(
"unavailable_sound" ) );
m_tabBar->addTab( instruments, tr( "Instruments" ),
2, FALSE, TRUE
m_tabBar->addTab( instruments, tr( "Instruments" ),
2, false, true
)->setIcon( embed::getIconPixmap(
"setup_midi" ) );
m_tabBar->addTab( analysis, tr( "Analysis Tools" ),
3, FALSE, TRUE
m_tabBar->addTab( analysis, tr( "Analysis Tools" ),
3, false, true
)->setIcon( embed::getIconPixmap( "analysis" ) );
m_tabBar->addTab( other, tr( "Don't know" ),
4, TRUE, TRUE
m_tabBar->addTab( other, tr( "Don't know" ),
4, true, true
)->setIcon( embed::getIconPixmap( "uhoh" ) );
m_tabBar->setActiveTab( 0 );
@@ -186,7 +185,7 @@ lv2BrowserView::lv2BrowserView( tool * _tool ) :
parentWidget()->hide();
parentWidget()->layout()->setSizeConstraint(
QLayout::SetFixedSize );
Qt::WindowFlags flags = parentWidget()->windowFlags();
flags |= Qt::MSWindowsFixedSizeDialogHint;
flags &= ~Qt::WindowMaximizeButtonHint;
@@ -216,7 +215,7 @@ QWidget * lv2BrowserView::createTab( QWidget * _parent, const QString & _txt,
const QString type = "<b>" + tr( "Type:" ) + "</b> ";
QLabel * title = new QLabel( type + _txt, tab );
QFont f = title->font();
f.setBold( TRUE );
f.setBold( true );
title->setFont( pointSize<12>( f ) );
layout->addSpacing( 5 );
@@ -225,16 +224,18 @@ QWidget * lv2BrowserView::createTab( QWidget * _parent, const QString & _txt,
lv2Description * description = new lv2Description( tab, _type );
// Double-clicking on a row gives us a pop-up
// Double-clicking on a row gives us a pop-up
connect( description, SIGNAL( doubleClicked( const lv2_key_t & ) ),
SLOT( showPorts( const lv2_key_t & ) ) );
layout->addWidget( description, 1 );
layout->addWidget( description, 1 );
return( tab );
return tab;
}
void lv2BrowserView::showPorts( const lv2_key_t & _key )
{
lv2PortDialog ports( _key );
@@ -243,3 +244,4 @@ void lv2BrowserView::showPorts( const lv2_key_t & _key )
#include "moc_lv2_browser.cxx"

View File

@@ -1,9 +1,8 @@
/*
* ladspa_browser.h - dialog to display information about installed LADSPA
* plugins
* lv2_browser.h - dialog to display information about installed LV2 plugins
*
* Copyright (c) 2009 Martin Andrews <mdda/at/users.sourceforge.net>
*
* Copyright (c) 2009-2009 Martin Andrews <mdda/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
@@ -64,7 +63,7 @@ public:
virtual pluginView * instantiateView( QWidget * )
{
return( new lv2BrowserView( this ) );
return new lv2BrowserView( this );
}
virtual QString nodeName( void ) const;

View File

@@ -1,7 +1,7 @@
/*
* lv2_description.cpp - LV2 plugin description
*
* Copyright (c) 2007 Javier Serrano Polo <jasp00/at/users.sourceforge.net>
* Copyright (c) 2009 Martin Andrews <mdda/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -35,7 +35,6 @@
#include "audio_device.h"
#include "engine.h"
// #include "ladspa_2_lmms.h"
#include "mixer.h"
@@ -45,9 +44,8 @@ lv2Description::lv2Description( QWidget * _parent,
lv2PluginType _type ) :
QWidget( _parent )
{
// ladspa2LMMS * manager = engine::getLADSPAManager();
lv2Manager * manager = static_lv2_manager;
/*
lv2Manager * manager = static_lv2_manager;
/*
switch( _type )
{
case SOURCE:
@@ -74,7 +72,7 @@ lv2Description::lv2Description( QWidget * _parent,
*/
// Simpler : Get all the plugins, and select based on the type...
l_sortable_plugin_t plugins = manager->getSortedPlugins();
QList<QString> pluginNames;
for( l_sortable_plugin_t::iterator it = plugins.begin();
it != plugins.end(); it++ )
@@ -82,11 +80,11 @@ lv2Description::lv2Description( QWidget * _parent,
lv2ManagerDescription * description=manager->getDescription( ( *it ).second );
if( description->type == _type &&
(
_type != VALID ||
description->inputChannels <= engine::getMixer()->audioDev()->channels()
_type != VALID ||
description->inputChannels <= engine::getMixer()->audioDev()->channels()
)
)
{
{
pluginNames.push_back( ( *it ).first );
m_pluginKeys.push_back( ( *it ).second );
}
@@ -139,8 +137,7 @@ void lv2Description::update( const lv2_key_t & _key )
QVBoxLayout * layout = new QVBoxLayout( description );
layout->setSizeConstraint( QLayout::SetFixedSize );
// ladspa2LMMS * manager = engine::getLADSPAManager();
lv2Manager * manager = static_lv2_manager;
lv2Manager * manager = static_lv2_manager;
QLabel * name = new QLabel( description );
name->setText( QWidget::tr( "Name: " ) + manager->getName( _key ) );
@@ -157,7 +154,7 @@ void lv2Description::update( const lv2_key_t & _key )
maker_label->setAlignment( Qt::AlignTop );
QLabel * maker_content = new QLabel( maker );
maker_content->setText( manager->getMaker( _key ) );
maker_content->setWordWrap( TRUE );
maker_content->setWordWrap( true );
makerLayout->addWidget( maker_label );
makerLayout->addWidget( maker_content, 1 );
@@ -174,7 +171,7 @@ void lv2Description::update( const lv2_key_t & _key )
QLabel * copyright_content = new QLabel( copyright );
copyright_content->setText( manager->getCopyright( _key ) );
copyright_content->setWordWrap( TRUE );
copyright_content->setWordWrap( true );
copyrightLayout->addWidget( copyright_label );
copyrightLayout->addWidget( copyright_content, 1 );
@@ -225,7 +222,7 @@ void lv2Description::rowChanged( int _pluginIndex )
void lv2Description::onDoubleClicked( QListWidgetItem * _item )
{
emit( doubleClicked( m_currentSelection ) );
emit doubleClicked( m_currentSelection );
}

View File

@@ -1,7 +1,7 @@
/*
* lv2_description.h - LV2 plugin description Pane of Information
*
* Copyright (c) 2009-2009 Martin Andrews <mdda/at/users.sourceforge.net>
* Copyright (c) 2009 Martin Andrews <mdda/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*

View File

@@ -1,8 +1,8 @@
/*
* lv2_port_dialog.cpp - dialog to test an LV2 plugin
*
* Copyright (c) 2009-2009 Martin Andrews <mdda/at/users.sourceforge.net>
*
* Copyright (c) 2009 Martin Andrews <mdda/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
@@ -30,18 +30,16 @@
#include "embed.h"
#include "engine.h"
// #include "ladspa_2_lmms.h"
#include "mixer.h"
lv2PortDialog::lv2PortDialog( const lv2_key_t & _key )
{
// ladspa2LMMS * manager = engine::getLADSPAManager();
lv2Manager * manager = static_lv2_manager;
lv2Manager * manager = static_lv2_manager;
setWindowIcon( embed::getIconPixmap( "ports" ) );
setWindowTitle( tr( "Ports" ) );
setModal( TRUE );
setModal( true );
QVBoxLayout * vlayout = new QVBoxLayout( this );
vlayout->setSpacing( 0 );
@@ -59,7 +57,7 @@ lv2PortDialog::lv2PortDialog( const lv2_key_t & _key )
// ports.append( tr( "SR Dependent" ) );
QTableWidget * settings = new QTableWidget( pc, ports.size(), this );
settings->setHorizontalHeaderLabels( ports );
settings->setHorizontalHeaderLabels( ports );
for( Uint16 row = 0; row < pc; row++ )
{
@@ -82,25 +80,25 @@ lv2PortDialog::lv2PortDialog( const lv2_key_t & _key )
manager->isPortInput( _key, row ) ?
tr( "Input" ) : tr( "Output" ) );
QStringList values;
if( manager->isInteger( _key, row ) )
{
values = manager->listEnumeration( _key, row );
settings->item( row, col )->setText( values.join("|") );
}
else
{
settings->item( row, col )->setText( tr( "Float" ) );
}
col++;
QStringList values;
if( manager->isInteger( _key, row ) )
{
values = manager->listEnumeration( _key, row );
settings->item( row, col )->setText( values.join("|") );
}
else
{
settings->item( row, col )->setText( tr( "Float" ) );
}
col++;
/*
settings->item( row, col++ )->setText(
manager->isPortToggled( _key, row ) ? tr( "Toggled" ) :
manager->isInteger( _key, row ) ? tr( "Integer" ) :
tr( "Float" ) );
*/
float min = manager->getLowerBound( _key, row );
float max = manager->getUpperBound( _key, row );
float def = manager->getDefaultSetting( _key, row );
@@ -126,7 +124,7 @@ lv2PortDialog::lv2PortDialog( const lv2_key_t & _key )
}
else if( values.size() >0 )
{
// Don't have a minimum
// Don't have a minimum
// range += QString::number( static_cast<int>( min ) ) + " < ";
}
else
@@ -163,7 +161,7 @@ lv2PortDialog::lv2PortDialog( const lv2_key_t & _key )
{
range += QString::number( max );
}
settings->item( row, col++ )->setText( range );
/*

View File

@@ -1,8 +1,8 @@
/*
* lv2_port_dialog.h - dialog to test an LV2 plugin
*
* Copyright (c) 2009-2009 Martin Andrews <mdda/at/users.sourceforge.net>
*
* Copyright (c) 2009 Martin Andrews <mdda/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

View File

@@ -1,11 +1,11 @@
/*
* lv2_2_lmms.cpp - class that identifies and instantiates LV2 effects
* for use with LMMS
* for use with LMMS
*
* Copyright (c) 2009-2009 Martin Andrews <mdda@sourceforge.net>
* Copyright (c) 2009 Martin Andrews <mdda@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
@@ -30,16 +30,16 @@
lv22LMMS::lv22LMMS( void )
{
l_sortable_plugin_t plugins = getSortedPlugins();
for( l_sortable_plugin_t::iterator it = plugins.begin();
it != plugins.end(); it++ )
{
lv2_key_t key = (*it).second;
lv2ManagerDescription * desc = getDescription( key );
if( desc->type == SOURCE )
{
m_instruments.append( qMakePair( getName( key ),
m_instruments.append( qMakePair( getName( key ),
key ) );
}
else if( desc->type == TRANSFER &&
@@ -57,7 +57,7 @@ lv22LMMS::lv22LMMS( void )
desc->inputChannels != 2 &&
desc->inputChannels != 4 ) ) )
{
m_invalidEffects.append( qMakePair( getName( key ),
m_invalidEffects.append( qMakePair( getName( key ),
key ) );
}
else if( desc->type == SINK )
@@ -67,25 +67,26 @@ lv22LMMS::lv22LMMS( void )
}
else if( desc->type == OTHER )
{
m_otherPlugins.append( qMakePair( getName( key ),
m_otherPlugins.append( qMakePair( getName( key ),
key ) );
}
}
}
lv22LMMS::~lv22LMMS()
{
}
QString lv22LMMS::getShortName( const lv2_key_t & _key )
{
QString name = getName( _key );
if( name.indexOf( "(" ) > 0 )
{
name = name.left( name.indexOf( "(" ) );
@@ -120,7 +121,7 @@ QString lv22LMMS::getShortName( const lv2_key_t & _key )
{
name = "LV2 Plugin";
}
return( name );
return name;
}

File diff suppressed because it is too large Load Diff