2
Copyright (C) 2003-2008 Fons Adriaensen <fons@kokkinizita.net>
4
This program is free software; you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation; either version 2 of the License, or
7
(at your option) any later version.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public License
15
along with this program; if not, write to the Free Software
16
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22
#include "cs_phaser.h"
26
void Ladspa_CS_phaser1::setport (PortIndex port, PortData *data)
28
_port [port] = (float*)data;
32
void Ladspa_CS_phaser1::active (bool act)
37
for (int i = 0; i < NSECT; i++) _c [i] = 0;
42
void Ladspa_CS_phaser1::runproc (SampleCount len, bool add)
45
float *p0, *p1, *p2, *p3, *p4;
47
float d, t, w, dw, x, z;
55
ns = (int)(floor (_port [6][0] + 0.5));
56
g0 = exp2ap (0.1661f * _port [5][0]);
66
k = (len > 24) ? 16 : len;
72
t = (exp2ap (_port [8][0] * *p3 + _port [7][0] + *p2 + 9.683f) + _port [9][0] * *p4 * 1000.0f) / _fsam;
73
if (t < 0.0f) t = 0.0f;
74
if (t > 1.5f) t = 1.5f;
75
t = (sinf (t) - 1) / cosf (t) + 1;
83
z = 4 * tanhf (0.25f * z);
84
for (i = 0; i < ns; i++)
93
if (add) *p1++ += t * _gain;
105
void Ladspa_CS_phaser1lfo::setport (PortIndex port, PortData *data)
107
_port [port] = (float*)data;
111
void Ladspa_CS_phaser1lfo::active (bool act)
116
_z = _w = _v = _p = 0;
117
for (int i = 0; i < NSECT; i++) _c [i] = 0;
124
void Ladspa_CS_phaser1lfo::runproc (SampleCount len, bool add)
128
float g0, gf, gi, gm;
129
float d, t, w, v, x, z;
134
ns = (int)(floor (_port [3][0] + 0.5));
135
g0 = exp2ap (0.1661f * _port [2][0]);
149
_p += 2 * DSUB * _port [5][0] / _fsam;
151
x = 0.999f * _port [6][0];
153
if (d < 0) t = 0.5f + d / (1 + x);
154
else t = 0.5f - d / (1 - x);
155
t = exp2ap (_port [7][0] * t + _port [4][0] + 9.683f) / _fsam;
156
if (t < 0.0f) t = 0.0f;
157
if (t > 1.5f) t = 1.5f;
158
t = (sinf (t) - 1) / cosf (t) + 1;
162
k = (_gi < len) ? _gi : len;
169
z = 4 * tanhf (0.25f * z);
170
for (i = 0; i < ns; i++)
179
if (add) *p1++ += t * _gain;