added bassbooster-effect and effect-lib

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@439 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Tobias Doerffel
2006-12-18 00:29:17 +00:00
parent c6aa917e9c
commit 64aa78c4f6
13 changed files with 644 additions and 10 deletions

View File

@@ -1,3 +1,22 @@
2006-12-17 Tobias Doerffel <tobydox/at/users/dot/sourceforge/dot/net>
* plugins/bass_booster/bassboster_control_dialog.cpp:
* plugins/bass_booster/bassboster_control_dialog.h:
* plugins/bass_booster/bass_boster.h:
* plugins/bass_booster/bass_boster.cpp:
* plugins/bass_booster/Makefile.am:
* plugins/Makefile.am:
* configure.in:
added bassbooster-effect-plugin
* src/core/effect_select_dialog.cpp:
added support for effects without sub-plugin-support and fixed some
potential crashs
* include/effect_lib.h:
added simple but powerful template-based effect-library with currently
two basic effects
2006-12-11 Javier Serrano Polo <jasp00/at/terra/dot/es>
* include/sample_buffer.h:

3
TODO
View File

@@ -1,4 +1,5 @@
- MIDI over Ethernet-support
- select number of channels in export-project-dialog
- MIDI over Ethernet support
- lock m_instrument in instrumentTrack-class for not crashing when using m_instrument in notePlayHandle::supportsParallelizing() while instrument is being deleted or so
- try to make vestige-plugin-dlls relative
- do song-editor-tempo-connection to vst-plugin inside remoteVSTPlugin

View File

@@ -2,8 +2,8 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.50)
AC_INIT(lmms, 0.2.1-svn20061211, lmms-devel/at/lists/dot/sf/dot/net)
AM_INIT_AUTOMAKE(lmms, 0.2.1-svn20061211)
AC_INIT(lmms, 0.2.1-svn20061217, lmms-devel/at/lists/dot/sf/dot/net)
AM_INIT_AUTOMAKE(lmms, 0.2.1-svn20061217)
AM_CONFIG_HEADER(config.h)
@@ -554,6 +554,7 @@ AC_CONFIG_FILES([Makefile
data/track_icons/Makefile
plugins/Makefile
plugins/audio_file_processor/Makefile
plugins/bass_booster/Makefile
plugins/bit_invader/Makefile
plugins/flp_import/Makefile
plugins/ladspa_base/Makefile

165
include/effect_lib.h Normal file
View File

@@ -0,0 +1,165 @@
/*
* effect_lib.h - library with simple inline-effects
*
* 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_LIB_H
#define _EFFECT_LIB_H
#include "templates.h"
#include "types.h"
namespace effectLib
{
template<typename SAMPLE = sample_t>
class base
{
public:
typedef SAMPLE sampleType;
virtual ~base()
{
}
virtual SAMPLE nextSample( const SAMPLE _in ) const = 0;
} ;
template<typename SAMPLE = sample_t>
class stereoBase
{
public:
virtual ~stereoBase()
{
}
typedef SAMPLE sampleType;
virtual void nextSample( SAMPLE & _in_left,
SAMPLE & _in_right ) const = 0;
} ;
template<class FX>
class monoToStereoAdaptor : public stereoBase<typename FX::sampleType>
{
public:
typedef typename FX::sampleType sampleType;
monoToStereoAdaptor( const FX & _mono_fx ) :
m_leftFX( _mono_fx ),
m_rightFX( _mono_fx )
{
}
virtual void nextSample( sampleType & _in_left,
sampleType & _in_right ) const
{
_in_left = m_leftFX.nextSample( _in_left );
_in_right = m_rightFX.nextSample( _in_right );
}
private:
FX m_leftFX;
FX m_rightFX;
} ;
template<typename SAMPLE>
inline SAMPLE saturate( const SAMPLE _x )
{
return( tMin<SAMPLE>( tMax<SAMPLE>( -1.0f, _x ), 1.0f ) );
}
template<typename SAMPLE = sample_t>
class bassBoost : public base<SAMPLE>
{
public:
bassBoost( const float _selectivity,
const float _gain,
const float _ratio ) :
m_selectivity( _selectivity ),
m_gain1( 1.0f / ( m_selectivity + 1.0f ) ),
m_gain2( _gain ),
m_ratio( _ratio ),
m_cap( 0.0f )
{
}
virtual ~bassBoost()
{
}
virtual SAMPLE nextSample( const SAMPLE _in ) const
{
m_cap = ( _in + m_cap*m_selectivity ) * m_gain1;
return( /*saturate<SAMPLE>(*/ ( _in + m_cap*m_ratio ) *
m_gain2/* )*/ );
}
/* void setSelectivity( const float _selectivity )
{
m_selectivity = _selectivity;
m_gain1 = 1.0f / ( m_selectivity + 1.0f );
}
void setGain( const float _gain )
{
m_gain2 = _gain;
}
void setRatio( const float _ratio )
{
m_ratio = _ratio;
}*/
private:
float m_selectivity;
float m_gain1;
float m_gain2;
float m_ratio;
mutable float m_cap;
} ;
template<typename SAMPLE = sample_t>
class stereoEnhancer : public stereoBase<SAMPLE>
{
public:
stereoEnhancer( const float _wide_coeff ) :
m_wideCoeff( _wide_coeff )
{
}
virtual void nextSample( SAMPLE & _in_left,
SAMPLE & _in_right ) const
{
const float delta = ( _in_left -
( _in_left+_in_right ) / 2.0f ) * m_wideCoeff;
_in_left += delta;
_in_right -= delta;
}
private:
const float m_wideCoeff;
} ;
} ;
#endif

