Filter: fixed test suite

fill in a parameters structure
This commit is contained in:
Andrew Tridgell 2023-11-03 10:25:10 +11:00
parent de8bec596e
commit 304890fc7d
2 changed files with 20 additions and 1 deletions

View File

@ -119,17 +119,26 @@ public:
// set the fundamental center frequency of the harmonic notch
void set_center_freq_hz(float center_freq) { _center_freq_hz.set(center_freq); }
// set the bandwidth of the harmonic notch
void set_bandwidth_hz(float bandwidth_hz) { _bandwidth_hz.set(bandwidth_hz); }
// set the attenuation of the harmonic notch
void set_attenuation(float attenuation_dB) { _attenuation_dB.set(attenuation_dB); }
// harmonics enabled on the harmonic notch
uint32_t harmonics(void) const { return _harmonics; }
// set the harmonics value
void set_harmonics(uint32_t hmncs) { _harmonics.set(hmncs); }
// has the user set the harmonics value
void set_default_harmonics(uint32_t hmncs) { _harmonics.set_default(hmncs); }
// reference value of the harmonic notch
float reference(void) const { return _reference; }
void set_reference(float ref) { _reference.set(ref); }
// notch options
bool hasOption(Options option) const { return _options & uint16_t(option); }
// notch dynamic tracking mode
@ -142,6 +151,9 @@ public:
}
void set_freq_min_ratio(float ratio) { _freq_min_ratio.set(ratio); }
// set options flags
void set_options(uint16_t options) { _options.set(options); }
// save parameters
void save_params();

View File

@ -106,7 +106,14 @@ TEST(NotchFilterTest, HarmonicNotchTest)
for (uint8_t c=0; c<chained_filters; c++) {
auto &f = filters[i][c];
f.allocate_filters(num_harmonics, harmonics, double_notch?2:1);
f.init(rate_hz, base_freq, bandwidth, attenuation_dB);
HarmonicNotchFilterParams notch_params {};
notch_params.set_attenuation(attenuation_dB);
notch_params.set_bandwidth_hz(bandwidth);
notch_params.set_center_freq_hz(base_freq);
notch_params.set_freq_min_ratio(1.0);
notch_params.set_options(uint16_t(HarmonicNotchFilterParams::Options::TreatLowAsMin));
f.init(rate_hz, notch_params);
f.update(base_freq);
}
}