22 void NotchFilter<T>::init(
float sample_freq_hz,
float center_freq_hz,
float bandwidth_hz,
float attenuation_dB)
24 float omega = 2.0 *
M_PI * center_freq_hz / sample_freq_hz;
25 float octaves = log2f(center_freq_hz / (center_freq_hz - bandwidth_hz/2)) * 2;
26 float A = powf(10, -attenuation_dB/40);
27 float Q = sqrtf(powf(2, octaves)) / (powf(2,octaves) - 1);
28 float alpha = sinf(omega) / (2 * Q/A);
30 b1 = -2.0 * cosf(omega);
32 a0_inv = 1.0/(1.0 + alpha/A);
33 a1 = -2.0 * cosf(omega);
52 T output = (ntchsig*b0 + ntchsig1*b1 + ntchsig2*b2 - signal1*a1 - signal2*a2) * a0_inv;
135 return filter.apply(sample);
#define AP_PARAM_FLAG_ENABLE
void init(float sample_freq_hz, float center_freq_hz, float bandwidth_hz, float attenuation_dB)
NotchFilterVector3fParam(void)
void init(float sample_freq_hz)
#define AP_GROUPINFO(name, idx, clazz, element, def)
Vector3f apply(const Vector3f &sample)
#define AP_GROUPINFO_FLAGS(name, idx, clazz, element, def, flags)
bool is_zero(const T fVal1)
static const struct AP_Param::GroupInfo var_info[]
std::enable_if< std::is_integral< typename std::common_type< Arithmetic1, Arithmetic2 >::type >::value,bool >::type is_equal(const Arithmetic1 v_1, const Arithmetic2 v_2)
NotchFilter< Vector3f > filter
static void setup_object_defaults(const void *object_pointer, const struct GroupInfo *group_info)