diff options
Diffstat (limited to 'muse/plugins')
-rw-r--r-- | muse/plugins/CMakeLists.txt | 2 | ||||
-rw-r--r-- | muse/plugins/doublechorus/doublechorusmodel.h | 18 | ||||
-rw-r--r-- | muse/plugins/pandelay/CMakeLists.txt | 33 | ||||
-rw-r--r-- | muse/plugins/pandelay/ladspapandelay.cpp | 95 | ||||
-rw-r--r-- | muse/plugins/pandelay/ladspapandelay.h | 55 | ||||
-rw-r--r-- | muse/plugins/pandelay/pandelay.cpp | 167 | ||||
-rw-r--r-- | muse/plugins/pandelay/pandelaymodel.cpp | 142 | ||||
-rw-r--r-- | muse/plugins/pandelay/pandelaymodel.h | 84 |
8 files changed, 586 insertions, 10 deletions
diff --git a/muse/plugins/CMakeLists.txt b/muse/plugins/CMakeLists.txt index e62f25ad..1293902f 100644 --- a/muse/plugins/CMakeLists.txt +++ b/muse/plugins/CMakeLists.txt @@ -18,5 +18,5 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #============================================================================= -subdirs( freeverb doublechorus ) +subdirs( freeverb doublechorus pandelay ) diff --git a/muse/plugins/doublechorus/doublechorusmodel.h b/muse/plugins/doublechorus/doublechorusmodel.h index 6dc7f3ac..40ce9f3f 100644 --- a/muse/plugins/doublechorus/doublechorusmodel.h +++ b/muse/plugins/doublechorus/doublechorusmodel.h @@ -49,15 +49,15 @@ class DoubleChorusModel { DoubleChorusModel(unsigned long samplerate); ~DoubleChorusModel(); - void processMix(long numsamples); - void processReplace(long numsamples); - void setPan1(float value); - void setLFOFreq1(float value); - void setDepth1(float value); - void setPan2(float value); - void setLFOFreq2(float value); - void setDepth2(float value); - void setDryWet(float value); + void processMix(long numsamples); + void processReplace(long numsamples); + void setPan1(float value); + void setLFOFreq1(float value); + void setDepth1(float value); + void setPan2(float value); + void setLFOFreq2(float value); + void setDepth2(float value); + void setDryWet(float value); float getPan1(); float getLFOFreq1(); float getDepth1(); diff --git a/muse/plugins/pandelay/CMakeLists.txt b/muse/plugins/pandelay/CMakeLists.txt new file mode 100644 index 00000000..5ebb08a0 --- /dev/null +++ b/muse/plugins/pandelay/CMakeLists.txt @@ -0,0 +1,33 @@ +#============================================================================= +# MusE +# Linux Music Editor +# $Id:$ +# +# Copyright (C) 2002-2006 by Werner Schweer and others +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2. +# +# 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; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +#============================================================================= + +add_library ( pandelay SHARED + pandelay.cpp ladspapandelay.cpp pandelaymodel.cpp + ) + +# tell cmake to name the target pandelay.so instead of +# libpandelay.so +# +set_target_properties (pandelay + PROPERTIES PREFIX "" + #COMPILE_FLAGS "-O3" + ) + +install_targets ( /lib/${MusE_INSTALL_NAME}/plugins pandelay) diff --git a/muse/plugins/pandelay/ladspapandelay.cpp b/muse/plugins/pandelay/ladspapandelay.cpp new file mode 100644 index 00000000..8c1caa20 --- /dev/null +++ b/muse/plugins/pandelay/ladspapandelay.cpp @@ -0,0 +1,95 @@ +//=========================================================================== +// +// ladspapandelay +// +// Version 0.0.1 +// +// +// +// +// Copyright (c) 2006 Nil Geisweiller +// +// +// +// 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; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +// 02111-1307, USA or point your web browser to http://www.gnu.org. +//=========================================================================== + +#include "ladspapandelay.h" + +//--------------------------------------------------------- +// PanDelay +//--------------------------------------------------------- + +LADSPAPanDelay::LADSPAPanDelay(unsigned long samplerate) + : PanDelayModel(samplerate) { + //TODO init param +} + +LADSPAPanDelay::~LADSPAPanDelay() { +} + +//--------------------------------------------------------- +// activate +//--------------------------------------------------------- + +void LADSPAPanDelay::activate() { + *port[4] = param[0]; + *port[5] = param[1]; + *port[6] = param[2]; + *port[7] = param[3]; + *port[8] = param[4]; +} + +void LADSPAPanDelay::updateParameters() { + if (param[0] != *port[4]) { + param[0] = *port[4]; + setDelayTime(param[0]); + } + if (param[1] != *port[5]) { + param[1] = *port[5]; + setFeedback(param[1]); + } + if (param[2] != *port[6]) { + param[2] = *port[6]; + setPanLFOFreq(param[2]); + } + if (param[3] != *port[7]) { + param[3] = *port[7]; + setPanLFODepth(param[3]); + } + if (param[4] != *port[8]) { + param[4] = *port[8]; + setDryWet(param[4]); + } +} + +//--------------------------------------------------------- +// processReplace +//--------------------------------------------------------- + +void LADSPAPanDelay::processReplace(long n) { + updateParameters(); + PanDelayModel::processReplace(port[0], port[1], port[2], port[3], n); +} + +//--------------------------------------------------------- +// processMix +//--------------------------------------------------------- + +void LADSPAPanDelay::processMix(long n) { + updateParameters(); + PanDelayModel::processMix(port[0], port[1], port[2], port[3], n); +} diff --git a/muse/plugins/pandelay/ladspapandelay.h b/muse/plugins/pandelay/ladspapandelay.h new file mode 100644 index 00000000..1918895c --- /dev/null +++ b/muse/plugins/pandelay/ladspapandelay.h @@ -0,0 +1,55 @@ +//=========================================================================== +// +// ladspapandelay +// +// Version 0.0.1 +// +// +// +// +// Copyright (c) 2006 Nil Geisweiller +// +// +// +// 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; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +// 02111-1307, USA or point your web browser to http://www.gnu.org. +//=========================================================================== + +#ifndef __LADSPAPANDELAY_H +#define __LADSPAPANDELAY_H + +#include "pandelaymodel.h" +#include "../../muse/ladspa.h" + +#define NBRPARAM 5 + +class LADSPAPanDelay : public PanDelayModel { + private: + + public: + LADSPAPanDelay(unsigned long samplerate); + ~LADSPAPanDelay(); + + LADSPA_Data* port[NBRPARAM + 4]; + float param[NBRPARAM]; + + void updateParameters(); + void processMix(long numsamples); + void processReplace(long numsamples); + + void activate(); +}; + +#endif diff --git a/muse/plugins/pandelay/pandelay.cpp b/muse/plugins/pandelay/pandelay.cpp new file mode 100644 index 00000000..401e03af --- /dev/null +++ b/muse/plugins/pandelay/pandelay.cpp @@ -0,0 +1,167 @@ +//========================================================= +// PanDelay for MusE +// +// (C) Copyright 2006 Nil Geisweiller +//========================================================= + +#include "ladspapandelay.h" +#include <stdio.h> + +//--------------------------------------------------------- +// instantiate pandelay +// Construct a new plugin instance. +//--------------------------------------------------------- + +LADSPA_Handle instantiate(const LADSPA_Descriptor* /*Descriptor*/, + unsigned long samplerate) +{ + return new LADSPAPanDelay(samplerate); +} + +//--------------------------------------------------------- +// connect PortTo pandelay +// Connect a port to a data location. +//--------------------------------------------------------- + +void connect(LADSPA_Handle Instance, unsigned long port, + LADSPA_Data* data) +{ + ((LADSPAPanDelay*)Instance)->port[port] = data; +} + +//--------------------------------------------------------- +// activate +//--------------------------------------------------------- + +void activate(LADSPA_Handle instance) +{ + ((LADSPAPanDelay*)instance)->activate(); +} + +//--------------------------------------------------------- +// deactivate +//--------------------------------------------------------- + +void deactivate(LADSPA_Handle /*Instance*/) +{ +} + +//--------------------------------------------------------- +// run pandelay +//--------------------------------------------------------- + +void run(LADSPA_Handle Instance, unsigned long n) +{ + ((LADSPAPanDelay*)Instance)->processReplace(n); +} + +//--------------------------------------------------------- +// runAdding pandelay +// *ADD* the output to the output buffer. +//--------------------------------------------------------- + +void runAdding(LADSPA_Handle Instance, unsigned long n) +{ + ((LADSPAPanDelay*)Instance)->processMix(n); +} + +//--------------------------------------------------------- +// set pandelay RunAddingGain +//--------------------------------------------------------- + +void setGain(LADSPA_Handle /*Instance*/, LADSPA_Data /*Gain*/) +{ + printf("TEST setGain\n"); + // ((LADSPAPanDelay*)Instance)->m_fRunAddingGain = Gain; +} + +//--------------------------------------------------------- +// cleanup pandelay +//--------------------------------------------------------- + +void cleanup(LADSPA_Handle Instance) +{ + delete (LADSPAPanDelay*)Instance; +} + +static const char* portNames[] = { + "Input (Left)", + "Input (Right)", + "Output (Left)", + "Output (Right)", + "Delay Time (ms)", + "Feedback", + "Pan LFO Freq", + "Pan LFO Depth", + "Dry/Wet" +}; + +LADSPA_PortDescriptor portDescriptors[] = { + LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO, + LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO, + LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO, + LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO, + LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL, + LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL, + LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL, + LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL, + LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL +}; + +LADSPA_PortRangeHint portRangeHints[] = { + { 0, 0.0, 0.0 }, + { 0, 0.0, 0.0 }, + { 0, 0.0, 0.0 }, + { 0, 0.0, 0.0 }, + { LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_DEFAULT_LOW, MINDELAYTIME, MAXDELAYTIME }, + { LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_DEFAULT_HIGH, -1.0, 1.0 }, + { LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_LOGARITHMIC | LADSPA_HINT_DEFAULT_HIGH, MINFREQ, MAXFREQ }, + { LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_DEFAULT_HIGH, 0.0, 1.0 }, + { LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_DEFAULT_MIDDLE, 0.0, 1.0 } +}; + +LADSPA_Descriptor descriptor = { + 1052, + "pandelay", + LADSPA_PROPERTY_HARD_RT_CAPABLE, + "PanDelay", + "Nil Geisweiller", + "GPL", + NBRPARAM + 4, + portDescriptors, + portNames, + portRangeHints, + 0, // impl. data + instantiate, + connect, + activate, + run, + runAdding, + setGain, + deactivate, + cleanup +}; + +//--------------------------------------------------------- +// _init +// called automatically when the plugin library is first +// loaded. +//--------------------------------------------------------- +void _init() { +} + +//--------------------------------------------------------- +// _fini +// called automatically when the library is unloaded. +//--------------------------------------------------------- +void _fini() { +} + +//--------------------------------------------------------- +// ladspa_descriptor +// Return a descriptor of the requested plugin type. +//--------------------------------------------------------- +const LADSPA_Descriptor* ladspa_descriptor(unsigned long i) { + return (i == 0) ? &descriptor : 0; +} + diff --git a/muse/plugins/pandelay/pandelaymodel.cpp b/muse/plugins/pandelay/pandelaymodel.cpp new file mode 100644 index 00000000..b3ce16a7 --- /dev/null +++ b/muse/plugins/pandelay/pandelaymodel.cpp @@ -0,0 +1,142 @@ +//=========================================================================== +// +// PanDelay, panoramic rotating delay +// +// version 0.0.1 +// +// pandelaymodel.cpp +// +// +// Copyright (c) 2006 Nil Geisweiller +// +// +// +// 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; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +// 02111-1307, USA or point your web browser to http://www.gnu.org. +//=========================================================================== + +#include "pandelaymodel.h" + +PanDelayModel::PanDelayModel(int samplerate) { + for(int i = 0; i < MAXBUFFERLENGTH; i++) { + _leftBuffer[i] = 0.0; + _rightBuffer[i] = 0.0; + } + _bufferPointer = 0; + _inc = 0.0; + _l = 1.0; + _r = 1.0; + + _samplerate = samplerate; + setPanDelay(); +} + +PanDelayModel::~PanDelayModel() { +} + +void PanDelayModel::setSamplerate(int sr) { + _samplerate = sr; + setPanDelay(); +} + +void PanDelayModel::setDelayTime(float dt) { + if(dt < MINDELAYTIME) _delayTime = MINDELAYTIME; + else if(dt > MAXDELAYTIME) _delayTime = MAXDELAYTIME; + else _delayTime = dt; + setPanDelay(); +} + +void PanDelayModel::setFeedback(float fb) { + _feedback = fb; + setPanDelay(); +} + +void PanDelayModel::setPanLFOFreq(float pf) { + _panLFOFreq = pf; + setPanDelay(); +} + +void PanDelayModel::setPanLFODepth(float pd) { + _panLFODepth = pd; + setPanDelay(); +} + +void PanDelayModel::setDryWet(float dw) { + _dryWet = dw; +} + +void PanDelayModel::setPanDelay() { + float numLFOSample = (1.0/_panLFOFreq) * (float)_samplerate; + _inc = 2.0 / numLFOSample; + _delaySampleSize = (int)(_delayTime * (float)_samplerate); + _lBound = 1.0 - _panLFODepth; + _rBound = 1.0 + _panLFODepth; +} + +void PanDelayModel::processMix(float* leftSamplesIn, float* rightSamplesIn, + float* leftSamplesOut, float* rightSamplesOut, + unsigned n) { + float ls, rs, p; + p = 1.0 - _dryWet; + for(unsigned i = 0; i < n; i++) { + //read buffer + ls = _leftBuffer[_bufferPointer]; + rs = _rightBuffer[_bufferPointer]; + //write buffer + _leftBuffer[_bufferPointer] *= _feedback; + _leftBuffer[_bufferPointer] += leftSamplesIn[i]; + _rightBuffer[_bufferPointer] *= _feedback; + _rightBuffer[_bufferPointer] += rightSamplesIn[i]; + //write out + leftSamplesOut[i] += _l * _dryWet * ls + p * leftSamplesIn[i]; + rightSamplesOut[i] += _r * _dryWet * rs + p * rightSamplesIn[i]; + //update _bufferPointer + _bufferPointer++; + _bufferPointer%=_delaySampleSize; + //update _l _r + _r += _inc; + _l -= _inc; + //update _inc + if(_r > _rBound || _r < _lBound) _inc = -_inc; + } +} + +void PanDelayModel::processReplace(float* leftSamplesIn, float* rightSamplesIn, + float* leftSamplesOut, + float* rightSamplesOut, unsigned n) { + float ls, rs, p; + p = 1.0 - _dryWet; + for(unsigned i = 0; i < n; i++) { + //read buffer + ls = _leftBuffer[_bufferPointer]; + rs = _rightBuffer[_bufferPointer]; + //write buffer + _leftBuffer[_bufferPointer] *= _feedback; + _leftBuffer[_bufferPointer] += leftSamplesIn[i]; + _rightBuffer[_bufferPointer] *= _feedback; + _rightBuffer[_bufferPointer] += rightSamplesIn[i]; + //write out + leftSamplesOut[i] = _l * _dryWet * ls + p * leftSamplesIn[i]; + rightSamplesOut[i] = _r * _dryWet * rs + p * rightSamplesIn[i]; + //update _bufferPointer + _bufferPointer++; + _bufferPointer%=_delaySampleSize; + //update _l _r + _r += _inc; + _l -= _inc; + //update _inc + if(_r > _rBound || _r < _lBound) _inc = -_inc; + } +} diff --git a/muse/plugins/pandelay/pandelaymodel.h b/muse/plugins/pandelay/pandelaymodel.h new file mode 100644 index 00000000..ed4255e2 --- /dev/null +++ b/muse/plugins/pandelay/pandelaymodel.h @@ -0,0 +1,84 @@ +//=========================================================================== +// +// PanDelay, panoramic rotating delay +// +// version 0.0.1 +// +// pandelaymodel.h +// +// +// Copyright (c) 2006 Nil Geisweiller +// +// +// +// 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; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +// 02111-1307, USA or point your web browser to http://www.gnu.org. +//=========================================================================== + +#ifndef __PANDELAYMODEL_H +#define __PANDELAYMODEL_H + +#include <math.h> + +#define MAXBUFFERLENGTH 192000 +#define MINFREQ 0.1 //in Hz +#define MAXFREQ 10.0 //in Hz +#define MINDELAYTIME 0.01 //in second +#define MAXDELAYTIME 2.0 //in second + +#define NBRPARAM 5 + +class PanDelayModel { + private: + int _samplerate; + + float _delayTime; + float _feedback; + float _panLFOFreq; + float _panLFODepth; + float _dryWet; //0.0 : dry, 1.0 : wet + + int _delaySampleSize; + float _lBound; + float _rBound; + float _inc; + float _l; + float _r; + + float _leftBuffer[MAXBUFFERLENGTH]; + float _rightBuffer[MAXBUFFERLENGTH]; + int _bufferPointer; + + public: + PanDelayModel(int samplerate); + ~PanDelayModel(); + + void setSamplerate(int sr); + void setDelayTime(float dt); + void setFeedback(float dt); + void setPanLFOFreq(float pf); + void setPanLFODepth(float pd); + void setDryWet(float dw); + void setPanDelay(); + + void processMix(float* leftInSamples, float* rightInSamples, + float* leftOutSamples, float* rightOutSamples, + unsigned n); + void processReplace(float* leftInSamples, float* rightInSamples, + float* leftOutSamples, float* rightOutSamples, + unsigned n); +}; + +#endif /* __PANDELAYMODEL_H */ |