Beispiel #1
0
//! fcd = cut-off (1=sampling rate)
//! ord = Filter order
//! ripple = passband ripple in dB
void chebyshev_iir(iir_coeff& filt, float_type fcd, bool lpf, float_type ripple = 3.0) {
  const float_type ten = 10.0;
  long order = filt.order;
  float_type epi = pow(ten, (ripple / ten)) - 1.0;
  epi = pow(epi, (float_type)(1. / (1.0 * order)));
  float_type wca = tan(0.5 * PI * fcd);
  //! wca - pre-warped angular frequency
  long n2 = (order + 1) / 2;
  chebyshev_s(filt.poles, filt.zeros, lpf, wca, epi, order, n2);
  filt.bilinear();
  filt.convert_to_ab();
}
Beispiel #2
0
//! fcd = cut-off (1=sampling rate)
//! ord = Filter order
//! ripple = passband ripple in dB
void chebyshev2_iir(iir_coeff& filt, float_type fcd, float_type stopband = 40.0) {
  const float_type ten = 10.0;
  auto order = filt.getOrder();
  float_type delta = pow(ten, -stopband/20.0);
  float_type epi   = delta/sqrt(1 - delta*delta);
  float_type wca = (filt.get_type()==filter_type::high) ? tan(M_PI * (0.5-fcd)) : tan(M_PI*fcd);
  chebyshev2_s(filt, wca, epi, order);
	filt.bilinear();
	if (filt.get_type()==filter_type::bandpass || filt.get_type()==filter_type::bandstop) {
		filt.make_band(filt.get_center());
	} else {
		filt.convert_to_ab();
	}
	if (filt.get_type()==filter_type::bandpass) filt.set_bandpass_gain();
}