From 6d2b91054bbf3365606ffaac1d3ba03406f289f4 Mon Sep 17 00:00:00 2001 From: dave Date: Sat, 15 Nov 2014 11:22:23 +0000 Subject: [PATCH] Tempo synced Delay Plugin --- data/locale/en.ts | 62 +++++++++++++- plugins/CMakeLists.txt | 1 + plugins/delay/CMakeLists.txt | 3 + plugins/delay/artwork.png | Bin 0 -> 1659 bytes plugins/delay/delaycontrols.cpp | 73 ++++++++++++++++ plugins/delay/delaycontrols.h | 72 ++++++++++++++++ plugins/delay/delaycontrolsdialog.cpp | 70 ++++++++++++++++ plugins/delay/delaycontrolsdialog.h | 41 +++++++++ plugins/delay/delayeffect.cpp | 115 ++++++++++++++++++++++++++ plugins/delay/delayeffect.h | 49 +++++++++++ plugins/delay/lfo.cpp | 79 ++++++++++++++++++ plugins/delay/lfo.h | 53 ++++++++++++ plugins/delay/logo.png | Bin 0 -> 3225 bytes plugins/delay/stereodelay.cpp | 100 ++++++++++++++++++++++ plugins/delay/stereodelay.h | 44 ++++++++++ 15 files changed, 760 insertions(+), 2 deletions(-) create mode 100644 plugins/delay/CMakeLists.txt create mode 100644 plugins/delay/artwork.png create mode 100644 plugins/delay/delaycontrols.cpp create mode 100644 plugins/delay/delaycontrols.h create mode 100644 plugins/delay/delaycontrolsdialog.cpp create mode 100644 plugins/delay/delaycontrolsdialog.h create mode 100644 plugins/delay/delayeffect.cpp create mode 100644 plugins/delay/delayeffect.h create mode 100644 plugins/delay/lfo.cpp create mode 100644 plugins/delay/lfo.h create mode 100644 plugins/delay/logo.png create mode 100644 plugins/delay/stereodelay.cpp create mode 100644 plugins/delay/stereodelay.h diff --git a/data/locale/en.ts b/data/locale/en.ts index b21db762d..736caf963 100644 --- a/data/locale/en.ts +++ b/data/locale/en.ts @@ -42,11 +42,11 @@ If you're interested in translating LMMS in another language or want to imp - <html><head/><body><p><a href="http://lmms.sourceforge.net"><span style=" text-decoration: underline; color:#0000ff;">http://lmms.sourceforge.net</span></a></p></body></html> + LMMS - LMMS + <html><head/><body><p><a href="http://lmms.io"><span style=" text-decoration: underline; color:#0000ff;">http://lmms.io</span></a></p></body></html> @@ -651,6 +651,60 @@ If you're interested in translating LMMS in another language or want to imp + + DelayControls + + Delay Samples + + + + Feedback + + + + Lfo Frequency + + + + Lfo Ammount + + + + + DelayControlsDialog + + Delay + + + + Delay Time Samples: + + + + Feedback + + + + Feedback Ammount: + + + + Lfo Hz + + + + Lfo Hz: + + + + Lfo Amt + + + + Lfo Amt: + + + DualFilterControlDialog @@ -7016,6 +7070,10 @@ This chip was used in the Commodore 64 computer. A NES-like synthesizer + + A native delay plugin + + projectNotes diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 8311c4fa6..1ba586768 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -5,6 +5,7 @@ ADD_SUBDIRECTORY(bit_invader) ADD_SUBDIRECTORY(carlabase) ADD_SUBDIRECTORY(carlapatchbay) ADD_SUBDIRECTORY(carlarack) +ADD_SUBDIRECTORY(delay) ADD_SUBDIRECTORY(DualFilter) ADD_SUBDIRECTORY(dynamics_processor) ADD_SUBDIRECTORY(flp_import) diff --git a/plugins/delay/CMakeLists.txt b/plugins/delay/CMakeLists.txt new file mode 100644 index 000000000..0663b9458 --- /dev/null +++ b/plugins/delay/CMakeLists.txt @@ -0,0 +1,3 @@ +INCLUDE(BuildPlugin) + +BUILD_PLUGIN(delay delayeffect.cpp delaycontrols.cpp delaycontrolsdialog.cpp lfo.cpp stereodelay.cpp MOCFILES delaycontrols.h EMBEDDED_RESOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.png") diff --git a/plugins/delay/artwork.png b/plugins/delay/artwork.png new file mode 100644 index 0000000000000000000000000000000000000000..19b18740f259cdc70e3c8933ec4e57132ee97788 GIT binary patch literal 1659 zcmbW2dpOez7{`BdS(#i$RBp{J2_>g;DavLhmze8zbXc}C$t=uejS&i+j*a8muwv~g zwd9(Uq*lt@Mx?0R*-?|SCRsS^obx>AIscwNKJWK=FVFit-}j$4$H&`kv+{Oj001_- zBjG5S;$)<3RFXx1$EP5fY&wHP#{mFX^E-0D<+81^B8cqny-$V%JD zuEAs&iAcmplL1&P9!tjKb|ju6N9=HO_workr>X-0iV}DDQU9co`La~cf_S}Wp-;;- z2Y^j>S_*@H_wafg)F6t#;&$S+RTs(wGw9jXWJy>v@1ecsa8Yq1-8Ak>RjG&TRmic0 zzTCk$N?{t|%7%;e{vXCyrY1kaxlPT~OJCj_HVG+9B8pRul;%9PQ2*(Jl7jk$M+ywv zZ=9|b)4-af-{j=??P^Zp;a3d`x6B-c_D|N+hw}3CJ)@%3E;E@oZhS)B=N5c%{+2mA zJDZx!ns_N(YeOI#w*C-tM4D0Ji6f|)Ia2rD)xK1DCqjwPTQ(Q#H?#$jl#Qj_-FsGK z_p_k%cuI)LW#?lo?C_1 zof*|T86LieB1jCfBvAQgdNZc?@2==8sdj7#8@M2dvG3Y?mb*C(ngN=KEvo(W%W>0b z7dwjtxxSjvvA$aB&e3*FTLaSa0ZT(}k)p4opYBx*z z1K|8&81zu`I6Y-2X?i1Ik+8Z0s*`*r`jMM*S^aj_p;Jb{c~`m(9-{$NxxG#1OS{YV zGc~@3HvrDKPSm`te?I&a*ykO z(=tuIf@L57E)j#l*vW+UroK3+*t#lWMRPg%!BYA1Nc^oI*EO+yuxPl2?(EHaDir&Mj-@>w9yLColjUJ?fWe49G9J55UL^f7 zY+EFPX24b>79Om6(mrBS9CEZtR@Cwks&~Y?c=q*f$(%{`o~Q$HOCt0;-RdBm~n zS^W@@U0!L2}4a9)biA^Dh1{`?FN-_`wVVf zfjL24hL4ORGWN=7z~6? + * + * This file is part of LMMS - http://lmms.io + * + * 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 "delaycontrols.h" +#include "delayeffect.h" +#include "engine.h" +#include "song.h" + +DelayControls::DelayControls(DelayEffect* effect): + EffectControls( effect ), + m_effect ( effect ), + m_delayTimeModel( 2.0, 0.01, 20.0, 0.0001, 20000.0, this, tr( "Delay Samples" )) , + m_feebackModel(0.0f,0.0f,1.0f,0.01f,this,tr( "Feedback" ) ), + m_lfoTimeModel(2.0, 0.01, 20.0, 0.0001, 20000.0, this, tr( "Lfo Frequency" ) ), + m_lfoAmmountModel(0.0f,0.0f,0.5f,0.01f, this, tr ( "Lfo Ammount" ) ) +{ + +} + + + + +void DelayControls::changeControl() +{ + //engine::getSong()->setModified(); +} + + + + +void DelayControls::loadSettings(const QDomElement &_this) +{ + m_delayTimeModel.loadSettings(_this, "DelayTimeSamples" ); + m_feebackModel.loadSettings( _this, "FeebackAmmount" ); + m_lfoTimeModel.loadSettings( _this , "LfoFrequency"); + m_lfoAmmountModel.loadSettings( _this, "LfoAmmount"); +} + + + + +void DelayControls::saveSettings(QDomDocument& doc, QDomElement& _this) +{ + m_delayTimeModel.saveSettings( doc, _this, "DelayTimeSamples"); + m_feebackModel.saveSettings( doc, _this ,"FeebackAmmount"); + m_lfoTimeModel.saveSettings( doc, _this, "LfoFrequency"); + m_lfoAmmountModel.saveSettings( doc, _this ,"LfoAmmount"); +} + +#include "moc_delaycontrols.cxx" diff --git a/plugins/delay/delaycontrols.h b/plugins/delay/delaycontrols.h new file mode 100644 index 000000000..4947bf93e --- /dev/null +++ b/plugins/delay/delaycontrols.h @@ -0,0 +1,72 @@ +/* + * delaycontrols.h - declaration of DelayControl class. + * + * Copyright (c) 2014 David French + * + * This file is part of LMMS - http://lmms.io + * + * 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 DELAYCONTROLS_H +#define DELAYCONTROLS_H + +#include "EffectControls.h" +#include "knob.h" +#include "delaycontrolsdialog.h" + + + +class DelayEffect; + +class DelayControls : public EffectControls +{ + Q_OBJECT +public: + DelayControls( DelayEffect* effect ); + virtual ~DelayControls() + { + } + virtual void saveSettings( QDomDocument& doc, QDomElement& parent ); + virtual void loadSettings( const QDomElement& _this ); + inline virtual QString nodeName() const + { + return "Delay"; + } + virtual int controlCount(){ + return 4; + } + virtual EffectControlDialog* createView() + { + return new DelayControlsDialog( this ); + } + +private slots: + void changeControl(); + +private: + DelayEffect* m_effect; + TempoSyncKnobModel m_delayTimeModel; + FloatModel m_feebackModel; + TempoSyncKnobModel m_lfoTimeModel; + FloatModel m_lfoAmmountModel; + + friend class DelayControlsDialog; + friend class DelayEffect; +}; + +#endif // DELAYCONTROLS_H diff --git a/plugins/delay/delaycontrolsdialog.cpp b/plugins/delay/delaycontrolsdialog.cpp new file mode 100644 index 000000000..a27e4cdb2 --- /dev/null +++ b/plugins/delay/delaycontrolsdialog.cpp @@ -0,0 +1,70 @@ +/* + * delaycontrolsdialog.cpp - definition of DelayControlsDialog class. + * + * Copyright (c) 2014 David French + * + * This file is part of LMMS - http://lmms.io + * + * 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 "delaycontrolsdialog.h" +#include "delaycontrols.h" +#include "embed.h" +#include "TempoSyncKnob.h" + + + + +DelayControlsDialog::DelayControlsDialog(DelayControls *controls) : + EffectControlDialog( controls ) +{ + setAutoFillBackground( true ); + QPalette pal; + pal.setBrush( backgroundRole(), PLUGIN_NAME::getIconPixmap( "artwork" ) ); + setPalette( pal ); + setFixedSize( 100,125 ); + + TempoSyncKnob* sampleDelayKnob = new TempoSyncKnob( knobBright_26, this ); + sampleDelayKnob->move( 20,30 ); + sampleDelayKnob->setVolumeKnob( false ); + sampleDelayKnob->setModel( &controls->m_delayTimeModel ); + sampleDelayKnob->setLabel( tr( "Delay" ) ); + sampleDelayKnob->setHintText( tr( "Delay Time Samples:" ) + " ", "" ); + + knob * feedbackKnob = new knob( knobBright_26, this); + feedbackKnob->move( 60,30 ); + feedbackKnob->setVolumeKnob(true); + feedbackKnob->setModel( &controls->m_feebackModel); + feedbackKnob->setLabel( tr( "Feedback" ) ); + feedbackKnob->setHintText( tr ( "Feedback Ammount:" ) + " ", ""); + + TempoSyncKnob * lfoFreqKnob = new TempoSyncKnob( knobBright_26, this); + lfoFreqKnob->move( 20,80 ); + lfoFreqKnob->setVolumeKnob(false); + lfoFreqKnob->setModel( &controls->m_lfoTimeModel); + lfoFreqKnob->setLabel( tr( "Lfo Hz" ) ); + lfoFreqKnob->setHintText( tr ( "Lfo Hz:" ) + " ", ""); + + knob * lfoAmtKnob = new knob( knobBright_26, this); + lfoAmtKnob->move( 60,80 ); + lfoAmtKnob->setVolumeKnob(true); + lfoAmtKnob->setModel( &controls->m_lfoAmmountModel); + lfoAmtKnob->setLabel( tr( "Lfo Amt" ) ); + lfoAmtKnob->setHintText( tr ( "Lfo Amt:" ) + " ", ""); + +} diff --git a/plugins/delay/delaycontrolsdialog.h b/plugins/delay/delaycontrolsdialog.h new file mode 100644 index 000000000..1850c774b --- /dev/null +++ b/plugins/delay/delaycontrolsdialog.h @@ -0,0 +1,41 @@ +/* + * delaycontrolsdialog.h - declaration of DelayControlsDialog class. + * + * Copyright (c) 2014 David French + * + * This file is part of LMMS - http://lmms.io + * + * 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 DELAYCONTROLSDIALOG_H +#define DELAYCONTROLSDIALOG_H + +#include "EffectControlDialog.h" + +class DelayControls; + +class DelayControlsDialog : public EffectControlDialog +{ +public: + DelayControlsDialog(DelayControls* controls ); + virtual ~DelayControlsDialog() + { + } +}; + +#endif // DELAYCONTROLSDIALOG_H diff --git a/plugins/delay/delayeffect.cpp b/plugins/delay/delayeffect.cpp new file mode 100644 index 000000000..5da1a6299 --- /dev/null +++ b/plugins/delay/delayeffect.cpp @@ -0,0 +1,115 @@ +/* + * delayeffect.cpp - definition of the DelayEffect class. The Delay Plugin + * + * Copyright (c) 2014 David French + * + * This file is part of LMMS - http://lmms.io + * + * 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 "delayeffect.h" +#include "engine.h" +#include "embed.cpp" + + +extern "C" +{ + +Plugin::Descriptor PLUGIN_EXPORT delay_plugin_descriptor = +{ + STRINGIFY( PLUGIN_NAME ), + "Delay", + QT_TRANSLATE_NOOP( "pluginBrowser", "A native delay plugin" ), + "Dave French ", + 0x0100, + Plugin::Effect, + new PluginPixmapLoader( "logo" ), + NULL, + NULL +} ; + + + + +DelayEffect::DelayEffect( Model* parent, const Plugin::Descriptor::SubPluginFeatures::Key* key ) : + Effect( &delay_plugin_descriptor, parent, key ), + m_delayControls( this ) +{ + m_delay = 0; + m_delay = new StereoDelay( engine::mixer()->processingSampleRate()* 20 ); + m_lfo = new Lfo( engine::mixer()->processingSampleRate() ); +} + + + +DelayEffect::~DelayEffect() +{ + if( m_delay ) + { + delete m_delay; + } + if( m_lfo ) + { + delete m_lfo; + } +} + + + + +bool DelayEffect::processAudioBuffer(sampleFrame* buf, const fpp_t frames) +{ + if( !isEnabled() || !isRunning () ) + { + return( false ); + } + double outSum = 0.0; + const float d = dryLevel(); + const float w = wetLevel(); + sample_t dryS[2]; + for( fpp_t f = 0; f < frames; ++f ) + { + dryS[0] = buf[f][0]; + dryS[1] = buf[f][1]; + m_lfo->setAmplitude( m_delayControls.m_lfoAmmountModel.value( f ) ); + m_lfo->setFrequency( 1.0 / m_delayControls.m_lfoTimeModel.value( f ) ); + m_delay->setLength( m_delayControls.m_delayTimeModel.value(f) * engine::mixer()->processingSampleRate() * m_lfo->tick() ); + m_delay->setFeedback( m_delayControls.m_feebackModel.value( f ) ); + m_delay->tick( &buf[f][0], &buf[f][1] ); + + buf[f][0] = ( d * dryS[0] ) + ( w * buf[f][0] ); + buf[f][1] = ( d * dryS[1] ) + ( w * buf[f][1] ); + outSum += buf[f][0]*buf[f][0] + buf[f][1]*buf[f][1]; + } + checkGate( outSum / frames ); + return isRunning(); +} + + + +extern "C" +{ + +//needed for getting plugin out of shared lib +Plugin * PLUGIN_EXPORT lmms_plugin_main( Model* parent, void* data ) +{ + return new DelayEffect( parent , static_cast( data ) ); +} + +}} + diff --git a/plugins/delay/delayeffect.h b/plugins/delay/delayeffect.h new file mode 100644 index 000000000..58de87329 --- /dev/null +++ b/plugins/delay/delayeffect.h @@ -0,0 +1,49 @@ +/* + * delayeffect.h - declaration of DelayEffect class, the Delay plugin + * + * Copyright (c) 2014 David French + * + * This file is part of LMMS - http://lmms.io + * + * 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 DELAYEFFECT_H +#define DELAYEFFECT_H + +#include "Effect.h" +#include "delaycontrols.h" +#include "lfo.h" +#include "stereodelay.h" + +class DelayEffect : public Effect +{ +public: + DelayEffect(Model* parent , const Descriptor::SubPluginFeatures::Key* key ); + virtual ~DelayEffect(); + virtual bool processAudioBuffer( sampleFrame* buf, const fpp_t frames); + virtual EffectControls* controls() + { + return &m_delayControls; + } +private: + DelayControls m_delayControls; + StereoDelay* m_delay; + Lfo* m_lfo; +}; + +#endif // DELAYEFFECT_H diff --git a/plugins/delay/lfo.cpp b/plugins/delay/lfo.cpp new file mode 100644 index 000000000..b93e9ad46 --- /dev/null +++ b/plugins/delay/lfo.cpp @@ -0,0 +1,79 @@ +/* + * lfo.cpp - defination of Lfo class. + * + * Copyright (c) 2014 David French + * + * This file is part of LMMS - http://lmms.io + * + * 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 "lfo.h" +#include + + + + +Lfo::Lfo( int samplerate ) +{ + m_samplerate = samplerate; + m_twoPiOverSr = TWOPI / samplerate; +} + + + +void Lfo::setFrequency( double frequency ) +{ + if( frequency < 0 || frequency > ( m_samplerate / 2.0 ) || frequency == m_frequency ) + { + return; + } + m_frequency = frequency; + m_increment = m_frequency * m_twoPiOverSr; +} + + + + +void Lfo::setAmplitude( float amplitude ) +{ + if( amplitude < 0.0 || amplitude > 1.0 ) + { + return; + } + m_amplitude = amplitude; +} + + + + +float Lfo::tick() +{ + float output = ( float )sin( m_phase ); + m_phase += m_increment; + if( m_phase >= TWOPI ) + { + m_phase -= TWOPI; + } + if( m_amplitude > 0.0001 ) + { + return ( ( output + 1.0 ) / 2.0 ) * m_amplitude; + } else + { + return 1; + } +} diff --git a/plugins/delay/lfo.h b/plugins/delay/lfo.h new file mode 100644 index 000000000..b561bbafa --- /dev/null +++ b/plugins/delay/lfo.h @@ -0,0 +1,53 @@ +/* + * lfo.h - declaration of Lfo class, a simple sine lfo + * + * Copyright (c) 2014 David French + * + * This file is part of LMMS - http://lmms.io + * + * 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 LFO_H +#define LFO_H + +#ifndef M_PI +#define M_PI (3.14159265358979321 ) +#endif +#define TWOPI ( 2.0 * M_PI ) + +class Lfo +{ +public: + Lfo( int samplerate ); + ~Lfo() + { + } + void setFrequency( double frequency ); + void setAmplitude( float amplitude ); + float tick(); + +private: + double m_frequency; + double m_phase; + double m_increment; + double m_amplitude; + double m_twoPiOverSr; + int m_samplerate; +}; + +#endif // LFO_H diff --git a/plugins/delay/logo.png b/plugins/delay/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..89e9f3680118931dd86f065a8f6bc0b4c631a585 GIT binary patch literal 3225 zcmV;K3}*9*P)`#WFm#_KhbhiGA@U*^o_ z?)UBYo!>dX?|kR%N`_(3mE2^y!khFt%vlIo2DuiJ53xXoA?=VokVZ)2as;qQmgTQk zRaM=vc=6&zGiJEI(qbI$Du=q8bYDa-!T4lNbqv-;`L=^Wjh{! z{PDzr0|$(OfdS*wS|X7!+S=NTZQHgPH{X17r=lo7!t?I`l?SGwJ#pWC_ib3WZk^=u zcnAs-2L-lzW^j-sNr=^ICA-}&`giTxMVmKoKG)dT_#F&+=ZgeTk(ZbE`g6}cx3Ipx zo-7uNP>z*~#bN|6ki+2+_tF7m0%D3qqfy$lX%lVVzMZ}ClP?0mRdD@VPe1*1pFK+ofU!5YF*p_;mk!1RdhfmW(!qlVx8m0KCZmipN#!dc z@2y(3s(kh8)x@-MI-L{_hlM5C`Ybk^jnrh4`uqE7cz9SyBoY<$@dK>i=M!W2nLr>w znx+x<5$)KqV+jB{u*S}bDrA|2@=nO_ATw%fYsI2$>8`F$;YgF?CjYsg_e4i$2W4kv zQ$az2piC0LhJr!i2?oSK+S}VHFE5vP-rc)*{}2eF>pfud6P*|l_SoFF@*VCGB-9aZ? zPeb`Alvaf0c`QG}pg924)YOQ*)Y{sbx%PK2MKZTO(^ETl?i9+eU%y^(maWO$mZ3Zu zNlcocMGGov$^1NW>RoipjSI*ksU)FKQAR>5KhIz|n$4YCO|QN72T-UtbM3D{uKO$$ z@~UELR`@5Byj z4`h+zo<$aAMnm>O&a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* + * This file is part of LMMS - http://lmms.io + * + * 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 "stereodelay.h" +#include + + +StereoDelay::StereoDelay(int maxLength) +{ + m_buffer = 0; + m_buffer = ( float* )malloc(maxLength*2*sizeof( float ) ); + m_maxLength = maxLength; + m_length = m_maxLength; + m_index = 0; + m_feedback = 0.0f; + setLength( 0 ); +} + + + + +StereoDelay::~StereoDelay() +{ + if( m_buffer ) + { + free( m_buffer ); + } +} + + + + +void StereoDelay::setLength( int length ) +{ + if( length <= m_maxLength && length >= 0 ) + { + if( length < m_length ) + { + for( int i = length * 2; i < m_length *2; i++) + { + m_buffer[i] = 0.0f; + } + } + m_length = length; + } +} + + + + +void StereoDelay::setFeedback( float feedback ) +{ + m_feedback = feedback; +} + + + +float m_oldLeft; +float m_oldRight; +void StereoDelay::tick( float* left, float* right ) +{ + m_oldLeft = m_buffer[m_index]; + m_oldRight = m_buffer[m_index+1]; + m_buffer[m_index] = *left + ( m_oldLeft * m_feedback ); + m_buffer[m_index+1] = *right + ( m_oldRight * m_feedback ); + *left = m_oldLeft; + *right = m_oldRight; + m_index++; m_index++; + if( m_index > m_length ) + { + m_index = 0; + } +} + + + + + + diff --git a/plugins/delay/stereodelay.h b/plugins/delay/stereodelay.h new file mode 100644 index 000000000..f4e4431b7 --- /dev/null +++ b/plugins/delay/stereodelay.h @@ -0,0 +1,44 @@ +/* + * stereodelay.h - declaration of StereoDelay class. + * + * Copyright (c) 2014 David French + * + * This file is part of LMMS - http://lmms.io + * + * 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 STEREODELAY_H +#define STEREODELAY_H + +class StereoDelay +{ +public: + StereoDelay( int maxLength ); + ~StereoDelay(); + void setLength( int length ); + void setFeedback( float feedback ); + void tick( float* left, float* right ); +private: + float *m_buffer; + int m_maxLength; + int m_length; + int m_index; + float m_feedback; +}; + +#endif // STEREODELAY_H