std::vector<double> calculate_decimator_taps(unsigned int rate, int low_rate_multipliers, bool use_fir) { const size_t IIR_Order = low_rate_multipliers/2; const double ripple = 0.1; const size_t Order=(2*low_rate_multipliers*rate)+1; const double fc = 0.5/rate; const double pass_edge = 0.8*fc; if (use_fir) { const double remez_stop_atten = 60.0; const double remez_trans = 2*(fc - pass_edge); const double remez_weight = remez_estimate_weight(ripple, remez_stop_atten); auto taps = design_fir("remez","LOW_PASS", (int)Order, pass_edge, 0, remez_trans, remez_weight); return taps; } else { iir_coeff* filt = design_iir("chebyshev", "LOW_PASS", (int)IIR_Order, pass_edge, ripple); // get the tap from iir_coeff for iir_filter, incorporating the gain to feedforward taps std::vector<double> b = filt->get_b(); std::vector<double> a = filt->get_a(); // Group together feed forward and feed back taps into 1 vector for transferring to IIR filter for (size_t i=0;i<a.size();i++) b.push_back(a[i]); return b; } }
float* calc_coefficients_125Hz_lowpass(int rate) { len125 = 256; float f = 125.0f / (rate / 2); float *coeffs = design_fir(&len125, &f, 0); static const float M3_01DB = 0.7071067812f; for (unsigned int i = 0; i < len125; i++) { coeffs[i] *= M3_01DB; } return coeffs; }