View File

@@ -10,5 +10,5 @@ if STK_SUPPORT
STK_DIR=stk
endif
SUBDIRS = audio_file_processor bit_invader flp_import $(LADSPA_DIRS) midi_import organic plucked_string_synth $(STK_DIR) triple_oscillator $(VST_DIRS) vibed
SUBDIRS = audio_file_processor bass_booster bit_invader flp_import $(LADSPA_DIRS) midi_import organic plucked_string_synth $(STK_DIR) triple_oscillator $(VST_DIRS) vibed

View File

@@ -0,0 +1,36 @@
AUTOMAKE_OPTIONS = foreign 1.4
INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/src/lib
AM_CXXFLAGS := $(AM_CXXFLAGS) $(QT_CXXFLAGS) -DPLUGIN_NAME="bassbooster"
%.moc: ./%.h
$(MOC) -o $@ $<
MOC_FILES = ./bassbooster_control_dialog.moc
BUILT_SOURCES = $(MOC_FILES) ./embedded_resources.h
EMBEDDED_RESOURCES = $(wildcard *png)
./embedded_resources.h: $(EMBEDDED_RESOURCES)
$(BIN2RES) $(EMBEDDED_RESOURCES) > $@
EXTRA_DIST = $(EMBEDDED_RESOURCES)
CLEANFILES = $(MOC_FILES) ./embedded_resources.h
pkglib_LTLIBRARIES= libbassbooster.la
libbassbooster_la_SOURCES = bass_booster.cpp \
bass_booster.h \
bassbooster_control_dialog.cpp \
bassbooster_control_dialog.h
$(libbassbooster_la_SOURCES): ./embedded_resources.h

View File

@@ -0,0 +1,123 @@
/*
* bass_booster.cpp - bass-booster-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.
*
*/
#include "bass_booster.h"
#undef SINGLE_SOURCE_COMPILE
#include "embed.cpp"
extern "C"
{
plugin::descriptor bassbooster_plugin_descriptor =
{
STRINGIFY_PLUGIN_NAME( PLUGIN_NAME ),
"BassBooster Effect",
QT_TRANSLATE_NOOP( "pluginBrowser",
"plugin for using arbitrary VST-effects "
"inside LMMS." ),
"Tobias Doerffel <tobydox/at/users.sf.net>",
0x0100,
plugin::Effect,
new QPixmap( PLUGIN_NAME::getIconPixmap( "logo" ) ),
NULL
} ;
}
bassBoosterEffect::bassBoosterEffect( effect::constructionData * _cdata ) :
effect( &bassbooster_plugin_descriptor, _cdata ),
m_bbFX( effectLib::bassBoost<>( 70.0f, 1.0f, 2.8f ) )
{
}
bassBoosterEffect::~bassBoosterEffect()
{
}
bool FASTCALL bassBoosterEffect::processAudioBuffer( surroundSampleFrame * _buf,
const fpab_t _frames )
{
if( isBypassed() || !isRunning () )
{
return( FALSE );
}
double out_sum = 0.0;
for( fpab_t f = 0; f < _frames; ++f )
{
sample_t s[2] = { _buf[f][0], _buf[f][1] };
m_bbFX.nextSample( s[0], s[1] );
for( ch_cnt_t ch = 0; ch < SURROUND_CHANNELS; ++ch )
{
_buf[f][ch] = getDryLevel() * _buf[f][ch] +
getWetLevel() *
s[ch%DEFAULT_CHANNELS];
out_sum += _buf[f][ch]*_buf[f][ch];
}
}
if( out_sum <= getGate() )
{
incrementBufferCount();
if( getBufferCount() > getTimeout() )
{
stopRunning();
resetBufferCount();
}
}
else
{
resetBufferCount();
}
return( isRunning() );
}
extern "C"
{
// neccessary for getting instance out of shared lib
plugin * lmms_plugin_main( void * _data )
{
return( new bassBoosterEffect(
static_cast<effect::constructionData *>( _data ) ) );
}
}

