Introduction

This is package provides a selection of standard IIR filters such as Bessel, Butterworth and Chebyshev. The filters are designed on the basis of analogue lowpass filters and transformed with the z-transform to the digital space into a chain of 2nd order biquads.

Usage

Setup

In general one needs two commands to set up the filter:
  1. Constructor call which defines the type of the filter, for example:
    Butterworth butterworth = new Butterworth();
  2. Call of the method which creates the desired filter response, for example:
    butterworth.bandPass(order, Samplingfreq, Center freq, Width in frequ);
    The filter order represents the number of poles, the 2nd argument is always the sampling frequency and the remaining parameters define the cutoff, center, width and other factors requied for the specific filter.
  3. The filter topology can be selected as an optional parameter which can be:
    • DirectFormAbstract.DIRECT_FORM_I
    • DirectFormAbstract.DIRECT_FORM_II.

Filtering

Filtering of the signal is sample by sample so that realtime processing is possible, for example:
outsample = butterworth.filter(insample)

Butterworth

This is the Butterworth filter available as low-, high-, bandpass and stopband filter. This filter has a maximally flat response in the passband but is not linear phase.

Setup

Butterworth butterworth = new Butterworth()

Lowpass

butterworth.lowPass(filter order, Sampling frequency,Cutoff frequency [,topology]);
  • filter order: number of poles or filter order / 2 = number of 2nd order filter stages
  • sampling frequency: the sampling frequency in Hz of the incoming samples.
  • cutoff frequency: the cutoff frequency of the lowpass filter in Hz
  • topology: the topology of the 2nd order biquad filters. Default is type II.

Highpass

butterworth.highPass(filter order, Sampling frequency,Cutoff frequency [,topology]);
  • filter order: number of poles or filter order / 2 = number of 2nd order filter stages
  • sampling frequency: the sampling frequency in Hz of the incoming samples.
  • cutoff frequency: the cutoff frequency of the highpass filter in Hz
  • topology: the topology of the 2nd order biquad filters. Default is type II.

Bandpass

butterworth.bandPass(filter order, Sampling frequency,Center frequency, Width [,topology]);
  • filter order: number of poles or filter order / 2 = number of 2nd order filter stages
  • sampling frequency: the sampling frequency in Hz of the incoming samples.
  • center frequency: the center frequency of the bandpass in Hz
  • width: the width of the bandpass in Hz
  • topology: the topology of the 2nd order biquad filters. Default is type II.

Bandstop

butterworth.bandStop(filter order, Sampling frequency,Center frequency, Width [,topology]);
  • filter order: number of poles or filter order / 2 = number of 2nd order filter stages
  • sampling frequency: the sampling frequency in Hz of the incoming samples.
  • center frequency: the center frequency of the bandstop in Hz
  • width: the width of the bandstop in Hz
  • topology: the topology of the 2nd order biquad filters. Default is type II.

Bessel

This is the Bessel filter available as low-, high-, bandpass and stopband filter. This filter has a maximally linear phase response in the passband but has a very slow rolloff.

Setup

Bessel bessel = new Bessel()

Lowpass

bessel.lowPass(filter order, Sampling frequency,Cutoff frequency [,topology]);
  • filter order: number of poles or filter order / 2 = number of 2nd order filter stages
  • sampling frequency: the sampling frequency in Hz of the incoming samples.
  • cutoff frequency: the cutoff frequency of the lowpass filter in Hz
  • topology: the topology of the 2nd order biquad filters. Default is type II.

Highpass

bessel.highPass(filter order, Sampling frequency,Cutoff frequency [,topology]);
  • filter order: number of poles or filter order / 2 = number of 2nd order filter stages
  • sampling frequency: the sampling frequency in Hz of the incoming samples.
  • cutoff frequency: the cutoff frequency of the highpass filter in Hz
  • topology: the topology of the 2nd order biquad filters. Default is type II.

Bandpass

bessel.bandPass(filter order, Sampling frequency,Center frequency, Width [,topology]);
  • filter order: number of poles or filter order / 2 = number of 2nd order filter stages
  • sampling frequency: the sampling frequency in Hz of the incoming samples.
  • center frequency: the center frequency of the bandpass in Hz
  • width: the width of the bandpass in Hz
  • topology: the topology of the 2nd order biquad filters. Default is type II.

Bandstop

bessel.bandStop(filter order, Sampling frequency,Center frequency, Width [,topology]);
  • filter order: number of poles or filter order / 2 = number of 2nd order filter stages
  • sampling frequency: the sampling frequency in Hz of the incoming samples.
  • center frequency: the center frequency of the stopband filter in Hz
  • width: the width of the stopband filter in Hz
  • topology: the topology of the 2nd order biquad filters. Default is type II.

