-
Notifications
You must be signed in to change notification settings - Fork 7
/
Filter.cpp
41 lines (38 loc) · 968 Bytes
/
Filter.cpp
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
//
// Filter.cpp
// Synthesis
//
// Created by Devin Mooers on 2/7/14.
//
//
#include "Filter.h"
// By Paul Kellett
// http://www.musicdsp.org/showone.php?id=29
double Filter::process(double inputValue) {
buf0 += cutoff * (inputValue - buf0);
buf1 += cutoff * (buf0 - buf1);
switch (mode) {
case FILTER_MODE_LOWPASS:
return buf1;
case FILTER_MODE_HIGHPASS:
return inputValue - buf0;
case FILTER_MODE_BANDPASS:
return buf0 - buf1;
default:
return 0.0;
}
// buf0 += cutoff * (inputValue - buf0);
// buf1 += cutoff * (buf0 - buf1);
// buf2 += cutoff * (buf1 - buf0);
// buf3 += cutoff * (buf2 - buf1);
// switch (mode) {
// case FILTER_MODE_LOWPASS:
// return buf3;
// case FILTER_MODE_HIGHPASS:
// return inputValue - buf3;
// case FILTER_MODE_BANDPASS:
// return buf0 - buf3;
// default:
// return 0.0;
// }
}