diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 6f315b792..01aa7868b 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -25,5 +25,6 @@ ADD_SUBDIRECTORY(triple_oscillator) ADD_SUBDIRECTORY(vestige) ADD_SUBDIRECTORY(vst_base) ADD_SUBDIRECTORY(vst_effect) +ADD_SUBDIRECTORY(waveshaper) ADD_SUBDIRECTORY(vibed) ADD_SUBDIRECTORY(zynaddsubfx) diff --git a/plugins/waveshaper/CMakeLists.txt b/plugins/waveshaper/CMakeLists.txt new file mode 100644 index 000000000..f4b4bc952 --- /dev/null +++ b/plugins/waveshaper/CMakeLists.txt @@ -0,0 +1,3 @@ +INCLUDE(BuildPlugin) + +BUILD_PLUGIN(waveshaper waveshaper.cpp waveshaper_controls.cpp waveshaper_control_dialog.cpp MOCFILES waveshaper_controls.h EMBEDDED_RESOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.png") diff --git a/plugins/waveshaper/artwork.png b/plugins/waveshaper/artwork.png new file mode 100644 index 000000000..23e2be7b3 Binary files /dev/null and b/plugins/waveshaper/artwork.png differ diff --git a/plugins/waveshaper/logo.png b/plugins/waveshaper/logo.png new file mode 100644 index 000000000..89e9f3680 Binary files /dev/null and b/plugins/waveshaper/logo.png differ diff --git a/plugins/waveshaper/waveshaper.cpp b/plugins/waveshaper/waveshaper.cpp new file mode 100644 index 000000000..9ac55de81 --- /dev/null +++ b/plugins/waveshaper/waveshaper.cpp @@ -0,0 +1,114 @@ +/* + * bass_booster.cpp - bass-booster-effect-plugin + * + * * Copyright * (c) 2006-2008 Vesa Kivimäki + * Copyright (c) 2006-2009 Tobias Doerffel + * + * 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" + +#include "embed.cpp" + + +extern "C" +{ + +Plugin::Descriptor PLUGIN_EXPORT waveshaper_plugin_descriptor = +{ + STRINGIFY( PLUGIN_NAME ), + "BassBooster Effect", + QT_TRANSLATE_NOOP( "pluginBrowser", + "plugin for boosting bass" ), + "Tobias Doerffel ", + 0x0100, + Plugin::Effect, + new PluginPixmapLoader( "logo" ), + NULL, + NULL +} ; + +} + + + +bassBoosterEffect::bassBoosterEffect( Model * _parent, + const Descriptor::SubPluginFeatures::Key * _key ) : + Effect( &waveshaper_plugin_descriptor, _parent, _key ), + m_bbFX( effectLib::fastBassBoost( 70.0f, 1.0f, 2.8f ) ), + m_bbControls( this ) +{ +} + + + + +bassBoosterEffect::~bassBoosterEffect() +{ +} + + + + +bool bassBoosterEffect::processAudioBuffer( sampleFrame * _buf, + const fpp_t _frames ) +{ + if( !isEnabled() || !isRunning () ) + { + return( false ); + } + + double out_sum = 0.0; + const float d = dryLevel(); + const float w = wetLevel(); + for( fpp_t f = 0; f < _frames; ++f ) + { + sample_t s[2] = { _buf[f][0], _buf[f][1] }; + m_bbFX.nextSample( s[0], s[1] ); + + _buf[f][0] = d * _buf[f][0] + w * s[0]; + _buf[f][1] = d * _buf[f][1] + w * s[1]; + + out_sum += _buf[f][0]*_buf[f][0] + _buf[f][1]*_buf[f][1]; + } + + checkGate( out_sum / _frames ); + + return( isRunning() ); +} + + + + + +extern "C" +{ + +// necessary for getting instance out of shared lib +Plugin * PLUGIN_EXPORT lmms_plugin_main( Model * _parent, void * _data ) +{ + return( new bassBoosterEffect( _parent, + static_cast( + _data ) ) ); +} + +} + diff --git a/plugins/waveshaper/waveshaper.h b/plugins/waveshaper/waveshaper.h new file mode 100644 index 000000000..90d8f2a55 --- /dev/null +++ b/plugins/waveshaper/waveshaper.h @@ -0,0 +1,64 @@ +/* + * bass_booster.h - bass-booster-effect-plugin + * + * * Copyright * (c) 2006-2008 Vesa Kivimäki + * Copyright (c) 2006-2008 Tobias Doerffel + * + * 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 "waveshaper_controls.h" + + + +class bassBoosterEffect : public Effect +{ +public: + bassBoosterEffect( Model * _parent, + const Descriptor::SubPluginFeatures::Key * _key ); + virtual ~bassBoosterEffect(); + virtual bool processAudioBuffer( sampleFrame * _buf, + const fpp_t _frames ); + + virtual EffectControls * controls() + { + return( &m_bbControls ); + } + + +private: + effectLib::monoToStereoAdaptor m_bbFX; + + bassBoosterControls m_bbControls; + + friend class bassBoosterControls; + +} ; + + + + + +#endif diff --git a/plugins/waveshaper/waveshaper_control_dialog.cpp b/plugins/waveshaper/waveshaper_control_dialog.cpp new file mode 100644 index 000000000..d7b16b232 --- /dev/null +++ b/plugins/waveshaper/waveshaper_control_dialog.cpp @@ -0,0 +1,74 @@ +/* + * waveshaper_control_dialog.cpp - control-dialog for waveshaper-effect + * + * Copyright * (c) 2006-2008 Vesa Kivimäki + * Copyright * (c) 2006-2008 Tobias Doerffel + * + * 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 + +#include "waveshaper_control_dialog.h" +#include "waveshaper_controls.h" +#include "embed.h" + + + +bassBoosterControlDialog::bassBoosterControlDialog( + bassBoosterControls * _controls ) : + EffectControlDialog( _controls ) +{ + setAutoFillBackground( true ); + QPalette pal; + pal.setBrush( backgroundRole(), + PLUGIN_NAME::getIconPixmap( "artwork" ) ); + setPalette( pal ); + setFixedSize( 120, 104 ); + + QVBoxLayout * tl = new QVBoxLayout( this ); + tl->addSpacing( 30 ); + + QHBoxLayout * l = new QHBoxLayout; + + knob * freqKnob = new knob( knobBright_26, this); + freqKnob->setModel( &_controls->m_freqModel ); + freqKnob->setLabel( tr( "FREQ" ) ); + freqKnob->setHintText( tr( "Frequency:" ) + " ", "Hz" ); + + knob * gainKnob = new knob( knobBright_26, this ); + gainKnob->setModel( &_controls->m_gainModel ); + gainKnob->setLabel( tr( "GAIN" ) ); + gainKnob->setHintText( tr( "Gain:" ) + " ", "" ); + + knob * ratioKnob = new knob( knobBright_26, this ); + ratioKnob->setModel( &_controls->m_ratioModel ); + ratioKnob->setLabel( tr( "RATIO" ) ); + ratioKnob->setHintText( tr( "Ratio:" ) + " ", "" ); + + l->addWidget( freqKnob ); + l->addWidget( gainKnob ); + l->addWidget( ratioKnob ); + + tl->addLayout( l ); + setLayout( tl ); +} + + diff --git a/plugins/waveshaper/waveshaper_control_dialog.h b/plugins/waveshaper/waveshaper_control_dialog.h new file mode 100644 index 000000000..fe11fd5e0 --- /dev/null +++ b/plugins/waveshaper/waveshaper_control_dialog.h @@ -0,0 +1,45 @@ +/* + * waveshaper_control_dialog.h - control-dialog for waveshaper-effect + * + * * Copyright * (c) 2006-2008 Vesa Kivimäki + * Copyright (c) 2006-2008 Tobias Doerffel + * + * 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 _WAVESHAPER_CONTROL_DIALOG_H +#define _WAVESHAPER_CONTROL_DIALOG_H + +#include "EffectControlDialog.h" + + +class bassBoosterControls; + + +class bassBoosterControlDialog : public EffectControlDialog +{ +public: + bassBoosterControlDialog( bassBoosterControls * _controls ); + virtual ~bassBoosterControlDialog() + { + } + +} ; + +#endif diff --git a/plugins/waveshaper/waveshaper_controls.cpp b/plugins/waveshaper/waveshaper_controls.cpp new file mode 100644 index 000000000..c675ea044 --- /dev/null +++ b/plugins/waveshaper/waveshaper_controls.cpp @@ -0,0 +1,110 @@ +/* + * waveshaper_controls.cpp - controls for waveshaper-effect + * + * Copyright * (c) 2006-2008 Vesa Kivimäki + * Copyright (c) 2008 Tobias Doerffel + * + * 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 + +#include "waveshaper_controls.h" +#include "bass_booster.h" + + + +bassBoosterControls::bassBoosterControls( bassBoosterEffect * _eff ) : + EffectControls( _eff ), + m_effect( _eff ), + m_freqModel( 100.0f, 50.0f, 200.0f, 1.0f, this, tr( "Frequency" ) ), + m_gainModel( 1.0f, 0.1f, 5.0f, 0.05f, this, tr( "Gain" ) ), + m_ratioModel( 2.0f, 0.1f, 10.0f, 0.1f, this, tr( "Ratio" ) ) +{ + connect( &m_freqModel, SIGNAL( dataChanged() ), + this, SLOT( changeFrequency() ) ); + + connect( &m_gainModel, SIGNAL( dataChanged() ), + this, SLOT( changeGain() ) ); + + connect( &m_ratioModel, SIGNAL( dataChanged() ), + this, SLOT( changeRatio() ) ); + + connect( engine::mixer(), SIGNAL( sampleRateChanged() ), + this, SLOT( changeFrequency() ) ); + changeFrequency(); + changeGain(); + changeRatio(); +} + + + + +void bassBoosterControls::changeFrequency() +{ + const sample_t fac = engine::mixer()->processingSampleRate() / + 44100.0f; + m_effect->m_bbFX.leftFX().setFrequency( m_freqModel.value() * fac ); + m_effect->m_bbFX.rightFX().setFrequency( m_freqModel.value() * fac ); +} + + + + +void bassBoosterControls::changeGain() +{ + m_effect->m_bbFX.leftFX().setGain( m_gainModel.value() ); + m_effect->m_bbFX.rightFX().setGain( m_gainModel.value() ); +} + + + + +void bassBoosterControls::changeRatio() +{ + m_effect->m_bbFX.leftFX().setRatio( m_ratioModel.value() ); + m_effect->m_bbFX.rightFX().setRatio( m_ratioModel.value() ); +} + + + + +void bassBoosterControls::loadSettings( const QDomElement & _this ) +{ + m_freqModel.setValue( _this.attribute( "freq" ).toFloat() ); + m_gainModel.setValue( _this.attribute( "gain" ).toFloat() ); + m_ratioModel.setValue( _this.attribute( "ratio" ).toFloat() ); +} + + + + +void bassBoosterControls::saveSettings( QDomDocument & _doc, + QDomElement & _this ) +{ + _this.setAttribute( "freq", m_freqModel.value() ); + _this.setAttribute( "gain", m_gainModel.value() ); + _this.setAttribute( "ratio", m_ratioModel.value() ); +} + + + +#include "moc_waveshaper_controls.cxx" + diff --git a/plugins/waveshaper/waveshaper_controls.h b/plugins/waveshaper/waveshaper_controls.h new file mode 100644 index 000000000..f8b818939 --- /dev/null +++ b/plugins/waveshaper/waveshaper_controls.h @@ -0,0 +1,80 @@ +/* + * waveshaper_controls.h - controls for waveshaper-effect + * + * Copyright * (c) 2006-2008 Vesa Kivimäki + * Copyright (c) 2008 Tobias Doerffel + * + * 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 _WAVESHAPER_CONTROLS_H +#define _WAVESHAPER_CONTROLS_H + +#include "EffectControls.h" +#include "waveshaper_control_dialog.h" +#include "knob.h" + + +class bassBoosterEffect; + + +class bassBoosterControls : public EffectControls +{ + Q_OBJECT +public: + bassBoosterControls( bassBoosterEffect * _eff ); + virtual ~bassBoosterControls() + { + } + + virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent ); + virtual void loadSettings( const QDomElement & _this ); + inline virtual QString nodeName() const + { + return( "waveshapercontrols" ); + } + + virtual int controlCount() + { + return( 3 ); + } + + virtual EffectControlDialog * createView() + { + return( new bassBoosterControlDialog( this ) ); + } + + +private slots: + void changeFrequency(); + void changeGain(); + void changeRatio(); + + +private: + bassBoosterEffect * m_effect; + FloatModel m_freqModel; + FloatModel m_gainModel; + FloatModel m_ratioModel; + + friend class bassBoosterControlDialog; + +} ; + +#endif