View File

@@ -0,0 +1,67 @@
/*
* bass_booster.h - bass-booster-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 _BASS_BOOSTER_H
#define _BASS_BOOSTER_H
#include "effect.h"
#include "effect_lib.h"
#include "main_window.h"
#include "bassbooster_control_dialog.h"
class bassBoosterEffect : public effect
{
public:
bassBoosterEffect( effect::constructionData * _cdata );
virtual ~bassBoosterEffect();
virtual bool FASTCALL processAudioBuffer( surroundSampleFrame * _buf,
const fpab_t _frames );
inline virtual QString nodeName( void ) const
{
return( "bassboostereffect" );
}
virtual inline effectControlDialog * createControlDialog( track * )
{
return( new bassBoosterControlDialog(
eng()->getMainWindow()->workspace(),
this ) );
}
private:
effectLib::monoToStereoAdaptor<effectLib::bassBoost<> > m_bbFX;
friend class bassBoosterControlDialog;
} ;
#endif

View File

@@ -0,0 +1,140 @@
/*
* bassbooster_control_dialog.cpp - control-dialog for bassbooster-effect
*
* 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.
*
*/
#ifdef QT4
#include <QtGui/QLayout>
#else
#include <qlayout.h>
#endif
#include "bass_booster.h"
#include "knob.h"
bassBoosterControlDialog::bassBoosterControlDialog( QWidget * _parent,
bassBoosterEffect * _eff ) :
effectControlDialog( _parent, _eff ),
m_effect( _eff )
{
QHBoxLayout * l = new QHBoxLayout( this );
m_freqKnob = new knob( knobBright_26, this, tr( "Frequency" ),
eng(), NULL );
m_freqKnob->setRange( 50.0f, 200.0f, 1.0f );
m_freqKnob->setInitValue( 100.0f );
m_freqKnob->setLabel( tr( "FREQ" ) );
m_freqKnob->setHintText( tr( "Frequency:" ) + " ", "Hz" );
connect( m_freqKnob, SIGNAL( valueChanged( float ) ),
this, SLOT( changeFrequency( float ) ) );
m_gainKnob = new knob( knobBright_26, this, tr( "Gain" ), eng(), NULL );
m_gainKnob->setRange( 0.1f, 5.0f, 0.1f );
m_gainKnob->setInitValue( 1.0f );
m_gainKnob->setLabel( tr( "GAIN" ) );
m_gainKnob->setHintText( tr( "Gain:" ) + " ", "" );
connect( m_gainKnob, SIGNAL( valueChanged( float ) ),
this, SLOT( changeGain( float ) ) );
m_ratioKnob = new knob( knobBright_26, this, tr( "Ratio" ), eng(),
NULL );
m_ratioKnob->setRange( 0.1f, 10.0f, 0.1f );
m_ratioKnob->setInitValue( 2.0f );
m_ratioKnob->setLabel( tr( "RATIO" ) );
m_ratioKnob->setHintText( tr( "Ratio:" ) + " ", "" );
connect( m_ratioKnob, SIGNAL( valueChanged( float ) ),
this, SLOT( changeRatio( float ) ) );
l->addWidget( m_freqKnob );
l->addWidget( m_gainKnob );
l->addWidget( m_ratioKnob );
updateEffect();
}
void bassBoosterControlDialog::changeFrequency( float )
{
updateEffect();
}
void bassBoosterControlDialog::changeGain( float )
{
updateEffect();
}
void bassBoosterControlDialog::changeRatio( float )
{
updateEffect();
}
void bassBoosterControlDialog::updateEffect( void )
{
// TODO: try to preserve effect and just change params
m_effect->m_bbFX = effectLib::bassBoost<>( m_freqKnob->value(),
m_gainKnob->value(), m_ratioKnob->value() );
}
void FASTCALL bassBoosterControlDialog::loadSettings(
const QDomElement & _this )
{
m_freqKnob->setValue( _this.attribute( "freq" ).toFloat() );
m_gainKnob->setValue( _this.attribute( "gain" ).toFloat() );
m_ratioKnob->setValue( _this.attribute( "ratio" ).toFloat() );
}
void FASTCALL bassBoosterControlDialog::saveSettings( QDomDocument & _doc,
QDomElement & _this )
{
_this.setAttribute( "freq", m_freqKnob->value() );
_this.setAttribute( "gain", m_gainKnob->value() );
_this.setAttribute( "ratio", m_ratioKnob->value() );
}
#include "bassbooster_control_dialog.moc"

