44 #ifndef STATEVARIABLE_H_
45 #define STATEVARIABLE_H_
48 #include "util/atomic.h"
49 #include "mozzi_fixmath.h"
51 #include "mozzi_utils.h"
54 enum filter_types {LOWPASS,BANDPASS,HIGHPASS,NOTCH};
64 template <
int8_t FILTER_TYPE>
92 scale = (
Q0n8)sqrt((
unsigned int) resonance<<8);
148 low += ((f*band)>>16);
149 int high = (((long)input - low - (((
long)band * q)>>8))*scale)>>8;
150 band += ((f*high)>>16);
166 low += ((f*band)>>16);
167 int high = (((long)input - low - (((
long)band * q)>>8))*scale)>>8;
168 band += ((f*high)>>16);
185 low += ((f*band)>>16);
186 int high = (((long)input - low - (((
long)band * q)>>8))*scale)>>8;
187 band += ((f*high)>>16);
204 low += ((f*band)>>16);
205 int high = (((long)input - low - (((
long)band * q)>>8))*scale)>>8;
206 band += ((f*high)>>16);
207 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.
A State Variable filter which offers 12db resonant low, high, bandpass and notch modes.
#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.