LMMS
Loading...
Searching...
No Matches
Chorus.h
Go to the documentation of this file.
1/*
2 Chorus.h
3
4 Copyright 2004-5 Tim Goetze <tim@quitte.de>
5
6 http://quitte.de/dsp/
7
8 mono and stereo chorus/flanger units, traditional designs and some
9 differentiated a bit further.
10
11*/
12/*
13 This program is free software; you can redistribute it and/or
14 modify it under the terms of the GNU General Public License
15 as published by the Free Software Foundation; either version 2
16 of the License, or (at your option) any later version.
17
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
26 02111-1307, USA or point your web browser to http://www.gnu.org.
27*/
28
29#ifndef _CHORUS_H_
30#define _CHORUS_H_
31
32#include "dsp/Sine.h"
33#include "dsp/Roessler.h"
34#include "dsp/Lorenz.h"
35#include "dsp/Delay.h"
36#include "dsp/OnePole.h"
37#include "dsp/BiQuad.h"
38#include "dsp/RBJ.h"
39
41: public Plugin
42{
43 public:
45};
46
48: public ChorusStub
49{
50 public:
54
55 template <sample_func_t>
56 void one_cycle (int frames);
57
58 public:
60
61 void init()
62 {
63 rate = .15;
64 delay.init ((int) (.040 * fs));
65 }
66
67 void activate()
68 {
69 time = 0;
70 width = 0;
71
72 rate = *ports[3];
73
74 delay.reset();
75 tap.reset();
76
77 lfo.set_f (rate, fs, 0);
78 }
79
80 void run (int n)
81 {
83 }
84
85 void run_adding (int n)
86 {
88 }
89};
90
92: public ChorusStub
93{
94 public:
97
99
100 struct {
104
105 template <sample_func_t>
106 void one_cycle (int frames);
107
108 public:
110
111 void init()
112 {
113 rate = .15;
114 phase = .5; /* pi */
115
116 delay.init ((int) (.040 * fs));
117 }
118
119 void activate()
120 {
121 time = 0;
122 width = 0;
123
124 delay.reset();
125
126 left.tap.reset();
127 right.tap.reset();
128
129 left.lfo.set_f (rate, fs, 0);
130 right.lfo.set_f (rate, fs, phase * M_PI);
131 }
132
133 void run (int n)
134 {
136 }
137
138 void run_adding (int n)
139 {
141 }
142};
143
144/* //////////////////////////////////////////////////////////////////////// */
145
146#define FRACTAL_RATE 0.02
147
148/* fractally modulated Chorus units */
149
151{
152 public:
156
157 void init (double fs)
158 {
159 lp.set_f (30. / fs);
160 f1.init (.001, frandom());
161 f2.init (.001, frandom());
162 }
163
165 {
166 f1.set_rate (r * FRACTAL_RATE);
167 f2.set_rate (3.3 * r * FRACTAL_RATE);
168 }
169
170 /* t = time, w = width, should inline nicely */
171 sample_t get (DSP::Delay & d, double t, double w)
172 {
173 double m = lp.process (f1.get() + .3 * f2.get());
174 return d.get_cubic (t + w * m);
175 }
176};
177
179: public ChorusStub
180{
181 public:
182 enum {
184 };
185
189
190 template <sample_func_t>
191 void one_cycle (int frames);
192
194 {
195 rate = r;
196 for (int i = 0; i < Taps; ++i)
197 {
198 taps[i].set_rate (rate * (i * FRACTAL_RATE) / Taps);
199 // fprintf (stderr, "[%d] %.3f\n", i, (rate * (i * FRACTAL_RATE) / Taps));
200 }
201 }
202
203 public:
205
206 void init()
207 {
208 delay.init ((int) (.040 * fs));
209 for (int i = 0; i < Taps; ++i)
210 taps[i].init (fs);
211 DSP::RBJ::HiShelve (1000. / fs, 1., 6, filter.a, filter.b);
212 }
213
214 void activate()
215 {
216 time = 0;
217 width = 0;
218
219 set_rate (*ports[3]);
220
221 delay.reset();
222 filter.reset();
223 }
224
225 void run (int n)
226 {
228 }
229
230 void run_adding (int n)
231 {
233 }
234};
235
237: public ChorusStub
238{
239 public:
242
244
245 struct {
250
251 template <sample_func_t>
252 void one_cycle (int frames);
253
255 {
256 rate = r;
257 left.fractal.set_rate (rate * FRACTAL_RATE);
258 right.fractal.set_rate (rate * FRACTAL_RATE);
259 left.lfo_lp.set_f (3. / fs);
260 right.lfo_lp.set_f (3. / fs);
261 }
262
263 public:
266
267 void init()
268 {
269 phase = .5; /* pi */
270
271 delay.init ((int) (.040 * fs));
272
273 left.fractal.init (.001, frandom());
274 right.fractal.init (.001, frandom());
275 }
276
277 void activate()
278 {
279 time = 0;
280 width = 0;
281
282 delay.reset();
283
284 left.tap.reset();
285 right.tap.reset();
286
287 set_rate (*ports[3]);
288 }
289
290 void run (int n)
291 {
293 }
294
295 void run_adding (int n)
296 {
298 }
299};
300
301#endif /* _CHORUS_H_ */
#define FRACTAL_RATE
Definition Chorus.h:146
LADSPA_Data sample_t
Definition basics.h:100
static float frandom()
Definition basics.h:143
Definition Chorus.h:49
void run(int n)
Definition Chorus.h:80
void activate()
Definition Chorus.h:67
DSP::DelayTapA tap
Definition Chorus.h:53
DSP::Delay delay
Definition Chorus.h:52
void run_adding(int n)
Definition Chorus.h:85
DSP::Sine lfo
Definition Chorus.h:51
static PortInfo port_info[]
Definition Chorus.h:59
void init()
Definition Chorus.h:61
void one_cycle(int frames)
Definition Chorus.h:180
FracTap taps[Taps]
Definition Chorus.h:186
void activate()
Definition Chorus.h:214
void set_rate(sample_t r)
Definition Chorus.h:193
DSP::Delay delay
Definition Chorus.h:188
void one_cycle(int frames)
static PortInfo port_info[]
Definition Chorus.h:204
void run_adding(int n)
Definition Chorus.h:230
DSP::BiQuad filter
Definition Chorus.h:187
@ Taps
Definition Chorus.h:183
void init()
Definition Chorus.h:206
void run(int n)
Definition Chorus.h:225
Definition Chorus.h:42
sample_t width
Definition Chorus.h:44
sample_t rate
Definition Chorus.h:44
sample_t time
Definition Chorus.h:44
Definition BiQuad.h:34
Definition Delay.h:41
Definition Delay.h:138
Definition Lorenz.h:34
Definition OnePole.h:34
Definition RBJ.h:262
Definition Roessler.h:34
Definition Sine.h:34
Definition Chorus.h:151
DSP::Lorenz f1
Definition Chorus.h:153
void set_rate(sample_t r)
Definition Chorus.h:164
DSP::OnePoleLP lp
Definition Chorus.h:155
sample_t get(DSP::Delay &d, double t, double w)
Definition Chorus.h:171
DSP::Roessler f2
Definition Chorus.h:154
void init(double fs)
Definition Chorus.h:157
Definition basics.h:174
sample_t ** ports
Definition basics.h:182
double fs
Definition basics.h:176
Definition Chorus.h:93
static PortInfo port_info[]
Definition Chorus.h:109
struct StereoChorusI::@310030130237147052235100216076150067332324357105 right
void run(int n)
Definition Chorus.h:133
void one_cycle(int frames)
DSP::DelayTapA tap
Definition Chorus.h:102
struct StereoChorusI::@310030130237147052235100216076150067332324357105 left
sample_t phase
Definition Chorus.h:96
void activate()
Definition Chorus.h:119
sample_t rate
Definition Chorus.h:95
void init()
Definition Chorus.h:111
void run_adding(int n)
Definition Chorus.h:138
DSP::Sine lfo
Definition Chorus.h:101
DSP::Delay delay
Definition Chorus.h:98
Definition Chorus.h:238
static PortInfo port_info[]
Definition Chorus.h:264
void activate()
Definition Chorus.h:277
void set_rate(sample_t r)
Definition Chorus.h:254
sample_t adding_gain
Definition Chorus.h:265
struct StereoChorusII::@040173003236106266066310112320333220012103223047 left
sample_t phase
Definition Chorus.h:241
void run(int n)
Definition Chorus.h:290
DSP::Roessler fractal
Definition Chorus.h:246
sample_t rate
Definition Chorus.h:240
void run_adding(int n)
Definition Chorus.h:295
DSP::OnePoleLP lfo_lp
Definition Chorus.h:247
DSP::DelayTapA tap
Definition Chorus.h:248
void init()
Definition Chorus.h:267
DSP::Delay delay
Definition Chorus.h:243
void one_cycle(int frames)
struct StereoChorusII::@040173003236106266066310112320333220012103223047 right
#define M_PI
Definition compat.h:149
UINT_D64 w
Definition inflate.c:942
unsigned * m
Definition inflate.c:1559
struct huft * t
Definition inflate.c:943
unsigned d
Definition inflate.c:940
register unsigned i
Definition inflate.c:1575
struct @113205115357366127300225113341150224053346037032::@137033172036070230260373056156374243321245367362 left
struct @113205115357366127300225113341150224053346037032::@137033172036070230260373056156374243321245367362 right
Definition basics.h:94
int n
Definition crypt.c:458
int r
Definition crypt.c:458