-
Notifications
You must be signed in to change notification settings - Fork 10
/
moogladder.h
53 lines (44 loc) · 1.37 KB
/
moogladder.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
#pragma once
#ifndef DSY_MOOGLADDER_H
#define DSY_MOOGLADDER_H
/** Moog ladder filter module
Ported from soundpipe
Original author(s) : Victor Lazzarini, John ffitch (fast tanh), Bob Moog
fast_shape() is now a hybrid linear/table-lookup function to speed up calculations (by copych)
*/
class MoogLadder
{
public:
MoogLadder() {}
~MoogLadder() {}
/** Initializes the MoogLadder module.
sample_rate - The sample rate of the audio engine being run.
*/
void Init(float sample_rate);
/** Processes the lowpass filter
*/
float Process(float in);
/**
Sets the cutoff frequency or half-way point of the filter.
Arguments
- freq - frequency value in Hz. Range: Any positive value.
*/
inline void SetCutoff(float freq) { freq_ = freq; }
inline void SetDrive(float drive) {
drive_ = drive+0.01f;
compens_ = (drive_* 0.85f + 3.2f) / drive_;
#ifdef DEBUG_FX
DEBF("Filter drive: %0.4f\r\n",drive);
#endif
}
/**
Sets the resonance of the filter.
*/
inline void SetResonance(float res) { res_ = res * 0.96f; }
private:
float istor_, res_, freq_, delay_[6], tanhstg_[3], old_freq_, old_res_, one_sr_,
sample_rate_, acr, old_acr_, old_tune_, drive_, compens_;
inline float my_tanh(float x);
};
//#endif
#endif