3
Copyright (C) 2000 Jeff Tranter
8
This library is free software; you can redistribute it and/or
9
modify it under the terms of the GNU Library General Public
10
License as published by the Free Software Foundation; either
11
version 2 of the License, or (at your option) any later version.
13
This library is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
Library General Public License for more details.
18
You should have received a copy of the GNU Library General Public License
19
along with this library; see the file COPYING.LIB. If not, write to
20
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21
Boston, MA 02111-1307, USA.
26
#include "artsmodules.h"
27
#include "stdsynthmodule.h"
31
class Synth_FX_CFLANGER_impl : virtual public Synth_FX_CFLANGER_skel,
32
virtual public StdSynthModule
37
static const int SAMPLINGRATE = 44100;
38
static const int MAXDELAY = SAMPLINGRATE;
45
Synth_FX_CFLANGER_impl()
47
dbuffer=new float[MAXDELAY];
49
~Synth_FX_CFLANGER_impl()
54
float mintime() { return _mintime; }
56
void mintime(float newMintime) { _mintime = newMintime; }
58
float maxtime() { return _maxtime; }
60
void maxtime(float newMaxtime) { _maxtime = newMaxtime; }
64
center = (_maxtime + _mintime) / 2;
65
range = _maxtime - center;
66
for (int i=0; i<MAXDELAY; i++)
71
void calculateBlock(unsigned long samples)
74
float delay, floor_delay;
75
long start_pos, end_pos;
76
float start_val, end_val;
78
for(i=0; i<samples; i++)
80
dbuffer[dbpos] = invalue[i];
81
// Delaytime i.e. = 35ms + (+/- LFO[-1 bis 1] * 15ms) / 1000 * 44100
82
delay = ((center + (lfo[i] * range)) / 1000.0) * (float) SAMPLINGRATE;
83
floor_delay = floor(delay);
84
start_pos = dbpos - (long)(floor_delay);
85
end_pos = start_pos-1;
86
if (start_pos < 0) start_pos += MAXDELAY; // wrapping exception
87
if (end_pos < 0) end_pos += MAXDELAY;
88
start_val = dbuffer[start_pos];
89
end_val = dbuffer[end_pos];
90
outvalue[i] = start_val + ((delay - floor_delay) * (end_val - start_val));
92
if (dbpos == MAXDELAY) dbpos = 0;
97
REGISTER_IMPLEMENTATION(Synth_FX_CFLANGER_impl);