Skip to content

Commit 0b17d61

Browse files
Merge pull request electro-smith#91 from andrewikenberry/svf_cpp
added inline documentation to svf
2 parents 0327abd + 6b1ada1 commit 0b17d61

File tree

2 files changed

+140
-3
lines changed

2 files changed

+140
-3
lines changed

daisysp/doc/svf.md

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

daisysp/modules/svf.h

+60-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1-
// State Variable Filter:
2-
// Double Sampled, Stable
1+
// # svf
2+
// Double Sampled, Stable State Variable Filter
33
//
44
// Credit to Andrew Simper from musicdsp.org
5+
//
56
// This is his "State Variable Filter (Double Sampled, Stable)"
7+
//
68
// Additional thanks to Laurent de Soras for stability limit, and
79
// Stefan Diedrichsen for the correct notch output
810
//
911
// Ported by: Stephen Hensley
1012
//
13+
// example:
14+
// daisysp/examples/svf/
1115
#pragma once
1216
#ifndef DSY_SVF_H
1317
#define DSY_SVF_H
@@ -20,19 +24,72 @@ namespace daisysp
2024
svf() {}
2125
~svf() {}
2226

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+
// ~~~~
2333
void init(float samplerate);
34+
// ~~~~
35+
36+
37+
// ### process
38+
//
39+
// Process the input signal, updating all of the outputs.
40+
// ~~~~
2441
void process(float in);
42+
// ~~~~
2543

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+
// ~~~~
2652
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+
// ~~~~
2761
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+
// ~~~~
2869
inline void set_drive(float d) { _drive = d; }
70+
// ~~~~
2971

30-
// Getters for all of the outputs.
72+
// ## Filter Outputs
73+
// ## Lowpass Filter
74+
// ~~~~
3175
inline float low() { return _out_low; }
76+
// ~~~~
77+
// ## Highpass Filter
78+
// ~~~~
3279
inline float high() { return _out_high; }
80+
// ~~~~
81+
// ## Bandpass Filter
82+
// ~~~~
3383
inline float band() { return _out_band; }
84+
// ~~~~
85+
// ## Notch Filter
86+
// ~~~~
3487
inline float notch() { return _out_notch; }
88+
// ~~~~
89+
// ## Peak Filter
90+
// ~~~~
3591
inline float peak() { return _out_peak; }
92+
// ~~~~
3693

3794
private:
3895
float _sr, _fc, _res, _drive, _freq, _damp;

0 commit comments

Comments
 (0)