44 #ifndef STATEVARIABLE_H_ 45 #define STATEVARIABLE_H_ 84 scale = (Q0n8)sqrt((
unsigned int)resonance << 8);
117 return next(input,
Int2Type<FILTER_TYPE>());
130 inline int next(
int input,
Int2Type<LOWPASS>) {
132 low += ((f * band) >> 16);
133 int high = (((
long)input - low - (((
long)band * q) >> 8)) * scale) >> 8;
134 band += ((f * high) >> 16);
145 inline int next(
int input,
Int2Type<BANDPASS>) {
147 low += ((f * band) >> 16);
148 int high = (((
long)input - low - (((
long)band * q) >> 8)) * scale) >> 8;
149 band += ((f * high) >> 16);
160 inline int next(
int input,
Int2Type<HIGHPASS>) {
162 low += ((f * band) >> 16);
163 int high = (((
long)input - low - (((
long)band * q) >> 8)) * scale) >> 8;
164 band += ((f * high) >> 16);
175 inline int next(
int input,
Int2Type<NOTCH>) {
177 low += ((f * band) >> 16);
178 int high = (((
long)input - low - (((
long)band * q) >> 8)) * scale) >> 8;
179 band += ((f * high) >> 16);
180 int notch = high + low;
int32_t Q15n16
signed fractional number using 15 integer bits and 16 fractional bits, represents -32767...
void setResonance(Q0n8 resonance)
Set how resonant the filter will be.
Enables you to instantiate a template based on an integer value.
StateVariable()
Constructor.
int next(int input)
Calculate the next sample, given an input signal.
#define AUDIO_RATE_AS_LSHIFT
State Variable Filter (approximation of Chamberlin version) Informed by pseudocode at http://www...
#define Q16n16_2PI
2*PI in Q16n16 format
uint8_t Q0n8
unsigned fractional number using 8 fractional bits, represents 0.0 to 0.996
void setCentreFreq(unsigned int centre_freq)
Set the centre or corner frequency of the filter.