View File

@@ -0,0 +1,73 @@
/*
* bassbooster_control_dialog.h - control-dialog for bassbooster-effect
*
* 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 _BASSBOOSTER_CONTROL_DIALOG_H
#define _BASSBOOSTER_CONTROL_DIALOG_H
#include "effect_control_dialog.h"
class knob;
class bassBoosterEffect;
class bassBoosterControlDialog : public effectControlDialog
{
Q_OBJECT
public:
bassBoosterControlDialog( QWidget * _parent, bassBoosterEffect * _eff );
virtual ~bassBoosterControlDialog()
{
}
virtual void FASTCALL saveSettings( QDomDocument & _doc,
QDomElement & _parent );
virtual void FASTCALL loadSettings( const QDomElement & _this );
inline virtual QString nodeName( void ) const
{
return( "bassboostercontrols" );
}
virtual ch_cnt_t getControlCount( void )
{
return( 3 );
}
private slots:
void changeFrequency( float );
void changeGain( float );
void changeRatio( float );
private:
void updateEffect( void );
bassBoosterEffect * m_effect;
knob * m_freqKnob;
knob * m_gainKnob;
knob * m_ratioKnob;
} ;
#endif

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@@ -192,7 +192,8 @@ effectList::effectList( QWidget * _parent, engine * _engine ) :
}
else
{
// TODO
m_effectKeys << effectKey( &( *it ), it->name );
}
}
@@ -200,8 +201,11 @@ effectList::effectList( QWidget * _parent, engine * _engine ) :
for( effectKeyList::const_iterator it = m_effectKeys.begin();
it != m_effectKeys.end(); ++it )
{
plugin_names += QString( ( *it ).desc->public_name ) + ": " +
( *it ).name;
plugin_names += QString( ( *it ).desc->public_name ) +
( ( ( *it ).desc->sub_plugin_features != NULL ) ?
": " + ( *it ).name
:
"" );
}
m_pluginList = new Q3ListBox( this );
@@ -239,6 +243,7 @@ void effectList::onHighlighted( int _pluginIndex )
{
m_currentSelection = m_effectKeys[_pluginIndex];
delete m_descriptionWidget;
m_descriptionWidget = NULL;
if( m_currentSelection.desc &&
m_currentSelection.desc->sub_plugin_features )
{
@@ -247,9 +252,13 @@ void effectList::onHighlighted( int _pluginIndex )
createDescriptionWidget( m_descriptionWidgetParent,
eng(), m_currentSelection );
}
dynamic_cast<QVBoxLayout *>( m_descriptionWidgetParent->layout() )->
if( m_descriptionWidget != NULL )
{
dynamic_cast<QVBoxLayout *>(
m_descriptionWidgetParent->layout() )->
addWidget( m_descriptionWidget );
m_descriptionWidget->show();
m_descriptionWidget->show();
}
emit( highlighted( m_currentSelection ) );
}

View File

@@ -243,7 +243,7 @@ rackPlugin::~rackPlugin()
void rackPlugin::editControls( void )
{
if( m_show)
if( m_show )
{
m_controlView->show();
m_controlView->raise();