-
Notifications
You must be signed in to change notification settings - Fork 2
/
filter.h
54 lines (43 loc) · 1015 Bytes
/
filter.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
#ifndef _FILTER_H_
#define _FILTER_H_
class Filter
{
public:
virtual void Initialize() {}
virtual short Work(short sample) { return 0; }
protected:
bool m_bParamsChanged;
};
class Lowpass : public Filter
{
float history[4];
float cutoff;
float resonance;
float targetCutoff;
float targetResonance;
float minCutoff, maxCutoff;
float minResonance, maxResonance;
float cutoffPow, resonancePow;
float inertia; // ratio of approach to target
float lastTargetC100, lastTargetR100;
float coef[5];
public:
void Initialize();
short Work(short sample);
// parameters are passed as percentage of range
void SetParams(float targetC100, float targetR100);
};
#define MAX_DELAY 22050
class Delay : public Filter
{
short buffer[MAX_DELAY];
int m_nPos;
int m_nFeedback;
int m_nDelayLength;
public:
virtual void Initialize();
virtual short Work(short sample);
// parameters are passed as percentage of range
void SetParams(int delay100, int feedback100);
};
#endif // _FILTER_H_