com.softsynth.jsyn
Class Filter_2o2p2z

java.lang.Object
  extended by java.util.Observable
      extended by com.softsynth.jsyn.SynthObject
          extended by com.softsynth.jsyn.SynthSound
              extended by com.softsynth.jsyn.SynthUnit
                  extended by com.softsynth.jsyn.SynthFilter
                      extended by com.softsynth.jsyn.Filter_2o2p2z

public class Filter_2o2p2z
extends SynthFilter

Filter_2o2p2z unit. Second Order, Two Pole, Two Zero filter using the following formula:

     y(n) = 2.0 * (A0*x(n) + A1*x(n-1)  + A2*x(n-2) - B1*y(n-1)  - B2*y(n-2))

where y(n) is Output, x(n) is Input, x(n-1) is a delayed copy of the input, and y(n-1) is a delayed copy of the output.

This filter is a recursive IIR or Infinite Impulse Response filter. It can be unstable depending on the values of the coefficients.

A thorough description of the digital filter theory needed to fully describe this filter is beyond the scope of this document. Calculating coefficients is non-intuitive; the interested user is referred to one of the standard texts on filter theory (e.g., Moore, "Elements of Computer Music", section 2.4).

Special thanks to Robert Bristow-Johnson for contributing his filter equations to the music-dsp list. They were used for calculating the coefficients for the lowPass, highPass, and other parametric filter calculations.

Version:
JSyn Version 011
Author:
(C) 1997 Phil Burk, SoftSynth.com, All Rights Reserved
See Also:
Synth, SynthUnit, Filter_1o1z, Filter_1o1p, Filter_2o2p, Filter_1o1p1z, Filter_LowPass, Filter_HighPass, Filter_BandPass, Filter_PeakingEQ, Filter_BandStop, Filter_LowShelf, Filter_HighShelf, Filter_StateVariable

Field Summary
 SynthVariable A0
          Filter coefficient.
 SynthVariable A1
          Filter coefficient.
 SynthVariable A2
          Filter coefficient.
 SynthVariable B1
          Filter coefficient.
 SynthVariable B2
          Filter coefficient.
 
Fields inherited from class com.softsynth.jsyn.SynthFilter
input, output
 
Constructor Summary
Filter_2o2p2z()
           
Filter_2o2p2z(SynthContext synthContext)
          Create a SynthUnit that runs at Synth.RATE_AUDIO.
Filter_2o2p2z(SynthContext synthContext, int calculationRate)
           
 
Method Summary
 void bandPass(double frequency, double bandwidth)
           
 void bandPass(int time, double frequency, double bandwidth)
          Set coefficients of filter for Band Pass operation.
 void highPass(double frequency, double bandwidth)
           
 void highPass(int time, double frequency, double bandwidth)
          Set coefficients of filter for High Pass operation.
 void highShelf(double frequency, double dBGain, double slope)
           
 void highShelf(double frequency, double bandwidth, double dBGain, double slope)
           
 void highShelf(int time, double frequency, double dBGain, double slope)
          Set coefficients of filter for High Shelf operation.
 void highShelf(int time, double frequency, double bandwidth, double dBGain, double slope)
           
 void lowPass(double frequency, double bandwidth)
           
 void lowPass(int time, double frequency, double bandwidth)
          Set coefficients of filter for Low Pass operation.
 void lowShelf(double frequency, double dBGain, double slope)
           
 void lowShelf(double frequency, double bandwidth, double dBGain, double slope)
           
 void lowShelf(int time, double frequency, double dBGain, double slope)
          Set coefficients of filter for Low Shelf operation.
 void lowShelf(int time, double frequency, double bandwidth, double dBGain, double slope)
           
 void notch(double frequency, double bandwidth)
           
 void notch(int time, double frequency, double bandwidth)
          Set coefficients of filter for Notch operation.
 void peakingEQ(double frequency, double bandwidth, double dBGain)
           
 void peakingEQ(int time, double frequency, double bandwidth, double dBGain)
          Set coefficients of filter for Peaking EQ operation.
 
Methods inherited from class com.softsynth.jsyn.SynthSound
addPort, addPort, findNamedPort, getName, getNumPorts, getPortAt, getPriority, setPriority, setStage, setStage, start, start, stop, stop
 
Methods inherited from class com.softsynth.jsyn.SynthObject
delete, deleteAll, enableDeletionByGarbageCollector, enableTracking, getPeer, getSynthContext, isTrackingEnabled, toString, track
 
Methods inherited from class java.util.Observable
addObserver, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

A0

public SynthVariable A0
Filter coefficient. SIGNAL_TYPE_RAW_SIGNED, default = 0.0.


A1

public SynthVariable A1
Filter coefficient. SIGNAL_TYPE_RAW_SIGNED, default = 0.0.


A2

public SynthVariable A2
Filter coefficient. SIGNAL_TYPE_RAW_SIGNED, default = 0.0.


B1

public SynthVariable B1
Filter coefficient. SIGNAL_TYPE_RAW_SIGNED, default = 0.0.


B2

public SynthVariable B2
Filter coefficient. SIGNAL_TYPE_RAW_SIGNED, default = 0.0.

Constructor Detail

Filter_2o2p2z

public Filter_2o2p2z(SynthContext synthContext,
                     int calculationRate)
              throws SynthException
Throws:
SynthException

Filter_2o2p2z

public Filter_2o2p2z(SynthContext synthContext)
              throws SynthException
Create a SynthUnit that runs at Synth.RATE_AUDIO.

Throws:
SynthException - If resource allocation fails.

Filter_2o2p2z

public Filter_2o2p2z()
              throws SynthException
Throws:
SynthException
Method Detail

lowPass

