12 #ifndef RESONANTFILTER_H_
13 #define RESONANTFILTER_H_
70 enum filter_types { LOWPASS, BANDPASS, HIGHPASS, NOTCH };
74 template<int8_t FILTER_TYPE,
typename su=uint8_t>
94 fb = q + ucfxmul(q, (
typename IntegerType<
sizeof(su)+
sizeof(su)>::unsigned_type) SHIFTED_1 + cutoff);
119 fb = q + ucfxmul(q,(
typename IntegerType<
sizeof(su)+
sizeof(su)>::unsigned_type) SHIFTED_1 + cutoff);
131 return current(in,
Int2Type<FILTER_TYPE>());
137 typename IntegerType<
sizeof(su)+
sizeof(su)>::unsigned_type fb;
139 const uint8_t FX_SHIFT =
sizeof(
su) << 3;
140 const uint8_t FX_SHIFT_M_1 =
FX_SHIFT-1;
141 const su SHIFTED_1 = (1<<
FX_SHIFT)-1;
152 buf0 += fxmul(((in - buf0) + fxmul(fb, buf0 - buf1)), f);
153 buf1 += ifxmul(buf0 - buf1, f);
165 inline typename IntegerType<
sizeof(su)+
sizeof(su)>::unsigned_type ucfxmul(su a,
typename IntegerType<
sizeof(su)+
sizeof(su)>::unsigned_type b)
167 return (((
typename IntegerType<
sizeof(su)+
sizeof(su)>::unsigned_type)a * (b >> 1)) >> (FX_SHIFT_M_1));
217 typedef ResonantFilter<LOWPASS> LowPassFilter;
218 typedef ResonantFilter<LOWPASS, uint16_t> LowPassFilter16;