summaryrefslogtreecommitdiff
path: root/attic/muse_qt4_evolution/plugins/pandelay
diff options
context:
space:
mode:
Diffstat (limited to 'attic/muse_qt4_evolution/plugins/pandelay')
-rw-r--r--attic/muse_qt4_evolution/plugins/pandelay/CMakeLists.txt33
-rw-r--r--attic/muse_qt4_evolution/plugins/pandelay/ladspapandelay.cpp100
-rw-r--r--attic/muse_qt4_evolution/plugins/pandelay/ladspapandelay.h55
-rw-r--r--attic/muse_qt4_evolution/plugins/pandelay/pandelay.cpp170
-rw-r--r--attic/muse_qt4_evolution/plugins/pandelay/pandelaymodel.cpp154
-rw-r--r--attic/muse_qt4_evolution/plugins/pandelay/pandelaymodel.h93
6 files changed, 605 insertions, 0 deletions
diff --git a/attic/muse_qt4_evolution/plugins/pandelay/CMakeLists.txt b/attic/muse_qt4_evolution/plugins/pandelay/CMakeLists.txt
new file mode 100644
index 00000000..5ebb08a0
--- /dev/null
+++ b/attic/muse_qt4_evolution/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/attic/muse_qt4_evolution/plugins/pandelay/ladspapandelay.cpp b/attic/muse_qt4_evolution/plugins/pandelay/ladspapandelay.cpp
new file mode 100644
index 00000000..b5680d3e
--- /dev/null
+++ b/attic/muse_qt4_evolution/plugins/pandelay/ladspapandelay.cpp
@@ -0,0 +1,100 @@
+//===========================================================================
+//
+// 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];
+ *port[9] = param[5];
+}
+
+void LADSPAPanDelay::updateParameters() {
+ if (param[0] != *port[4]) {
+ param[0] = *port[4];
+ setBPM(param[0]);
+ }
+ if (param[1] != *port[5]) {
+ param[1] = *port[5];
+ setBeatRatio(param[1]);
+ }
+ if (param[2] != *port[6]) {
+ param[2] = *port[6];
+ setFeedback(param[2]);
+ }
+ if (param[3] != *port[7]) {
+ param[3] = *port[7];
+ setPanLFOFreq(param[3]);
+ }
+ if (param[4] != *port[8]) {
+ param[4] = *port[8];
+ setPanLFODepth(param[4]);
+ }
+ if (param[5] != *port[9]) {
+ param[5] = *port[9];
+ setDryWet(param[5]);
+ }
+}
+
+//---------------------------------------------------------
+// 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/attic/muse_qt4_evolution/plugins/pandelay/ladspapandelay.h b/attic/muse_qt4_evolution/plugins/pandelay/ladspapandelay.h
new file mode 100644
index 00000000..ab5427a1
--- /dev/null
+++ b/attic/muse_qt4_evolution/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 6
+
+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/attic/muse_qt4_evolution/plugins/pandelay/pandelay.cpp b/attic/muse_qt4_evolution/plugins/pandelay/pandelay.cpp
new file mode 100644
index 00000000..18ce1a41
--- /dev/null
+++ b/attic/muse_qt4_evolution/plugins/pandelay/pandelay.cpp
@@ -0,0 +1,170 @@
+//=========================================================
+// 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)",
+ "BMP",
+ "Beat Ratio",
+ "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_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_100, MINBPM, MAXBPM },
+ { LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_DEFAULT_1, MINBEATRATIO, MAXBEATRATIO },
+ { 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/attic/muse_qt4_evolution/plugins/pandelay/pandelaymodel.cpp b/attic/muse_qt4_evolution/plugins/pandelay/pandelaymodel.cpp
new file mode 100644
index 00000000..ab01ba9f
--- /dev/null
+++ b/attic/muse_qt4_evolution/plugins/pandelay/pandelaymodel.cpp
@@ -0,0 +1,154 @@
+//===========================================================================
+//
+// 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::setBPM(float bpm) {
+ _BPM = bpm;
+ _delayTime = _beatRatio * 60.0 / _BPM;
+ setPanDelay();
+}
+
+void PanDelayModel::setBeatRatio(float br) {
+ _beatRatio = br;
+ _delayTime = _beatRatio * 60.0 / _BPM;
+ 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/attic/muse_qt4_evolution/plugins/pandelay/pandelaymodel.h b/attic/muse_qt4_evolution/plugins/pandelay/pandelaymodel.h
new file mode 100644
index 00000000..65983187
--- /dev/null
+++ b/attic/muse_qt4_evolution/plugins/pandelay/pandelaymodel.h
@@ -0,0 +1,93 @@
+//===========================================================================
+//
+// 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 MINBPM 60.0
+#define MAXBPM 255.0
+#define MINBEATRATIO 0.125
+#define MAXBEATRATIO 2.0
+#define MINDELAYTIME 0.01 //in second
+#define MAXDELAYTIME 2.0 //in second
+
+#define NBRPARAM 5
+
+class PanDelayModel {
+ private:
+ int _samplerate;
+
+ //bool _beatFraction; //if true then the delay is calculated in beat fraction
+ float _BPM;
+ float _beatRatio;
+ float _delayTime; //delay is calculated according to BMP and ratioBMP
+ 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 setBeatRatio(float br);
+ void setBPM(float bpm);
+ 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 */