public void lowPass(int time,
                    double frequency,
                    double bandwidth)
             throws SynthException
Set coefficients of filter for Low Pass operation. Frequencies below the given frequency parameter will be passed. Frequencies above will be cut off to varying degrees.

Parameters:
time - Time at which to set ports..
frequency - Cutoff frequency in Hertz.
bandwidth - Bandwidth in octaves (between midpoint (dBgain/2) gain frequencies for peaking or between -3 dB frequencies for BPF and notch).
Throws:
SynthException - If port setting fails.

lowPass

public void lowPass(double frequency,
                    double bandwidth)
             throws SynthException
Throws:
SynthException

highPass

public void highPass(int time,
                     double frequency,
                     double bandwidth)
              throws SynthException
Set coefficients of filter for High Pass operation. Frequencies above the given frequency parameter will be passed. Frequencies below will be cut off to varying degrees.

Parameters:
time - Time at which to set ports..
frequency - Cutoff frequency in Hertz.
bandwidth - Bandwidth in octaves (between midpoint (dBgain/2) gain frequencies for peaking or between -3 dB frequencies for BPF and notch).
Throws:
SynthException - If port setting fails.

highPass

public void highPass(double frequency,
                     double bandwidth)
              throws SynthException
Throws:
SynthException

bandPass

public void bandPass(int time,
                     double frequency,
                     double bandwidth)
              throws SynthException
Set coefficients of filter for Band Pass operation. Frequencies near the given frequency parameter will be passed. Frequencies above and below will be cut off to varying degrees.

Parameters:
time - Time at which to set ports..
frequency - Center frequency in Hertz.
bandwidth - Bandwidth in octaves (between midpoint (dBgain/2) gain frequencies for peaking or between -3 dB frequencies for BPF and notch).
Throws:
SynthException - If port setting fails.

bandPass

public void bandPass(double frequency,
                     double bandwidth)
              throws SynthException
Throws:
SynthException

notch

public void notch(int time,
                  double frequency,
                  double bandwidth)
           throws SynthException
Set coefficients of filter for Notch operation. Frequencies near the given frequency parameter will be cut. Frequencies above and below will be passed to varying degrees.

Parameters:
time - Time at which to set ports..
frequency - Center frequency in Hertz.
bandwidth - Bandwidth in octaves (between midpoint (dBgain/2) gain frequencies for peaking or between -3 dB frequencies for BPF and notch).
Throws:
SynthException - If port setting fails.

notch

public void notch(double frequency,
                  double bandwidth)
           throws SynthException
Throws:
SynthException

peakingEQ

public void peakingEQ(int time,
                      double frequency,
                      double bandwidth,
                      double dBGain)
               throws SynthException
Set coefficients of filter for Peaking EQ operation. Frequencies near the given frequency parameter will be passed. Frequencies above and below will be cut off to varying degrees.

Parameters:
time - Time at which to set ports..
frequency - Center frequency in Hertz.
bandwidth - Bandwidth in octaves (between midpoint (dBgain/2) gain frequencies for peaking or between -3 dB frequencies for BPF and notch).
dBGain - Gain in decibels at the center frequency. If dBGain is zero then the signal is unmodified.
Throws:
SynthException - If port setting fails.

peakingEQ

public void peakingEQ(double frequency,
                      double bandwidth,
                      double dBGain)
               throws SynthException
Throws:
SynthException

lowShelf

public void lowShelf(int time,
                     double frequency,
                     double dBGain,
                     double slope)
              throws SynthException
Set coefficients of filter for Low Shelf operation. This is similar to the Bass control on a stereo.

Parameters:
time - Time at which to set ports..
frequency - Center frequency in Hertz.
bandwidth - Bandwidth in octaves (between midpoint (dBgain/2) gain frequencies for peaking or between -3 dB frequencies for BPF and notch).
dBGain - Gain in decibels past the edge of the shelf. If dBGain is zero then the signal is unmodified.
slope - Slope of the edge of the shelf. Should be < 1.0 to prevent irregularities in the frequency response curve.
Throws:
SynthException - If port setting fails.

lowShelf

public void lowShelf(double frequency,
                     double dBGain,
                     double slope)
              throws SynthException
Throws:
SynthException

lowShelf

public void lowShelf(double frequency,
                     double bandwidth,
                     double dBGain,
                     double slope)
              throws SynthException
Throws:
SynthException

lowShelf

public void lowShelf(int time,
                     double frequency,
                     double bandwidth,
                     double dBGain,
                     double slope)
              throws SynthException
Throws:
SynthException

highShelf

public void highShelf(int time,
                      double frequency,
                      double dBGain,
                      double slope)
               throws SynthException
Set coefficients of filter for High Shelf operation. This is similar to the Treble control on a stereo.

Parameters:
time - Time at which to set ports..
frequency - Center frequency in Hertz.
bandwidth - Bandwidth in octaves (between midpoint (dBgain/2) gain frequencies for peaking or between -3 dB frequencies for BPF and notch).
dBGain - Gain in decibels past the edge of the shelf. If dBGain is zero then the signal is supposed to be unmodified but isn't.
slope - Slope of the edge of the shelf. Should be < 1.0 to prevent irregularities in the frequency response curve.
Throws:
SynthException - If port setting fails.

highShelf

public void highShelf(double frequency,
                      double dBGain,
                      double slope)
               throws SynthException
Throws:
SynthException

highShelf

public void highShelf(double frequency,
                      double bandwidth,
                      double dBGain,
                      double slope)
               throws SynthException
Throws:
SynthException

highShelf

public void highShelf(int time,
                      double frequency,
                      double bandwidth,
                      double dBGain,
                      double slope)
               throws SynthException
Throws:
SynthException