27 #ifndef NOTCH_FILTER_H
28 #define NOTCH_FILTER_H
48 filter->
Ts = 1.0/frequency;
57 float d = expf(-M_PI*bandwidth*filter->
Ts);
67 float theta = 2.0*M_PI*frequency*filter->
Ts;
81 float a = (1 + filter->
d2) * 0.5;
83 *output_signal = (b * filter->
yn1) - (filter->
d2 * filter->
yn2) + (a * *input_signal) - (b * filter->
xn1) + (a * filter->
xn2);
87 filter->
xn1 = *input_signal;
89 filter->
yn1 = *output_signal;
static void notch_filter_set_sampling_frequency(struct SecondOrderNotchFilter *filter, uint16_t frequency)
Set sampling frequency of the notch filter.
static void notch_filter_init(struct SecondOrderNotchFilter *filter, float cutoff_frequency, float bandwidth, uint16_t sample_frequency)
Initialize second order notch filter.
static void notch_filter_set_filter_frequency(struct SecondOrderNotchFilter *filter, float frequency)
Set notch filter frequency in Hz.
static void notch_filter_update(struct SecondOrderNotchFilter *filter, int32_t *input_signal, int32_t *output_signal)
Notch filter propagate.
static void notch_filter_set_bandwidth(struct SecondOrderNotchFilter *filter, float bandwidth)
Set bandwidth of the notch filter.