13 #ifndef RESONANTFILTER_H_ 14 #define RESONANTFILTER_H_ 71 enum filter_types { LOWPASS, BANDPASS, HIGHPASS, NOTCH };
75 template<int8_t FILTER_TYPE,
typename su=uint8_t>
95 fb = q + ucfxmul(q, (
typename IntegerType<
sizeof(su)+
sizeof(su)>::unsigned_type) SHIFTED_1 + cutoff);
120 fb = q + ucfxmul(q,(
typename IntegerType<
sizeof(su)+
sizeof(su)>::unsigned_type) SHIFTED_1 + cutoff);
132 return current(in,
Int2Type<FILTER_TYPE>());
138 typename IntegerType<
sizeof(su)+
sizeof(su)>::unsigned_type fb;
140 const uint8_t FX_SHIFT =
sizeof(
su) << 3;
141 const uint8_t FX_SHIFT_M_1 =
FX_SHIFT-1;
142 const su SHIFTED_1 = (1<<
FX_SHIFT)-1;
153 buf0 += fxmul(((in - buf0) + fxmul(fb, buf0 - buf1)), f);
154 buf1 += ifxmul(buf0 - buf1, f);
166 inline typename IntegerType<
sizeof(su)+
sizeof(su)>::unsigned_type ucfxmul(su a,
typename IntegerType<
sizeof(su)+
sizeof(su)>::unsigned_type b)
168 return (((
typename IntegerType<
sizeof(su)+
sizeof(su)>::unsigned_type)a * (b >> 1)) >> (FX_SHIFT_M_1));
218 typedef ResonantFilter<LOWPASS> LowPassFilter;
219 typedef ResonantFilter<LOWPASS, uint16_t> LowPassFilter16;
void setCutoffFreqAndResonance(su cutoff, su resonance)
Set the cut off frequency and resonance.
AudioOutputStorage_t next(AudioOutputStorage_t in)
Calculate the next sample, given an input signal.
AudioOutputStorage_t notch()
Return the input filtered with a notch filter.
Enables you to instantiate a template based on an integer value.
void next(AudioOutputStorage_t in)
Compute the filters, given an input signal.
A generic filter for audio signals that can produce lowpass, highpass, bandpass and notch outputs at ...
AudioOutputStorage_t low()
Return the input filtered with a lowpass filter.
AudioOutputStorage_t high()
Return the input filtered with a highpass filter.
AudioOutputStorage_t band()
Return the input filtered with a bandpass filter.
void setResonance(su resonance)
deprecated.
A generic resonant filter for audio signals.
void setCutoffFreq(su cutoff)
deprecated.
ResonantFilter()
Constructor.
#define AudioOutputStorage_t
The type used to store a single channel of a single frame, internally.