aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-08-21 23:51:21 +0000
committerDavid Robillard <d@drobilla.net>2012-08-21 23:51:21 +0000
commitbd2f4150a8e78a4e09fb962782a07821ee7ae7f1 (patch)
treef59243ed2f9d247b311b03a3834bf55961af3626
parent734a9f490f2f8cb4552c71bfac8fc779f836c436 (diff)
downloadfomp.lv2-bd2f4150a8e78a4e09fb962782a07821ee7ae7f1.tar.gz
fomp.lv2-bd2f4150a8e78a4e09fb962782a07821ee7ae7f1.tar.bz2
fomp.lv2-bd2f4150a8e78a4e09fb962782a07821ee7ae7f1.zip
Add parametric EQ and auto-wah.
git-svn-id: http://svn.drobilla.net/lad/trunk/plugins/fomp.lv2@4735 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--fomp.lv2/autowah.ttl73
-rw-r--r--fomp.lv2/manifest.ttl.in10
-rw-r--r--fomp.lv2/parametric1.ttl195
-rw-r--r--src/autowah.cc130
-rw-r--r--src/autowah.h52
-rw-r--r--src/autowah_lv2.cc56
-rw-r--r--src/filters.cc113
-rw-r--r--src/filters.h130
-rw-r--r--src/filters_lv2.cc56
-rw-r--r--wscript4
10 files changed, 818 insertions, 1 deletions
diff --git a/fomp.lv2/autowah.ttl b/fomp.lv2/autowah.ttl
new file mode 100644
index 0000000..ec99fb3
--- /dev/null
+++ b/fomp.lv2/autowah.ttl
@@ -0,0 +1,73 @@
+@prefix doap: <http://usefulinc.com/ns/doap#> .
+@prefix foaf: <http://xmlns.com/foaf/0.1/> .
+@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
+@prefix owl: <http://www.w3.org/2002/07/owl#> .
+@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
+@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
+
+<http://drobilla.net/plugins/fomp/autowah>
+ a lv2:Plugin ,
+ lv2:FilterPlugin ;
+ doap:name "Auto-wah" ;
+ lv2:microVersion 0 ;
+ lv2:minorVersion 0 ;
+ lv2:optionalFeature lv2:hardRTCapable ;
+ lv2:port [
+ a lv2:AudioPort ,
+ lv2:InputPort ;
+ lv2:index 0 ;
+ lv2:name "Input" ;
+ lv2:symbol "in"
+ ] , [
+ a lv2:AudioPort ,
+ lv2:OutputPort ;
+ lv2:index 1 ;
+ lv2:name "Output" ;
+ lv2:symbol "out"
+ ] , [
+ a lv2:ControlPort ,
+ lv2:InputPort ;
+ lv2:default 0.0 ;
+ lv2:index 2 ;
+ lv2:maximum 20.0 ;
+ lv2:minimum -20.0 ;
+ lv2:name "Drive" ;
+ lv2:symbol "drive"
+ ] , [
+ a lv2:ControlPort ,
+ lv2:InputPort ;
+ lv2:default 0.5 ;
+ lv2:index 3 ;
+ lv2:maximum 1.0 ;
+ lv2:minimum 0.0 ;
+ lv2:name "Decay" ;
+ lv2:symbol "decay"
+ ] , [
+ a lv2:ControlPort ,
+ lv2:InputPort ;
+ lv2:default 0.5 ;
+ lv2:index 4 ;
+ lv2:maximum 1.0 ;
+ lv2:minimum 0.0 ;
+ lv2:name "Range" ;
+ lv2:symbol "range"
+ ] , [
+ a lv2:ControlPort ,
+ lv2:InputPort ;
+ lv2:default 0.5 ;
+ lv2:index 5 ;
+ lv2:maximum 1.0 ;
+ lv2:minimum 0.0 ;
+ lv2:name "Freq" ;
+ lv2:symbol "freq"
+ ] , [
+ a lv2:ControlPort ,
+ lv2:InputPort ;
+ lv2:default 0.5 ;
+ lv2:index 6 ;
+ lv2:maximum 1.0 ;
+ lv2:minimum 0.0 ;
+ lv2:name "Mix" ;
+ lv2:symbol "mix"
+ ] .
diff --git a/fomp.lv2/manifest.ttl.in b/fomp.lv2/manifest.ttl.in
index 80291ad..ad71d53 100644
--- a/fomp.lv2/manifest.ttl.in
+++ b/fomp.lv2/manifest.ttl.in
@@ -78,3 +78,13 @@ fomp:rec_vco
a lv2:Plugin ;
rdfs:seeAlso <rec_vco.ttl> ;
lv2:binary <blvco@LIB_EXT@> .
+
+fomp:parametric1
+ a lv2:Plugin ;
+ rdfs:seeAlso <parametric1.ttl> ;
+ lv2:binary <filters@LIB_EXT@> .
+
+fomp:autowah
+ a lv2:Plugin ;
+ rdfs:seeAlso <autowah.ttl> ;
+ lv2:binary <autowah@LIB_EXT@> .
diff --git a/fomp.lv2/parametric1.ttl b/fomp.lv2/parametric1.ttl
new file mode 100644
index 0000000..8118107
--- /dev/null
+++ b/fomp.lv2/parametric1.ttl
@@ -0,0 +1,195 @@
+@prefix doap: <http://usefulinc.com/ns/doap#> .
+@prefix fomp: <http://drobilla.net/plugins/fomp/> .
+@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
+@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
+@prefix units: <http://lv2plug.in/ns/extensions/units#> .
+
+fomp:parametric1
+ a lv2:Plugin ,
+ lv2:ParaEQPlugin ;
+ doap:name "4-Band Parametric Filter" ;
+ lv2:microVersion 0 ;
+ lv2:minorVersion 0 ;
+ lv2:optionalFeature lv2:hardRTCapable ;
+ lv2:port [
+ a lv2:AudioPort ,
+ lv2:InputPort ;
+ lv2:index 0 ;
+ lv2:name "Input" ;
+ lv2:symbol "in"
+ ] , [
+ a lv2:AudioPort ,
+ lv2:OutputPort ;
+ lv2:index 1 ;
+ lv2:name "Output" ;
+ lv2:symbol "out"
+ ] , [
+ a lv2:ControlPort ,
+ lv2:InputPort ;
+ lv2:default 0.0 ;
+ lv2:index 2 ;
+ lv2:name "Filter" ;
+ lv2:portProperty lv2:toggled ;
+ lv2:symbol "filter"
+ ] , [
+ a lv2:ControlPort ,
+ lv2:InputPort ;
+ lv2:default 0.0 ;
+ lv2:index 3 ;
+ lv2:maximum 20.0 ;
+ lv2:minimum -20.0 ;
+ lv2:name "Gain" ;
+ lv2:symbol "gain"
+ ] , [
+ a lv2:ControlPort ,
+ lv2:InputPort ;
+ lv2:default 0.0 ;
+ lv2:index 4 ;
+ lv2:name "Section 1" ;
+ lv2:portProperty lv2:toggled ;
+ lv2:symbol "sec_1"
+ ] , [
+ a lv2:ControlPort ,
+ lv2:InputPort ;
+ lv2:default 200.0 ;
+ lv2:index 5 ;
+ lv2:maximum 2000.0 ;
+ lv2:minimum 20.0 ;
+ lv2:name "Frequency 1" ;
+ lv2:portProperty <http://lv2plug.in/ns/ext/port-props#logarithmic> ;
+ lv2:symbol "freq_1" ;
+ units:unit units:hz
+ ] , [
+ a lv2:ControlPort ,
+ lv2:InputPort ;
+ lv2:default 1.0 ;
+ lv2:index 6 ;
+ lv2:maximum 8.0 ;
+ lv2:minimum 0.125 ;
+ lv2:name "Bandwidth 1" ;
+ lv2:portProperty <http://lv2plug.in/ns/ext/port-props#logarithmic> ;
+ lv2:symbol "bw_1"
+ ] , [
+ a lv2:ControlPort ,
+ lv2:InputPort ;
+ lv2:default 0.0 ;
+ lv2:index 7 ;
+ lv2:maximum 20.0 ;
+ lv2:minimum -20.0 ;
+ lv2:name "Gain 1" ;
+ lv2:symbol "gain_1"
+ ] , [
+ a lv2:ControlPort ,
+ lv2:InputPort ;
+ lv2:default 0.0 ;
+ lv2:index 8 ;
+ lv2:name "Section 2" ;
+ lv2:portProperty lv2:toggled ;
+ lv2:symbol "sec_2"
+ ] , [
+ a lv2:ControlPort ,
+ lv2:InputPort ;
+ lv2:default 400.0 ;
+ lv2:index 9 ;
+ lv2:maximum 4000.0 ;
+ lv2:minimum 40.0 ;
+ lv2:name "Frequency 2" ;
+ lv2:portProperty <http://lv2plug.in/ns/ext/port-props#logarithmic> ;
+ lv2:symbol "freq_2" ;
+ units:unit units:hz
+ ] , [
+ a lv2:ControlPort ,
+ lv2:InputPort ;
+ lv2:default 1.0 ;
+ lv2:index 10 ;
+ lv2:maximum 8.0 ;
+ lv2:minimum 0.125 ;
+ lv2:name "Bandwidth 2" ;
+ lv2:portProperty <http://lv2plug.in/ns/ext/port-props#logarithmic> ;
+ lv2:symbol "bw_2"
+ ] , [
+ a lv2:ControlPort ,
+ lv2:InputPort ;
+ lv2:default 0.0 ;
+ lv2:index 11 ;
+ lv2:maximum 20.0 ;
+ lv2:minimum -20.0 ;
+ lv2:name "Gain 2" ;
+ lv2:symbol "gain_2"
+ ] , [
+ a lv2:ControlPort ,
+ lv2:InputPort ;
+ lv2:default 0.0 ;
+ lv2:index 12 ;
+ lv2:name "Section 3" ;
+ lv2:portProperty lv2:toggled ;
+ lv2:symbol "sec_3"
+ ] , [
+ a lv2:ControlPort ,
+ lv2:InputPort ;
+ lv2:default 1000.0 ;
+ lv2:index 13 ;
+ lv2:maximum 10000.0 ;
+ lv2:minimum 100.0 ;
+ lv2:name "Frequency 3" ;
+ lv2:portProperty <http://lv2plug.in/ns/ext/port-props#logarithmic> ;
+ lv2:symbol "freq_3" ;
+ units:unit units:hz
+ ] , [
+ a lv2:ControlPort ,
+ lv2:InputPort ;
+ lv2:default 1.0 ;
+ lv2:index 14 ;
+ lv2:maximum 8.0 ;
+ lv2:minimum 0.125 ;
+ lv2:name "Bandwidth 3" ;
+ lv2:portProperty <http://lv2plug.in/ns/ext/port-props#logarithmic> ;
+ lv2:symbol "bw_3"
+ ] , [
+ a lv2:ControlPort ,
+ lv2:InputPort ;
+ lv2:default 0.0 ;
+ lv2:index 15 ;
+ lv2:maximum 20.0 ;
+ lv2:minimum -20.0 ;
+ lv2:name "Gain 3" ;
+ lv2:symbol "gain_3"
+ ] , [
+ a lv2:ControlPort ,
+ lv2:InputPort ;
+ lv2:default 0.0 ;
+ lv2:index 16 ;
+ lv2:name "Section 4" ;
+ lv2:portProperty lv2:toggled ;
+ lv2:symbol "sec_4"
+ ] , [
+ a lv2:ControlPort ,
+ lv2:InputPort ;
+ lv2:default 2000.0 ;
+ lv2:index 17 ;
+ lv2:maximum 20000.0 ;
+ lv2:minimum 200.0 ;
+ lv2:name "Frequency 4" ;
+ lv2:portProperty <http://lv2plug.in/ns/ext/port-props#logarithmic> ;
+ lv2:symbol "freq_4" ;
+ units:unit units:hz
+ ] , [
+ a lv2:ControlPort ,
+ lv2:InputPort ;
+ lv2:default 1.0 ;
+ lv2:index 18 ;
+ lv2:maximum 8.0 ;
+ lv2:minimum 0.125 ;
+ lv2:name "Bandwidth 4" ;
+ lv2:portProperty <http://lv2plug.in/ns/ext/port-props#logarithmic> ;
+ lv2:symbol "bw_4"
+ ] , [
+ a lv2:ControlPort ,
+ lv2:InputPort ;
+ lv2:default 0.0 ;
+ lv2:index 19 ;
+ lv2:maximum 20.0 ;
+ lv2:minimum -20.0 ;
+ lv2:name "Gain 4" ;
+ lv2:symbol "gain_4"
+ ] .
diff --git a/src/autowah.cc b/src/autowah.cc
new file mode 100644
index 0000000..a18c8d3
--- /dev/null
+++ b/src/autowah.cc
@@ -0,0 +1,130 @@
+/*
+ Copyright (C) 2009 Fons Adriaensen <fons@kokkinizita.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; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+
+#include <math.h>
+#include <string.h>
+#include "autowah.h"
+
+
+void Ladspa_Autowah::setport (PortIndex port, PortData *data)
+{
+ _port [port] = (float*)data;
+}
+
+
+#define G_RES 4.0f
+#define F_MIN 300.0f
+#define F_RAT 10
+#define B_MIN 0.03f
+#define B_RAT 4
+#define T_MIN 0.05f
+#define T_LOG 2
+
+
+void Ladspa_Autowah::active (bool act)
+{
+ if (! act) return;
+
+ _wbase = F_MIN * 6.28f / _fsam;
+ _bbase = B_MIN;
+ _rfact = 64.0f / (_fsam * T_MIN);
+ _z1 = _z2 = 0;
+ _s1 = _s2 = 0;
+ _gx = _gy = 0;
+ _dr = 0;
+}
+
+
+void Ladspa_Autowah::runproc (SampleCount len, bool add)
+{
+ int i, k;
+ float *inp = _port [A_INP];
+ float *out = _port [A_OUT];
+ float z1, z2, s1, s2, gx, gy;
+ float ds1, ds2, dgx, dgy;
+ float gd, rf, md, fr, dr;
+ float b, p, t, w, x, y;
+
+ gx = _gx;
+ gy = _gy;
+ t = _port [C_OPMIX][0];
+ _gy = G_RES * t;
+ _gx = _gy + 1 - t;
+ dgx = (_gx - gx) / len;
+ dgy = (_gy - gy) / len;
+
+ gd = 10 * powf (10.0f, 0.05f * _port [C_DRIVE][0]);
+ rf = 1.0f - _rfact / powf (10.0f, T_LOG * _port [C_DECAY][0]);
+ md = _port [C_RANGE][0];
+ fr = _port [C_FREQ][0];
+
+ z1 = _z1;
+ z2 = _z2;
+ s1 = _s1;
+ s2 = _s2;
+ dr = _dr;
+
+ while (len)
+ {
+ k = (len > 80) ? 64 : len;
+
+ p = 0;
+ for (i = 0; i < k; i++)
+ {
+ x = inp [i];
+ p += x * x;
+ }
+ p = gd * sqrtf (p / k);
+
+ if (p > dr) dr += 0.1f *(p - dr);
+ if (dr > md) dr = md;
+ t = dr + fr;
+ dr = dr * rf + 1e-10f;
+ w = _wbase * (1 + (F_RAT - 1) * t * t);
+ b = w * _bbase * (1 + (B_RAT - 1) * t);
+ if (w > 0.7f) w = 0.7f;
+
+ _s1 = -cosf (w);
+ _s2 = (1 - b) / (1 + b);
+ ds1 = (_s1 - s1) / k;
+ ds2 = (_s2 - s2) / k;
+
+ for (i = 0; i < k; i++)
+ {
+ s1 += ds1;
+ s2 += ds2;
+ gx += dgx;
+ gy += dgy;
+ x = inp [i];
+ y = x - s2 * z2;
+ out [i] = gx * x - gy * (z2 + s2 * y);
+ y -= s1 * z1;
+ z2 = z1 + s1 * y;
+ z1 = y + 1e-10f;
+ }
+ inp += k;
+ out += k;
+ len -= k;
+ }
+
+ _z1 = z1;
+ _z2 = z2;
+ _dr = dr;
+}
+
diff --git a/src/autowah.h b/src/autowah.h
new file mode 100644
index 0000000..79a3d9c
--- /dev/null
+++ b/src/autowah.h
@@ -0,0 +1,52 @@
+/*
+ Copyright (C) 2009 Fons Adriaensen <fons@kokkinizita.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; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+
+#ifndef __AUTOWAH_H
+#define __AUTOWAH_H
+
+
+#include "ladspaplugin.h"
+
+
+class Ladspa_Autowah : public LadspaPlugin
+{
+public:
+
+ enum { A_INP, A_OUT, C_DRIVE, C_DECAY, C_RANGE, C_FREQ, C_OPMIX, NPORT };
+
+ Ladspa_Autowah (SampleRate fsam) : LadspaPlugin (fsam) {}
+ virtual void setport (PortIndex port, PortData *data);
+ virtual void active (bool act);
+ virtual void runproc (SampleCount len, bool add);
+ virtual ~Ladspa_Autowah (void) {}
+
+private:
+
+ float *_port [NPORT];
+ float _wbase;
+ float _bbase;
+ float _rfact;
+ float _z1, _z2;
+ float _s1, _s2;
+ float _gx, _gy;
+ float _dr;
+};
+
+
+#endif
diff --git a/src/autowah_lv2.cc b/src/autowah_lv2.cc
new file mode 100644
index 0000000..29a64ee
--- /dev/null
+++ b/src/autowah_lv2.cc
@@ -0,0 +1,56 @@
+/*
+ Copyright (C) 2012 David Robillard <d@drobilla.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; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include <stddef.h>
+
+#include "autowah.h"
+#include "plugin_lv2.h"
+
+extern "C" {
+
+static LV2_Handle
+instantiate(const LV2_Descriptor* descriptor,
+ double rate,
+ const char* bundle_path,
+ const LV2_Feature* const* features)
+{
+ return new Ladspa_Autowah(rate);
+}
+
+static const LV2_Descriptor descriptor = {
+ "http://drobilla.net/plugins/fomp/autowah",
+ instantiate,
+ connect_port,
+ activate,
+ run,
+ deactivate,
+ cleanup,
+ NULL
+};
+
+LV2_SYMBOL_EXPORT
+const LV2_Descriptor*
+lv2_descriptor(uint32_t index)
+{
+ switch (index) {
+ case 0: return &descriptor;
+ default: return NULL;
+ }
+}
+
+} // extern "C"
diff --git a/src/filters.cc b/src/filters.cc
new file mode 100644
index 0000000..8c93696
--- /dev/null
+++ b/src/filters.cc
@@ -0,0 +1,113 @@
+/*
+ Copyright (C) 2004-2009 Fons Adriaensen <fons@kokkinizita.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; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+
+#include <string.h>
+#include "filters.h"
+#include "exp2ap.h"
+
+
+void Ladspa_Paramfilt::setport (PortIndex port, PortData *data)
+{
+ _port [port] = (float*)data;
+}
+
+
+void Ladspa_Paramfilt::active (bool act)
+{
+ int j;
+
+ if (! act) return;
+ _fade = 0;
+ _gain = 1;
+ for (j = 0; j < NSECT; j++) _sect [j].init ();
+}
+
+
+void Ladspa_Paramfilt::runproc (SampleCount len, bool add)
+{
+ int i, j, k;
+ float *aip = _port [AIP];
+ float *aop = _port [AOP];
+ float *p, sig [48];
+ float t, g, d;
+ float fgain;
+ float sfreq [NSECT];
+ float sband [NSECT];
+ float sgain [NSECT];
+
+ fgain = exp2ap (0.1661 * _port [GAIN][0]);
+ for (j = 0; j < NSECT; j++)
+ {
+ t = _port [SECT + 4 * j + Paramsect::FREQ][0] / _fsam;
+ if (t < 0.0002) t = 0.0002;
+ if (t > 0.4998) t = 0.4998;
+ sfreq [j] = t;
+ sband [j] = _port [SECT + 4 * j + Paramsect::BAND][0];
+ if (_port [SECT + 4 * j + Paramsect::SECT][0] > 0) sgain [j] = exp2ap (0.1661 * _port [SECT + 4 * j + Paramsect::GAIN][0]);
+ else sgain [j] = 1.0;
+ }
+
+ while (len)
+ {
+ k = (len > 48) ? 32 : len;
+
+ t = fgain;
+ g = _gain;
+ if (t > 1.25 * g) t = 1.25 * g;
+ else if (t < 0.80 * g) t = 0.80 * g;
+ _gain = t;
+ d = (t - g) / k;
+ for (i = 0; i < k; i++)
+ {
+ g += d;
+ sig [i] = g * aip [i];
+ }
+
+ for (j = 0; j < NSECT; j++) _sect [j].proc (k, sig, sfreq [j], sband [j], sgain [j]);
+
+ j = _fade;
+ g = j / 16.0;
+ p = 0;
+ if (_port [FILT][0] > 0)
+ {
+ if (j == 16) p = sig;
+ else ++j;
+ }
+ else
+ {
+ if (j == 0) p = aip;
+ else --j;
+ }
+ _fade = j;
+ if (p) memcpy (aop, p, k * sizeof (float));
+ else
+ {
+ d = (j / 16.0 - g) / k;
+ for (i = 0; i < k; i++)
+ {
+ g += d;
+ aop [i] = g * sig [i] + (1 - g) * aip [i];
+ }
+ }
+ aip += k;
+ aop += k;
+ len -= k;
+ }
+}
+
diff --git a/src/filters.h b/src/filters.h
new file mode 100644
index 0000000..3000870
--- /dev/null
+++ b/src/filters.h
@@ -0,0 +1,130 @@
+/*
+ Copyright (C) 2004-2009 Fons Adriaensen <fons@kokkinizita.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; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+
+#ifndef __FILTERS_H
+#define __FILTERS_H
+
+#include <math.h>
+#include "ladspaplugin.h"
+
+
+class Paramsect
+{
+public:
+
+ enum { SECT, FREQ, BAND, GAIN };
+
+ void init (void)
+ {
+ _f = 0.25f;
+ _b = _g = 1.0f;
+ _a = _s1 = _s2 = _z1 = _z2 = 0.0f;
+ }
+
+ void proc (int k, float *sig, float f, float b, float g)
+ {
+ float s1, s2, d1, d2, a, da, x, y;
+ bool u2 = false;
+
+ s1 = _s1;
+ s2 = _s2;
+ a = _a;
+ d1 = 0;
+ d2 = 0;
+ da = 0;
+
+ if (f != _f)
+ {
+ if (f < 0.5f * _f) f = 0.5f * _f;
+ else if (f > 2.0f * _f) f = 2.0f * _f;
+ _f = f;
+ _s1 = -cosf (6.283185f * f);
+ d1 = (_s1 - s1) / k;
+ u2 = true;
+ }
+
+ if (g != _g)
+ {
+ if (g < 0.5f * _g) g = 0.5f * _g;
+ else if (g > 2.0f * _g) g = 2.0f * _g;
+ _g = g;
+ _a = 0.5f * (g - 1.0f);
+ da = (_a - a) / k;
+ u2 = true;
+ }
+
+ if (b != _b)
+ {
+ if (b < 0.5f * _b) b = 0.5f * _b;
+ else if (b > 2.0f * _b) b = 2.0f * _b;
+ _b = b;
+ u2 = true;
+ }
+
+ if (u2)
+ {
+ b *= 7 * f / sqrtf (g);
+ _s2 = (1 - b) / (1 + b);
+ d2 = (_s2 - s2) / k;
+ }
+
+ while (k--)
+ {
+ s1 += d1;
+ s2 += d2;
+ a += da;
+ x = *sig;
+ y = x - s2 * _z2;
+ *sig++ -= a * (_z2 + s2 * y - x);
+ y -= s1 * _z1;
+ _z2 = _z1 + s1 * y;
+ _z1 = y + 1e-10f;
+ }
+ }
+
+private:
+
+ float _f, _b, _g;
+ float _s1, _s2, _a;
+ float _z1, _z2;
+};
+
+
+class Ladspa_Paramfilt : public LadspaPlugin
+{
+public:
+
+ enum { AIP, AOP, FILT, GAIN, SECT, NSECT = 4, NPORT = 20 };
+
+ Ladspa_Paramfilt (SampleRate fsam) : LadspaPlugin (fsam) {}
+ virtual void setport (PortIndex port, PortData *data);
+ virtual void active (bool act);
+ virtual void runproc (SampleCount len, bool add);
+ virtual ~Ladspa_Paramfilt (void) {}
+
+private:
+
+ float *_port [NPORT];
+ float _gain;
+ int _fade;
+ Paramsect _sect [NSECT];
+};
+
+
+#endif
diff --git a/src/filters_lv2.cc b/src/filters_lv2.cc
new file mode 100644
index 0000000..0696c38
--- /dev/null
+++ b/src/filters_lv2.cc
@@ -0,0 +1,56 @@
+/*
+ Copyright (C) 2012 David Robillard <d@drobilla.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; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include <stddef.h>
+
+#include "filters.h"
+#include "plugin_lv2.h"
+
+extern "C" {
+
+static LV2_Handle
+instantiate(const LV2_Descriptor* descriptor,
+ double rate,
+ const char* bundle_path,
+ const LV2_Feature* const* features)
+{
+ return new Ladspa_Paramfilt(rate);
+}
+
+static const LV2_Descriptor descriptor = {
+ "http://drobilla.net/plugins/fomp/parametric1",
+ instantiate,
+ connect_port,
+ activate,
+ run,
+ deactivate,
+ cleanup,
+ NULL
+};
+
+LV2_SYMBOL_EXPORT
+const LV2_Descriptor*
+lv2_descriptor(uint32_t index)
+{
+ switch (index) {
+ case 0: return &descriptor;
+ default: return NULL;
+ }
+}
+
+} // extern "C"
diff --git a/wscript b/wscript
index a2a35f7..042dbb8 100644
--- a/wscript
+++ b/wscript
@@ -73,9 +73,11 @@ def build(bld):
LIB_EXT = bld.env.pluginlib_EXT,
install_path = '${LV2DIR}/fomp.lv2')
- plugins = ['blvco',
+ plugins = ['autowah',
+ 'blvco',
'cs_chorus',
'cs_phaser',
+ 'filters',
'mvchpf24',
'mvclpf24']
for i in plugins: