Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## ddf.minim.effects
Class IIRFilter

    java.lang.Object
      ddf.minim.effects.IIRFilter

All Implemented Interfaces:
  AudioEffect

Direct Known Subclasses:
  BandPass, ChebFilter, HighPassSP, LowPassFS, LowPassSP, NotchFilter

    public abstract class IIRFilter

extends java.lang.Object
implements AudioEffect

An Infinite Impulse Response, or IIR, filter is a filter that uses a set of coefficients and previous filtered values to filter a stream of audio. It is an efficient way to do digital filtering. IIRFilter is a general IIRFilter that simply applies the filter designated by the filter coefficients so that sub-classes only have to dictate what the values of those coefficients are by defining the `calcCoeff()` function. When filling the coefficient arrays, be aware that `b[0]` corresponds to `b1`.

Author:
  Damien Di Fede

Field Summary
`protected float[]` | `a` The a coefficients.
`protected float[]` | `b` The b coefficients.

Constructor Summary
`IIRFilter(float freq, float sampleRate)` Constructs an IIRFilter with the given cutoff frequency that will be used to filter audio recorded at `sampleRate`.

Method Summary
`protected abstract void` | `calcCoeff()` Calculates the coefficients of the filter using the current cutoff frequency.
`float` | `frequency()` Returns the cutoff frequency (in Hz).
`void` | `printCoeff()` Prints the current values of the coefficients to the console.
`void` | `process(float[] signal)` Processes `signal` in some way.
`void` | `process(float[] sigLeft, float[] sigRight)` Processes `sigLeft` and `sigRight` in some way.
`float` | `sampleRate()` Returns the sample rate of audio that this filter will process.
`void` | `setFreq(float f)` Sets the cutoff/center frequency of the filter.
`boolean` | `validFreq(float f)` Returns true if the frequency is valid for this filter.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### a

    protected float[] a

  The a coefficients.

### b

    protected float[] b

  The b coefficients.

Constructor Detail

### IIRFilter

    public IIRFilter(float freq,
                     float sampleRate)

  Constructs an IIRFilter with the given cutoff frequency that will be used to filter audio recorded at `sampleRate`.

  Parameters:
    `freq` - the cutoff frequency
    `sampleRate` - the sample rate of audio to be filtered

Method Detail

### process

    public final void process(float[] signal)

  Description copied from interface: `AudioEffect`
  Processes `signal` in some way.

  Specified by:
    `process` in interface `AudioEffect`
  Parameters:
    `signal` - an array of audio samples, representing a mono sound stream.

### process

    public final void process(float[] sigLeft,
                              float[] sigRight)

  Description copied from interface: `AudioEffect`
  Processes `sigLeft` and `sigRight` in some way.

  Specified by:
    `process` in interface `AudioEffect`
  Parameters:
    `sigLeft` - an array of audio samples, representing the left channel of a stereo sound stream
    `sigRight` - an array of audio samples, representing the right channel of a stereo sound stream

### setFreq

    public final void setFreq(float f)

  Sets the cutoff/center frequency of the filter. Doing this causes the coefficients to be recalculated.

  Parameters:
    `f` - the new cutoff/center frequency (in Hz).

### validFreq

    public boolean validFreq(float f)

  Returns true if the frequency is valid for this filter. Subclasses can override this method if they want to limit center frequencies to certain ranges to avoid becoming unstable. The default implementation simply makes sure that `f` is positive.

  Parameters:
    `f` - the frequency (in Hz) to validate
  Returns:
    true if `f` is a valid frequency for this filter

### frequency

    public final float frequency()

  Returns the cutoff frequency (in Hz).

  Returns:
    the current cutoff frequency (in Hz).

### sampleRate

    public final float sampleRate()

  Returns the sample rate of audio that this filter will process.

  Returns:
    the sample rate of audio that will be processed

### calcCoeff

    protected abstract void calcCoeff()

  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`.

### printCoeff

    public final void printCoeff()

  Prints the current values of the coefficients to the console.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD