LMMS
Loading...
Searching...
No Matches
Amp.h
Go to the documentation of this file.
1/*
2 Amp.h
3
4 Copyright 2002-9 Tim Goetze <tim@quitte.de>
5
6 http://quitte.de/dsp/
7
8 Oversampled tube amplifier emulation.
9
10*/
11/*
12 This program is free software; you can redistribute it and/or
13 modify it under the terms of the GNU General Public License
14 as published by the Free Software Foundation; either version 2
15 of the License, or (at your option) any later version.
16
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25 02111-1307, USA or point your web browser to http://www.gnu.org.
26*/
27
28#ifndef _AMP_H_
29#define _AMP_H_
30
31#include "dsp/util.h"
32#include "dsp/OnePole.h"
33#include "dsp/BiQuad.h"
34#include "dsp/TwelveAX7.h"
35#include "dsp/Roessler.h"
36
37#include "dsp/FIR.h"
38#include "dsp/sinc.h"
39#include "dsp/windows.h"
40
41#include "dsp/RBJ.h"
42#include "dsp/Eq.h"
43
44#include "dsp/ToneStack.h"
45
47: public Plugin
48{
49 public:
51
53
54 struct {
55 /* gain (remember current setting and fade to port setting in run) */
56 double g;
57 /* should also do this for temperature to remove another potential
58 * source of zippering, but that would be overkill, at the cost of
59 * at least one pow() per block. */
61
62 /* input is hipass-filtered first */
64
65 enum {
68 };
69
70 /* antialias filters */
73
76 down (FIR_SIZE, up.c)
77 { }
78
79 void init (bool adjust_downsampler = false);
80
82 {
83 return i_drive * (a - drive * fabs (a) * a);
84 }
85};
86
87/* /////////////////////////////////////////////////////////////////////// */
88
90: public AmpStub
91{
92 public:
93 template <sample_func_t F, int OVERSAMPLE>
94 void one_cycle (int frames);
95
97
98 public:
100
102
103 void init();
104 void activate()
105 {
106 current.g = 1;
107
108 filter.reset();
109 up.reset();
110 down.reset();
111 dc_blocker.reset();
112 }
113
114 void run (int n)
115 {
117 }
118
119 void run_adding (int n)
120 {
122 }
123};
124
125/* /////////////////////////////////////////////////////////////////////// */
126
128: public AmpStub
129{
130 public:
131 template <sample_func_t F, int OVERSAMPLE>
132 void one_cycle (int frames);
133
135
136 public:
138
140
141 void init();
142 void activate()
143 {
144 current.g = 1;
145
146 up.reset();
147 down.reset();
148 dc_blocker.reset();
149 filter.reset();
150 }
151
152 void run (int n)
153 {
155 }
156
157 void run_adding (int n)
158 {
160 }
161};
162
163/* /////////////////////////////////////////////////////////////////////// */
164
165typedef struct
166 {float center, Q, adjust;}
168
170{
171 public:
174 static PreampBand bands[4];
175
176 public:
177 void init (double _fs);
179
180 inline void
181 start_cycle (sample_t ** ports, double one_over_n)
182 {
183 for (int i = 0; i < 4; ++i)
184 {
185 if (*ports[i] == eq_gain[i])
186 {
187 eq.gf[i] = 1;
188 continue;
189 }
190
191 eq_gain[i] = *ports [i];
192
193 double want = get_band_gain (i, eq_gain[i]);
194 eq.gf[i] = pow (want / eq.gain[i], one_over_n);
195 }
196 }
197
198 double get_band_gain (int i, double g);
199 void set_band_gain (int i, float g);
200
202 {
203 return eq.process (x);
204 }
205};
206
207/* /////////////////////////////////////////////////////////////////////// */
208
210: public PreampIII
211{
212 public:
214
215 template <sample_func_t F, int OVERSAMPLE>
216 void one_cycle (int frames);
217
218 public:
220
222
223 void init();
224 void activate();
225
226 void run (int n)
227 {
229 }
230
231 void run_adding (int n)
232 {
234 }
235};
236
237/* /////////////////////////////////////////////////////////////////////// */
238
239class AmpIV
240: public AmpStub
241{
242 public:
244
245 template <sample_func_t F, int OVERSAMPLE>
246 void one_cycle (int frames);
247
248 public:
250
252
253 void init();
254 void activate()
255 {
256 current.g = 1;
257
258 tone.activate (ports + 3);
259
260 up.reset();
261 down.reset();
262 dc_blocker.reset();
263 }
264
265 void run (int n)
266 {
268 }
269
270 void run_adding (int n)
271 {
273 }
274};
275
276/* /////////////////////////////////////////////////////////////////////// */
277
278class AmpV
279: public AmpStub
280{
281 public:
282 template <sample_func_t F, int OVERSAMPLE>
283 void one_cycle (int frames);
284
286
288
289 /* supply voltage sag */
292
293 public:
295
297
298 void init();
299 void activate()
300 {
301 current.g = 1;
302
303 for (int i = 0; i < 2; ++i)
304 filter[i].reset(),
305 power_cap[i].reset();
306
307 up.reset();
308 down.reset();
309 dc_blocker.reset();
310
311 cut = 2;
312 supply = 0.;
313
314 tone = -1; /* causes initialisation of the filter at first cycle */
315 }
316
317 void run (int n)
318 {
320 }
321
322 void run_adding (int n)
323 {
325 }
326};
327
328/* /////////////////////////////////////////////////////////////////////// */
329
331: public AmpStub
332{
333 public:
335
336 template <sample_func_t F, int OVERSAMPLE>
337 void one_cycle (int frames);
338
340
341 /* supply voltage sag */
344
345 public:
347
349
350 void init();
351 void activate()
352 {
353 current.g = 1;
354
355 for (int i = 0; i < 2; ++i)
356 power_cap[i].reset();
357
358 up.reset();
359 down.reset();
360 dc_blocker.reset();
361
362 cut = 2;
363 supply = 0.;
364 }
365
366 void run (int n)
367 {
369 }
370
371 void run_adding (int n)
372 {
374 }
375};
376
377#endif /* _AMP_H_ */
uint8_t a
Definition Spc_Cpu.h:141
LADSPA_Data sample_t
Definition basics.h:100
Definition Amp.h:129
void activate()
Definition Amp.h:142
void one_cycle(int frames)
sample_t adding_gain
Definition Amp.h:139
void run_adding(int n)
Definition Amp.h:157
void init()
DSP::BiQuad filter
Definition Amp.h:134
void run(int n)
Definition Amp.h:152
static PortInfo port_info[]
Definition Amp.h:137
Definition Amp.h:241
void activate()
Definition Amp.h:254
void run(int n)
Definition Amp.h:265
void one_cycle(int frames)
ToneControls tone
Definition Amp.h:243
static PortInfo port_info[]
Definition Amp.h:249
void run_adding(int n)
Definition Amp.h:270
sample_t adding_gain
Definition Amp.h:251
void init()
DSP::FIRUpsampler up
Definition Amp.h:71
sample_t i_drive
Definition Amp.h:52
void init(bool adjust_downsampler=false)
double g
Definition Amp.h:56
struct AmpStub::@072353315060060136134103160115162061312042375214 current
@ OVERSAMPLE
Definition Amp.h:66
@ FIR_SIZE
Definition Amp.h:67
DSP::FIR down
Definition Amp.h:72
sample_t power_transfer(sample_t a)
Definition Amp.h:81
AmpStub()
Definition Amp.h:74
DSP::TwelveAX7_3 tube
Definition Amp.h:50
sample_t drive
Definition Amp.h:52
DSP::OnePoleHP dc_blocker
Definition Amp.h:63
Definition Amp.h:280
DSP::BiQuad filter[3]
Definition Amp.h:285
void run(int n)
Definition Amp.h:317
void one_cycle(int frames)
void run_adding(int n)
Definition Amp.h:322
void init()
static PortInfo port_info[]
Definition Amp.h:294
DSP::BiQuad power_cap[2]
Definition Amp.h:291
sample_t cut
Definition Amp.h:287
sample_t adding_gain
Definition Amp.h:296
sample_t tone
Definition Amp.h:287
sample_t supply
Definition Amp.h:290
void activate()
Definition Amp.h:299
Definition Amp.h:332
sample_t adding_gain
Definition Amp.h:348
void one_cycle(int frames)
sample_t supply
Definition Amp.h:342
void init()
void run_adding(int n)
Definition Amp.h:371
static PortInfo port_info[]
Definition Amp.h:346
void run(int n)
Definition Amp.h:366
sample_t cut
Definition Amp.h:339
sample_t tone
Definition Amp.h:339
DSP::BiQuad power_cap[2]
Definition Amp.h:343
DSP::ToneStack tonestack
Definition Amp.h:334
void activate()
Definition Amp.h:351
Definition BiQuad.h:34
Definition Eq.h:62
Definition FIR.h:42
Definition FIR.h:161
Definition OnePole.h:80
Definition ToneStack.h:48
Definition TwelveAX7.h:152
Definition basics.h:174
sample_t ** ports
Definition basics.h:182
Definition Amp.h:91
void run(int n)
Definition Amp.h:114
void run_adding(int n)
Definition Amp.h:119
DSP::BiQuad filter
Definition Amp.h:96
void one_cycle(int frames)
void activate()
Definition Amp.h:104
sample_t adding_gain
Definition Amp.h:101
void init()
static PortInfo port_info[]
Definition Amp.h:99
Definition Amp.h:211
static PortInfo port_info[]
Definition Amp.h:219
void init()
void one_cycle(int frames)
sample_t adding_gain
Definition Amp.h:221
ToneControls tone
Definition Amp.h:213
void run_adding(int n)
Definition Amp.h:231
void activate()
void run(int n)
Definition Amp.h:226
Definition Amp.h:170
sample_t process(sample_t x)
Definition Amp.h:201
static PreampBand bands[4]
Definition Amp.h:174
sample_t eq_gain[4]
Definition Amp.h:172
void set_band_gain(int i, float g)
DSP::Eq< 4 > eq
Definition Amp.h:173
void start_cycle(sample_t **ports, double one_over_n)
Definition Amp.h:181
void activate(sample_t **)
double get_band_gain(int i, double g)
void init(double _fs)
int g
Definition inflate.c:1573
register unsigned i
Definition inflate.c:1575
unsigned x[BMAX+1]
Definition inflate.c:1586
Definition basics.h:94
Definition Amp.h:166
float adjust
Definition Amp.h:166
float center
Definition Amp.h:166
float Q
Definition Amp.h:166
int n
Definition crypt.c:458
return c
Definition crypt.c:175