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.
26
extern float exp2ap (float);
29
#define N (MIXLEN * PERIOD)
32
void Diffuser::init (int size, float c)
35
_data = new float [size];
36
memset (_data, 0, size * sizeof (float));
42
void Diffuser::fini (void)
48
float Asection::_refl [16] =
50
0.250f, 0.440f, 0.615f, 0.940f,
51
0.200f, 0.370f, 0.560f, 0.900f,
52
0.230f, 0.400f, 0.500f, 0.920f,
53
0.280f, 0.460f, 0.690f, 0.960f
57
Asection::Asection (float fsam) : _fsam (fsam)
59
_base = new float [NCHANN * N];
60
memset (_base, 0, NCHANN * N * sizeof (float));
63
_sw = _sx = _sy = 0.0f;
64
_dif0.init ((int)(fsam * 0.017f), 0.5f);
65
_dif1.init ((int)(fsam * 0.029f), 0.5f);
66
_dif2.init ((int)(fsam * 0.023f), 0.5f);
67
_dif3.init ((int)(fsam * 0.013f), 0.5f);
69
_apar [AZIMUTH]._val = 0.0f;
70
_apar [AZIMUTH]._min = -0.5f;
71
_apar [AZIMUTH]._max = 0.5f;
72
_apar [STWIDTH]._val = 0.8f;
73
_apar [STWIDTH]._min = 0.0f;
74
_apar [STWIDTH]._max = 1.0f;
75
_apar [DIRECT]._val = 0.56f;
76
_apar [DIRECT]._min = 0.00f;
77
_apar [DIRECT]._max = 1.00f;
78
_apar [REFLECT]._val = 0.25f;
79
_apar [REFLECT]._min = 0.00f;
80
_apar [REFLECT]._max = 1.00f;
81
_apar [REVERB]._val = 0.32f;
82
_apar [REVERB]._min = 0.00f;
83
_apar [REVERB]._max = 1.00f;
87
Asection::~Asection (void)
97
void Asection::set_size (float time)
103
if (r > N - PERIOD) r = N - PERIOD;
104
for (i = 0; i < 16; i++)
106
d = (int)(r * _refl [i]);
107
d = (_offs0 - d * PERIOD) & (N - 1);
108
_offs [i] = d + (i >> 2) * N;
113
void Asection::process (float vol, float *W, float *X, float *Y, float *R)
116
float s, d, g, gw, gr, gx1, gy1, gx2, gy2;
117
float *p, t0, t1, t2, t3;
121
gw = vol * _apar [DIRECT]._val;
122
g = 0.45f * _apar [STWIDTH]._val;
123
s = 0.5f + g * (1 - g);
127
g = 0.25f * _apar [STWIDTH]._val;
128
s = 0.5f + g * (1 - g);
133
gr = 0.5f * _apar [REVERB]._val;
134
for (i = 0; i < PERIOD; i++)
141
s = t0 + t1 + t2 + t3;
144
x [i] = gx1 * (t3 + t0) + gx2 * (t2 + t1);
145
y [i] = gy1 * (t3 - t0) + gy2 * (t2 - t1);
148
gr = vol * _apar [REFLECT]._val;
150
for (i = 0; i < PERIOD; i++)
152
t0 = _dif0.process (p [_offs [1]] + p [_offs [5]] + p [_offs [11]] + p [_offs [15]] + 1e-20f);
153
t1 = _dif1.process (p [_offs [0]] + p [_offs [4]] + p [_offs [10]] + p [_offs [14]] + 1e-20f);
154
t2 = _dif2.process (p [_offs [2]] + p [_offs [6]] + p [_offs [8]] + p [_offs [12]] + 2e-20f);
155
t3 = _dif3.process (p [_offs [3]] + p [_offs [7]] + p [_offs [9]] + p [_offs [13]] + 2e-20f);
157
s = t0 + t1 + t2 + t3;
158
_sw += 0.5f * (s - _sw);
159
_sx += 0.5f * (0.4f * (t0 + t3) + 0.6f * (t2 + t1) - _sx);
160
_sy += 0.5f * (0.9f * (t0 - t3) + 0.8f * (t2 - t1) - _sy);
166
g = 6.283184f * _apar [AZIMUTH]._val;
169
for (i = 0; i < PERIOD; i++)
171
X [i] += gx1 * x [i] + gy1 * y [i];
172
Y [i] += gx1 * y [i] - gy1 * x [i];
175
_offs0 = (_offs0 + PERIOD) & (N - 1);
176
for (i = 0; i < 16; i++) _offs [i] = ((_offs [i] + PERIOD) & (N - 1)) + (i >> 2) * N;
178
memset (p + 0 * N, 0, PERIOD * sizeof (float));
179
memset (p + 1 * N, 0, PERIOD * sizeof (float));
180
memset (p + 2 * N, 0, PERIOD * sizeof (float));
181
memset (p + 3 * N, 0, PERIOD * sizeof (float));