ddf.minim.effects
Class ChebFilter

java.lang.Object
  extended by ddf.minim.ugens.UGen
      extended by ddf.minim.effects.IIRFilter
          extended by ddf.minim.effects.ChebFilter
All Implemented Interfaces:
AudioEffect

public class ChebFilter
extends IIRFilter

A Chebyshev filter is an IIR filter that uses a particular method to calculate the coefficients of the filter. It is defined by whether it is a low pass filter or a high pass filter and the number of poles it has. You needn't worry about what a pole is, exactly, just know that more poles usually makes for a better filter. An additional limitation is that the number of poles must be even. See setPoles(int) for more information about poles. Another characteristic of Chebyshev filters is how much "ripple" they allow in the pass band. The pass band is the range of frequencies that the filter lets through. The "ripple" in the pass band can be seen as wavy line in the frequency response of the filter. Lots of ripple is bad, but more ripple gives a faster rolloff from the pass band to the stop band (the range of frequencies blocked by the filter). Faster rolloff is good because it means the cutoff is sharper. Ripple is expressed as a percentage, such as 0.5% ripple.

Author:
Damien Di Fede
See Also:
Chebyshev Filters

Nested Class Summary
 
Nested classes/interfaces inherited from class ddf.minim.ugens.UGen
UGen.InputType, UGen.UGenInput
 
Field Summary
static int HP
          A constant used to indicate a high pass filter.
static int LP
          A constant used to indicate a low pass filter.
 
Fields inherited from class ddf.minim.effects.IIRFilter
a, audio, b, cutoff
 
Constructor Summary
ChebFilter(float frequency, int type, float ripple, int poles, float sampleRate)
          Constructs a Chebyshev filter with a cutoff of the given frequency, of the given type, with the give amount of ripple in the pass band, and with the given number of poles, that will be used to filter audio of that was recorded at the given sample rate.
 
Method Summary
protected  void calcCoeff()
          Calculates the coefficients of the filter using the current cutoff frequency.
 int getPoles()
          Returns the number of poles in the filter.
 float getRipple()
          Returns the ripple percentage of the filter.
 int getType()
          Returns the type of the filter.
 void setPoles(int p)
          Sets the number of poles used in the filter.
 void setRipple(float r)
          Sets the ripple percentage of the filter.
 void setType(int t)
          Sets the type of the filter.
 
Methods inherited from class ddf.minim.effects.IIRFilter
frequency, initArrays, printCoeff, process, process, setFreq, uGenerate, validFreq
 
Methods inherited from class ddf.minim.ugens.UGen
addInput, getLastValues, patch, patch, patch, printInputs, removeInput, sampleRate, sampleRateChanged, setSampleRate, tick, unpatch, unpatch
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LP

public static final int LP
A constant used to indicate a low pass filter.

See Also:
Constant Field Values

HP

public static final int HP
A constant used to indicate a high pass filter.

See Also:
Constant Field Values
Constructor Detail

ChebFilter

public ChebFilter(float frequency,
                  int type,
                  float ripple,
                  int poles,
                  float sampleRate)
Constructs a Chebyshev filter with a cutoff of the given frequency, of the given type, with the give amount of ripple in the pass band, and with the given number of poles, that will be used to filter audio of that was recorded at the given sample rate.

Parameters:
frequency - the cutoff frequency of the filter
type - the type of filter, either ChebFilter.LP or ChebFilter.HP
ripple - the percentage of ripple, such as 0.005
poles - the number of poles, must be even and in the range [2, 20]
sampleRate - the sample rate of audio that will be filtered
Method Detail

setType

public void setType(int t)
Sets the type of the filter. Either ChebFilter.LP or ChebFilter.HP

Parameters:
t - the type of the filter

getType

public int getType()
Returns the type of the filter.


setRipple

public void setRipple(float r)
Sets the ripple percentage of the filter.

Parameters:
r - the ripple percentage

getRipple

public float getRipple()
Returns the ripple percentage of the filter.

Returns:
the ripple percentage

setPoles

public void setPoles(int p)
Sets the number of poles used in the filter. The number of poles must be even and between 2 and 20. This function will report an error if either of those conditions are not met. However, it should also be mentioned that depending on the current cutoff frequency of the filter, the number of poles that will result in a stable filter, can be a few as 4. The function does not report an error in the case of the number of requested poles resulting in an unstable filter. For reference, here is a table of the maximum number of poles possible according to cutoff frequency:

Cutoff Frequency
(expressed as a fraction of the sampling rate)
0.02 0.05 0.10 0.25 0.40 0.45 0.48
Maximum poles 4 6 10 20 10 6 4

Parameters:
p - - the number of poles

getPoles

public int getPoles()
Returns the number of poles in the filter.

Returns:
the number of poles

calcCoeff

protected void calcCoeff()
Description copied from class: IIRFilter
Calculates the coefficients of the filter using the current cutoff frequency. To make your own IIRFilters, you must extend IIRFilter and implement this function. The frequency is expressed as a fraction of the sample rate. When filling the coefficient arrays, be aware that b[0] corresponds to the coefficient b1.

Specified by:
calcCoeff in class IIRFilter