1
- // State Variable Filter:
2
- // Double Sampled, Stable
1
+ // # svf
2
+ // Double Sampled, Stable State Variable Filter
3
3
//
4
4
// Credit to Andrew Simper from musicdsp.org
5
+ //
5
6
// This is his "State Variable Filter (Double Sampled, Stable)"
7
+ //
6
8
// Additional thanks to Laurent de Soras for stability limit, and
7
9
// Stefan Diedrichsen for the correct notch output
8
10
//
9
11
// Ported by: Stephen Hensley
10
12
//
13
+ // example:
14
+ // daisysp/examples/svf/
11
15
#pragma once
12
16
#ifndef DSY_SVF_H
13
17
#define DSY_SVF_H
@@ -20,19 +24,72 @@ namespace daisysp
20
24
svf () {}
21
25
~svf () {}
22
26
27
+ // ### init
28
+ //
29
+ // Initializes the filter
30
+ //
31
+ // float samplerate - sample rate of the audio engine being run, and the frequency that the process function will be called.
32
+ // ~~~~
23
33
void init (float samplerate);
34
+ // ~~~~
35
+
36
+
37
+ // ### process
38
+ //
39
+ // Process the input signal, updating all of the outputs.
40
+ // ~~~~
24
41
void process (float in);
42
+ // ~~~~
25
43
44
+ // ## Setters
45
+ //
46
+ // ### set_freq
47
+ //
48
+ // sets the frequency of the cutoff frequency.
49
+ //
50
+ // f must be between 0.0 and samplerate / 2
51
+ // ~~~~
26
52
void set_freq (float f);
53
+ // ~~~~
54
+
55
+ // ### set_res
56
+ //
57
+ // sets the resonance of the filter.
58
+ //
59
+ // Must be between 0.0 and 1.0 to ensure stability.
60
+ // ~~~~
27
61
void set_res (float r);
62
+ // ~~~~
63
+
64
+ // ### set_drive
65
+ //
66
+ // sets the drive of the filter, affecting the response of the resonance of
67
+ // the filter..
68
+ // ~~~~
28
69
inline void set_drive (float d) { _drive = d; }
70
+ // ~~~~
29
71
30
- // Getters for all of the outputs.
72
+ // ## Filter Outputs
73
+ // ## Lowpass Filter
74
+ // ~~~~
31
75
inline float low () { return _out_low; }
76
+ // ~~~~
77
+ // ## Highpass Filter
78
+ // ~~~~
32
79
inline float high () { return _out_high; }
80
+ // ~~~~
81
+ // ## Bandpass Filter
82
+ // ~~~~
33
83
inline float band () { return _out_band; }
84
+ // ~~~~
85
+ // ## Notch Filter
86
+ // ~~~~
34
87
inline float notch () { return _out_notch; }
88
+ // ~~~~
89
+ // ## Peak Filter
90
+ // ~~~~
35
91
inline float peak () { return _out_peak; }
92
+ // ~~~~
36
93
37
94
private:
38
95
float _sr, _fc, _res, _drive, _freq, _damp;
0 commit comments