-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGenesis.h
executable file
·531 lines (522 loc) · 10.9 KB
/
Genesis.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
#ifndef __GENESIS__
#define __GENESIS__
#define SR (44100.f) //sample rate
#define F_PI (3.14159f);
#include "IPlug_include_in_plug_hdr.h"
#include <math.h>
//#include "filter.h"
//#include "Effects.h"
class LP6 {
public:
LP6() :
cutoff(0.1),
resonance(0.0),
buf0(0.0)
{
calculateFeedbackAmount();
};
double process(double inputValue);
inline void set(double newCutoff) { cutoff = newCutoff; calculateFeedbackAmount(); };
inline void setResonance(double newResonance) { resonance = newResonance; calculateFeedbackAmount(); };
private:
double cutoff;
double resonance;
double feedbackAmount;
inline void calculateFeedbackAmount() { feedbackAmount = resonance + resonance/(1.0 - cutoff); }
double buf0;
};
class LP12 {
public:
LP12() :
cutoff(0.1),
resonance(0.0),
buf0(0.0),
buf1(0.0)
{
calculateFeedbackAmount();
};
double process(double inputValue);
inline void set(double newCutoff) { cutoff = newCutoff; calculateFeedbackAmount(); };
inline void setResonance(double newResonance) { resonance = newResonance; calculateFeedbackAmount(); };
private:
double cutoff;
double resonance;
double feedbackAmount;
inline void calculateFeedbackAmount() { feedbackAmount = resonance + resonance/(1.0 - cutoff); }
double buf0;
double buf1;
};
class LP24 {
public:
LP24() :
cutoff(0.1),
resonance(0.0),
buf0(0.0),
buf1(0.0),
buf2(0.0),
buf3(0.0)
{
calculateFeedbackAmount();
};
double process(double inputValue);
inline void set(double newCutoff) { cutoff = newCutoff; calculateFeedbackAmount(); };
inline void setResonance(double newResonance) { resonance = newResonance; calculateFeedbackAmount(); };
private:
double cutoff;
double resonance;
double feedbackAmount;
inline void calculateFeedbackAmount() { feedbackAmount = resonance + resonance/(1.0 - cutoff); }
double buf0;
double buf1;
double buf2;
double buf3;
};
class LP48 {
public:
LP48() :
cutoff(0.1),
resonance(0.0),
buf0(0.0),
buf1(0.0),
buf2(0.0),
buf3(0.0),
buf4(0.0),
buf5(0.0),
buf6(0.0),
buf7(0.0)
{
calculateFeedbackAmount();
};
double process(double inputValue);
inline void set(double newCutoff) { cutoff = newCutoff; calculateFeedbackAmount(); };
inline void setResonance(double newResonance) { resonance = newResonance; calculateFeedbackAmount(); };
private:
double cutoff;
double resonance;
double feedbackAmount;
inline void calculateFeedbackAmount() { feedbackAmount = resonance + resonance/(1.0 - cutoff); }
double buf0;
double buf1;
double buf2;
double buf3;
double buf4;
double buf5;
double buf6;
double buf7;
};
class HP12 {
public:
HP12() :
cutoff(0.1),
resonance(0.0),
buf0(0.0),
buf1(0.0)
{
calculateFeedbackAmount();
};
double process(double inputValue);
inline void set(double newCutoff) { cutoff = newCutoff; calculateFeedbackAmount(); };
inline void setResonance(double newResonance) { resonance = newResonance; calculateFeedbackAmount(); };
private:
double cutoff;
double resonance;
double feedbackAmount;
inline void calculateFeedbackAmount() { feedbackAmount = resonance + resonance/(1.0 - cutoff); }
double buf0;
double buf1;
};
class HP24 {
public:
HP24() :
cutoff(0.1),
resonance(0.0),
buf0(0.0),
buf1(0.0),
buf2(0.0),
buf3(0.0)
{
calculateFeedbackAmount();
};
double process(double inputValue);
inline void set(double newCutoff) { cutoff = newCutoff; calculateFeedbackAmount(); };
inline void setResonance(double newResonance) { resonance = newResonance; calculateFeedbackAmount(); };
private:
double cutoff;
double resonance;
double feedbackAmount;
inline void calculateFeedbackAmount() { feedbackAmount = resonance + resonance/(1.0 - cutoff); }
double buf0;
double buf1;
double buf2;
double buf3;
};
class HP48 {
public:
HP48() :
cutoff(0.1),
resonance(0.0),
buf0(0.0),
buf1(0.0),
buf2(0.0),
buf3(0.0),
buf4(0.0),
buf5(0.0),
buf6(0.0),
buf7(0.0)
{
calculateFeedbackAmount();
};
double process(double inputValue);
inline void set(double newCutoff) { cutoff = newCutoff; calculateFeedbackAmount(); };
inline void setResonance(double newResonance) { resonance = newResonance; calculateFeedbackAmount(); };
private:
double cutoff;
double resonance;
double feedbackAmount;
inline void calculateFeedbackAmount() { feedbackAmount = resonance + resonance/(1.0 - cutoff); }
double buf0;
double buf1;
double buf2;
double buf3;
double buf4;
double buf5;
double buf6;
double buf7;
};
class Notch {
public:
Notch() :
cutoff(0.1),
resonance(1.0),
buf0(0.0),
buf1(0.0),
buf2(0.0),
buf3(0.0)
{
calculateFeedbackAmount();
};
double process(double inputValue);
inline void set(double newCutoff) { cutoff = newCutoff; calculateFeedbackAmount(); };
inline void setResonance(double newResonance) { resonance = newResonance; calculateFeedbackAmount(); };
private:
double cutoff;
double resonance;
double feedbackAmount;
inline void calculateFeedbackAmount() { feedbackAmount = resonance + resonance / (1.0 - cutoff); }
double buf0;
double buf1;
double buf2;
double buf3;
};
class Eq3{
public:
Eq3():
lg(0.25),
mg(0.125),
hg(4.0)
{
lf.setResonance(0.0);
mf1.setResonance(0.0);
mf2.setResonance(0.0);
hf.setResonance(0.0);
}
double process(double inputValue);
void set(int sampleRate);
private:
LP24 lf;
HP24 mf1;
LP24 mf2;
HP24 hf;
double lg;
double mg;
double hg;
};
class Clipper {
public:
double process(double inputValue);
private:
double k;
};
class LFO {
public:
LFO() :
out(0.0),
mPI(2 * acos(0.0)),
mFrequency(0.00001),
mPhase(0.0),
mSampleRate(44100.0) {
updateIncrement();
};
void setFrequency(double Frequency);
void setSampleRate(double sampleRate);
void setPhase(double phase);
double process(double inputValue);
private:
const double mPI;
double mFrequency;
double mPhase;
double mSampleRate;
double mPhaseIncrement;
void updateIncrement();
double out;
};
class Compressor{
public:
Compressor():
peakOutput(0.0),
peakB0Attack(1.0),
outputGain(0.0),
dynamicsAttackTime(0.0),
dynamicsReleaseTime(0.5),
dynamicsOutputGain(0.0) {
set(44100);
};
void set(double sampleRate);
double dynamics(double inputGain);
double peakFinder(double inputValue);
private:
double inputAbs;
double peakfinderB0;
double peakOutput;
double fs;
double peakfinderB0Attack;
double peakfinderFinderA1;
double peakfinderB0Release;
double peakfinderReleaseTime;
double peakB0Attack;
double peakfinderA1;
double outputGain;
double dynamicsAttackTime;
double dynamicsB0Attack;
double dynamicsReleaseTime;
double dynamicsB0Release;
double dynamicsOutputGain;
double dynamicsB0;
};
class EnvelopeFollower
{
public:
EnvelopeFollower():
envelope(0)
{
set(10.0,200.0,44100);
};
void set(double attackMs, double releaseMs, int sampleRate);
void process(double input);
double sidechain(double input, double sidechainSignal);
double envelope;
private:
double temp;
double attack;
double release;
};
class Limiter{
public:
Limiter():
attackCoeff(0.0),
releaseCoeff(0.0),
env(0.0),
targetGain(1.0),
currentGain(1.0),
delayIndex(0)
{
set(20.0,20.0,-6.0,44100);
};
double process(double input);
void set(double attackMs, double releaseMs, double thresholdDb,int sampleRate);
void resetEnv();
private:
double attackCoeff;
double releaseCoeff;
double env;
double targetGain;
double currentGain;
int delayIndex;
int delayLength;
int sr;
//double* delayLine;
double threshold;
};
class Gate{
public:
Gate():
releaseTime(0.2),
sr(44100),
threshold(0.001),
outputValue(0.0),
gain(1.0),
holdTime(1.0),
attackTime(0.01){
set(44100.0);
};
double process(double inputValue);
void set(double sampleRate);
private:
double releaseTime;
double sr;
double release;
double threshold;
double outputValue;
double gain;
int tick;
double hold;
double holdTime;
double attack;
double attackTime;
};
class Xcomp{
public:
void set(int sampleRate);
double process(double inputValue);
private:
int sampleRate;
double fRec2[2];
double fRec1[2];
double fRec0[2];
double fConst0;
double fConst1;
double fConst2;
double fConst3;
double fConst4;
double fTemp0;
double fTemp1;
double fTemp2;
double output;
};
class Xlimiter{
public:
void set(int sampleRate);
double process(double inputValue);
private:
int sampleRate;
double fRec2[2];
double fRec1[2];
double fRec0[2];
double b1;
double b2;
double attack;
double release;
double temp;
double mag;
double env;
double output;
};
class Genesis : public IPlug
{
public:
Genesis(IPlugInstanceInfo instanceInfo);
~Genesis();
void Reset();
void OnParamChange(int paramIdx);
void ProcessDoubleReplacing(double** inputs, double** outputs, int nFrames);
private:
double attackTime;
double attackCoeff;
double releaseTime;
double releaseCoeff;
double envelope=0.0;
double currentLevel= 50.0;
double targetLevel;
double ramp;
double sr1;
double sr2;
double bs1;
double fq1;
double fq2;
double fq3;
double fq4;
double fq5;
double fq6;
double fq7;
double fq8;
double fq9;
double fq10;
double fq11;
double fq12;
double fq13;
double fq14;
double fq15;
double fq16;
double fq17;
double fq18;
double mGain;
double l=0.0;
double r=0.0;
double left;
double right;
double peakOutL=0.0;
double peakOutR=0.0;
double peakSum=0.0;
double gainDb=0.0;
double gain=0.0;
double ratio=10.0;
double thresholdDb=(-12.0);
double targetGain;
HP12 filter1;
LP48 filter2;
LP24 filter3;
HP48 filter4;
HP24 filter5;
LP24 filter6;
LP6 filter7;
LP12 filter8;
HP12 filter9;
LP48 filter10;
LP24 filter11;
HP48 filter12;
HP24 filter13;
LP24 filter14;
LP6 filter15;
LP12 filter16;
Notch filter17;
Notch filter18;
HP12 filter19;
HP12 filter20;
HP24 filter21;
HP24 filter22;
LP12 filter23;
LP12 filter24;
LP12 filter25;
LP12 filter26;
HP12 filter27;
HP12 filter28;
HP24 filter29;
HP24 filter30;
LP24 filter31;
LP24 filter32;
HP48 filter33;
HP48 filter34;
HP24 filter35;
HP24 filter36;
//Eq3 eq1;
//Eq3 eq2;
//LFO lfo1;
//LFO lfo2;
Gate gate1;
Gate gate2;
//Compressor comp1;
//Compressor comp2;
//gam::Notch<double> notch1;
//gam::Notch<double> notch2;
//gam::FreqShift<double> shifter1;
//gam::FreqShift<double> shifter2;
Clipper clipper1;
Clipper clipper2;
Clipper clipper3;
Clipper clipper4;
Limiter limiter1;
Limiter limiter2;
Limiter limiter3;
Limiter limiter4;
//Limiter limiter5;
//Limiter limiter6;
//Xcomp xcomp1;
//Xcomp xcomp2;
//Xlimiter xlimiter1;
//Xlimiter xlimiter2;
//EnvelopeFollower sidechain1;
//EnvelopeFollower sidechain2;
//EnvelopeFollower sidechain3;
//EnvelopeFollower sidechain4;
};
#endif