ChebyshevI

This is the Chebyshev type I filter available as low-, high-, bandpass and stopband filter. This filter has ripples in the passband. In addition to the standard parameters one needs to specify the allowed ripple in the passband in debcibel.

Setup

ChebyshevI chebyshevI = new ChebyshevI()

Lowpass

chebyshevI.lowPass(filter order, Sampling frequency,Cutoff frequency, ripple in DB [,topology]);
  • filter order: number of poles or filter order / 2 = number of 2nd order filter stages
  • sampling frequency: the sampling frequency in Hz of the incoming samples.
  • cutoff frequency: the cutoff frequency of the lowpass filter in Hz
  • ripple in DB: sets the allowed ripples in the passband.
  • topology: the topology of the 2nd order biquad filters. Default is type II.

Highpass

chebyshevI.highPass(filter order, Sampling frequency,Cutoff frequency, ripple in DB [,topology]);
  • filter order: number of poles or filter order / 2 = number of 2nd order filter stages
  • sampling frequency: the sampling frequency in Hz of the incoming samples.
  • cutoff frequency: the cutoff frequency of the highpass filter in Hz
  • ripple in DB: sets the allowed ripples in the passband.
  • topology: the topology of the 2nd order biquad filters. Default is type II.

Bandpass

chebyshevI.bandPass(filter order, Sampling frequency,Center frequency, Width, ripple in DB [,topology]);
  • filter order: number of poles or filter order / 2 = number of 2nd order filter stages
  • sampling frequency: the sampling frequency in Hz of the incoming samples.
  • center frequency: the center frequency of the bandpass in Hz
  • width: the width of the bandpass in Hz
  • ripple in DB: sets the allowed ripples in the passband.
  • topology: the topology of the 2nd order biquad filters. Default is type II.

Bandstop

chebyshevI.bandStop(filter order, Sampling frequency,Center frequency, Width, ripple in DB [,topology]);
  • filter order: number of poles or filter order / 2 = number of 2nd order filter stages
  • sampling frequency: the sampling frequency in Hz of the incoming samples.
  • center frequency: the center frequency of the stopband filter in Hz
  • width: the width of the stopband filter in Hz
  • topology: the topology of the 2nd order biquad filters. Default is type II.

ChebyshevII

This is the Chebyshev type II filter available as low-, high-, bandpass and stopband filter. In addition to the standard parameters one needs to specify the allowed ripple in the stopband in debcibel.

Setup

ChebyshevII chebyshevII = new ChebyshevII()

Lowpass

chebyshevII.lowPass(filter order, Sampling frequency,Cutoff frequency, ripple in DB [,topology]);
  • filter order: number of poles or filter order / 2 = number of 2nd order filter stages
  • sampling frequency: the sampling frequency in Hz of the incoming samples.
  • cutoff frequency: the cutoff frequency of the lowpass filter in Hz
  • ripple in DB: sets the allowed ripples in the stopband.
  • topology: the topology of the 2nd order biquad filters. Default is type II.

Highpass

chebyshevII.highPass(filter order, Sampling frequency,Cutoff frequency, ripple in DB [,topology]);
  • filter order: number of poles or filter order / 2 = number of 2nd order filter stages
  • sampling frequency: the sampling frequency in Hz of the incoming samples.
  • cutoff frequency: the cutoff frequency of the highpass filter in Hz
  • ripple in DB: sets the allowed ripples in the stopband.
  • topology: the topology of the 2nd order biquad filters. Default is type II.

Bandpass

chebyshevII.bandPass(filter order, Sampling frequency,Center frequency, Width, ripple in DB [,topology]);
  • filter order: number of poles or filter order / 2 = number of 2nd order filter stages
  • sampling frequency: the sampling frequency in Hz of the incoming samples.
  • center frequency: the center frequency of the bandpass in Hz
  • width: the width of the bandpass in Hz
  • ripple in DB: sets the allowed ripples in the stopband.
  • topology: the topology of the 2nd order biquad filters. Default is type II.

Bandstop

chebyshevII.bandStop(filter order, Sampling frequency,Center frequency, Width, ripple in DB [,topology]);
  • filter order: number of poles or filter order / 2 = number of 2nd order filter stages
  • sampling frequency: the sampling frequency in Hz of the incoming samples.
  • center frequency: the center frequency of the bandpass in Hz
  • width: the width of the bandstop in Hz
  • ripple in DB: sets the allowed ripples in the stopband.
  • topology: the topology of the 2nd order biquad filters. Default is type II.