diff options
author | David Robillard <d@drobilla.net> | 2012-08-20 05:16:04 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-08-20 05:16:04 +0000 |
commit | 734a9f490f2f8cb4552c71bfac8fc779f836c436 (patch) | |
tree | 34d286b3e8cbd291267ebe3ae6804ba52959c68b /src/mvchpf24.cc | |
download | fomp.lv2-734a9f490f2f8cb4552c71bfac8fc779f836c436.tar.gz fomp.lv2-734a9f490f2f8cb4552c71bfac8fc779f836c436.tar.bz2 fomp.lv2-734a9f490f2f8cb4552c71bfac8fc779f836c436.zip |
Add fomp.lv2, a port of Fons' modular-oriented LADSPA plugins to LV2.
git-svn-id: http://svn.drobilla.net/lad/trunk/plugins/fomp.lv2@4727 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/mvchpf24.cc')
-rw-r--r-- | src/mvchpf24.cc | 123 |
1 files changed, 123 insertions, 0 deletions
diff --git a/src/mvchpf24.cc b/src/mvchpf24.cc new file mode 100644 index 0000000..d63155b --- /dev/null +++ b/src/mvchpf24.cc @@ -0,0 +1,123 @@ +/* + Copyright (C) 2003-2008 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 <stdio.h> +#include <math.h> +#include "mvchpf24.h" +#include "exp2ap.h" + + +void Ladspa_Mvchpf1::setport (PortIndex port, PortData *data) +{ + _port [port] = (float*)data; +} + + +void Ladspa_Mvchpf1::active (bool act) +{ + _c1 = _c2 = _c3 = _c4 = _x = 0; + _w = 1e5; +} + + +void Ladspa_Mvchpf1::runproc (SampleCount len, bool add) +{ + int k; + float *p0, *p1, *p2, *p3; + float c1, c2, c3, c4; + float g0, g1, d, w, dw, t, x, y; + + p0 = _port [AINP]; + p1 = _port [AOUT]; + p2 = _port [AFREQ] - 1; + p3 = _port [AFMOD] - 1; + g0 = exp2ap (0.1661f * _port [CINP][0]) / 4; + g1 = exp2ap (0.1661f * _port [COUT][0]) * 4; + if (add) g1 *= _gain; + + c1 = _c1; + c2 = _c2; + c3 = _c3; + c4 = _c4; + w = _w; + x = _x; + + do + { + k = (len > 24) ? 16 : len; + p2 += k; + p3 += k; + len -= k; + + t = _fsam / exp2ap (_port [CFMOD][0] * *p3 + *p2 + _port [CFREQ][0] + 9.2f); + if (t < 2) t = 2; + dw = (t - w) / k; + + while (k--) + { + w += dw; + + x = y = *p0++ * g0 - 0.3f * x; + + d = x - c1 + 1e-10f; + t = d * d; + d *= (1 + t) / (w + t); + c1 += d; + x -= c1; + c1 += d; + + d = x - c2 + 1e-10f; + t = d * d; + d *= (1 + t) / (w + t); + c2 += d; + x -= c2; + c2 += d; + + d = x - c3 + 1e-10f; + t = d * d; + d *= (1 + t) / (w + t); + c3 += d; + x -= c3; + c3 += d; + + d = x - c4 + 1e-10f; + t = d * d; + d *= (1 + t) / (w + t); + c4 += d; + x -= c4; + c4 += d; + + if (add) *p1++ += g1 * x; + else *p1++ = g1 * x; + + x -= y; + } + } + while (len); + + _c1 = c1; + _c2 = c2; + _c3 = c3; + _c4 = c4; + _w = w; + _x = x; +} + + + |