Chebyshev Type I and Butterworth HP & LP Filters

I have made a plugin which will provide HP and LP chebyshev type I and butterworth filters.

You can specify the cutoff frequency (-3dB down point), filter order and the allowed ripple in the passband.

0dB ripple in the passband gives you a butterworth (perfectly flat) filter response and with ripple it is warped into a chebyshev type I (The unit circle in z-domain is warped to an ellipse - for those who care - the more ripple the more elliptical it is).

The gain is corrected so that it is 0dB gain in the passband (except for ripple).

You can use the HP and LP in combination to give flat-topped band pass filters - as opposed to filters specified using Q, which typically have a rounded top. I have also created sets to provide octave and partial octave band filters if people are interested, but they are based on this fundamental plugin.

Kai
Old version:
chebyI.ny (5.57 KB)
The latest version is available on the Audacity wiki

Terrific, thanks Kai.
Very readable code and nicely commented too.

Regarding your note:

  ;This function follows the code in Table 20-5 of
  ;1997, Smith, S. "The Scientist and Engineer's Guide to Digital Signal Processing"
  ;http://www.dspguide.com
  ;Note: The naming convention in Smith (1997) of the a and b coefficients
  ;is reversed compared to nyquist

I’ve not checked this - but has he used the Matlab sign conventions for coefficients?
http://www.cs.cmu.edu/~rbd/doc/nyquist/part8.html#index432


Do you plan to develop this further or are you happy with it as is? With some values the code produces divide by zero errors (ripple > 3.0, other values at default).

It might be nice to add support for stereo tracks which could be done by changing the final line to:

(multichan-expand #'chebyI s n fType fc ripple)

Another tip, “pi” is defined in Nyquist (to 32 bit float precision) so you don’t need to set it yourself.

(setq *float-format* "%1.15f") ; sets the format for printed output to 15 places
(print pi)
; paste into the Nyquist prompt effect and click Debug

Thanks a lot for the plugin, works great.

I will try to check the Nyquist biquad implementation against the math in Steven W. Smith’s DSP book. The numbers in the online version of the DSP book are very hard to read, but the related chapter can be downloaded as a PDF file with readable numbers.

  • edgar

I have updated the plugin now with some minor tweaks

  1. Fixed ripple bug, now limited to 3dB ripple
  2. Added stereo compatibility
  3. Removed self-defined pi
  4. Limited to 30th order. It seems to get a little bit strange after that - that should be enough anyway right! :wink:

[edit: I have saved the new version in the top message]

Good to know.

Agree :slight_smile:

It is not the matlab conventions (ie its not the sign of the coefficients that is wrong), its that the actual coefficients are labelled in the opposite sense, a is called b, and b is called a.

Happy with the new version (thanks for your input). I considered doing a band pass filter, but I think it would make the interface confusing, since you would have to have an extra cut-off frequency input that would only be used when in band-pass mode. I think it would be better just to make a seperate plugin, which is a band-pass version.

If anyone has any other ideas for improvement I would be happy to hear them.

I suddenly had a need for a Chebyshev filter and remembered this one.
Since I was using it, I’ve added some error checking and streamlined the code a bit. Functionally this version is identical to the original (which works very well) but a lot less likely to return errors.
chebyI.ny (6.07 KB)

Plug-in transferred to the Audacity wiki: http://wiki.audacityteam.org/wiki/Nyquist_Effect_Plug-ins#Chebyshev_Type_I_Filter