|
|
|
@ -7,11 +7,14 @@ |
|
|
|
|
|
|
|
|
|
#include "util.h" |
|
|
|
|
|
|
|
|
|
#define FILTER_K_BASE 6.907755278982137 |
|
|
|
|
|
|
|
|
|
inline float noteToK(float note) { |
|
|
|
|
return ((note - 69) / 12.0) / (FILTER_K_BASE * M_LOG2E); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
class SVF12 { |
|
|
|
|
public: |
|
|
|
|
float frequency; |
|
|
|
|
float Q; |
|
|
|
|
|
|
|
|
|
typedef struct { |
|
|
|
|
float lp; // low-pass
|
|
|
|
|
float bp; // band-pass
|
|
|
|
@ -66,9 +69,9 @@ private: |
|
|
|
|
public: |
|
|
|
|
void assign(Settings const * settings); |
|
|
|
|
|
|
|
|
|
inline float tick(float in, float freqAdd, float freqScale) { |
|
|
|
|
float freq = clamp(freqScale * settings->freq + freqAdd, 0, 1); |
|
|
|
|
float kK = tan(M_PI_4 * clamp(0.001 * exp(freq * 6.907755278982137), 0, 1)); |
|
|
|
|
inline float tick(float in, float freqAdd) { |
|
|
|
|
float freq = clamp(settings->freq + freqAdd, 0, 1); |
|
|
|
|
float kK = tan(M_PI_4 * clamp(0.001 * exp(freq * FILTER_K_BASE), 0, 1)); |
|
|
|
|
float kQ = M_SQRT1_2 + settings->res; |
|
|
|
|
|
|
|
|
|
SVF12::Output outA = fltA.tick(in, kK, kQ); |
|
|
|
|