net.beadsproject.beads.ugens
Class CombFilter

java.lang.Object
  extended by net.beadsproject.beads.core.Bead
      extended by net.beadsproject.beads.core.UGen
          extended by net.beadsproject.beads.ugens.IIRFilter
              extended by net.beadsproject.beads.ugens.CombFilter

public class CombFilter
extends IIRFilter

Implements a simple comb filter with both feed-forward and feed-back components.

y(n) = a * x(n) + g * x(n - d) - h * y(n - d)

Version:
0.9.1
Author:
Benito Crawford

Nested Class Summary
 
Nested classes/interfaces inherited from class net.beadsproject.beads.ugens.IIRFilter
IIRFilter.IIRFilterAnalysis
 
Nested classes/interfaces inherited from class net.beadsproject.beads.core.UGen
UGen.OutputInitializationRegime, UGen.OutputPauseRegime
 
Field Summary
 
Fields inherited from class net.beadsproject.beads.core.UGen
bufferSize, bufIn, bufOut, context, ins, outputInitializationRegime, outputPauseRegime, outs
 
Constructor Summary
CombFilter(AudioContext con, int maxdel)
          Constructor.
 
Method Summary
 void calculateBuffer()
          Called by the signal chain to update this UGen's ouput data.
 float getA()
          Gets the 'a' parameter.
 UGen getAUGen()
          Gets the 'a' UGen, if it exists.
 int getDelay()
          Gets the current delay in samples.
 UGen getDelayUGen()
          Gets the delay UGen, if it exists.
 IIRFilter.IIRFilterAnalysis getFilterResponse(float freq)
           
 float getG()
          Gets the g parameter.
 UGen getGUGen()
          Gets the g UGen, if it exists.
 float getH()
          Gets the h parameter.
 UGen getHUGen()
          Gets the h UGen, if it exists.
 int getMaxDelay()
          Gets the maximum delay in samples.
 DataBead getParams()
          Gets a DataBead with properties "a", "g", "h", and "delay" set to the corresponding filter parameters.
 DataBead getStaticParams()
          Gets a DataBead with properties "a", "g", "h", and "delay" set to static float values corresponding to the current filter parameters.
 void messageReceived(Bead message)
          Responds to an incoming message.
 void reset()
          Use this to reset the filter if it explodes.
 CombFilter setA(float a)
          Sets the 'a' parameter to a float value.
 CombFilter setA(UGen a)
          Sets a UGen to specify the 'a' parameter.
 CombFilter setDelay(int delay)
          Sets the delay time in samples.
 CombFilter setDelay(UGen delay)
          Sets a UGen to specify the delay in samples (converted to ints).
 CombFilter setG(float g)
          Sets the g parameter to a float value.
 CombFilter setG(UGen g)
          Sets a UGen to specify the g parameter.
 CombFilter setH(float h)
          Sets the h parameter to a float value.
 CombFilter setH(UGen h)
          Sets a UGen to specify the h parameter.
 CombFilter setParams(DataBead paramBead)
          Sets the filter parameters with a DataBead.
 CombFilter setParams(int delay, float a, float g, float h)
          Sets all the parameters at once.
 CombFilter setParams(UGen delUGen, UGen aUGen, UGen gUGen, UGen hUGen)
          Sets the parameter UGens.
 
Methods inherited from class net.beadsproject.beads.ugens.IIRFilter
analyzeFilter, calculateFilterResponse, calculateGroupDelay, getAmplitudeResponse, getGroupDelay, getPhaseDelay, getPhaseResponse
 
Methods inherited from class net.beadsproject.beads.core.UGen
addDependent, addInput, addInput, clearDependents, clearInputConnections, containsInput, crossfadeInput, getConnectedInputs, getContext, getEnvelopes, getIns, getNumberOfConnectedUGens, getNumberOfDependents, getOutBuffer, getOuts, getTimeTakenLastUpdate, getValue, getValue, getValueDouble, getValueDouble, initializeOuts, isTimerMode, isUpdated, noInputs, pause, printInBuffers, printInputList, printOutBuffers, removeAllConnections, removeConnection, removeDependent, setOutsToPause, setTimerMode, setValue, update, zeroIns, zeroOuts
 
Methods inherited from class net.beadsproject.beads.core.Bead
getKillListener, getName, isDeleted, isPaused, kill, message, setKillListener, setName, start, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CombFilter

public CombFilter(AudioContext con,
                  int maxdel)
Constructor.

Parameters:
con - The audio context.
maxdel - The maximum delay in samples.
Method Detail

calculateBuffer

public void calculateBuffer()
Description copied from class: UGen
Called by the signal chain to update this UGen's ouput data. Subclassses of UGen should implement the UGen's DSP perform routine here. In general this involves grabbing data from UGen.bufIn and putting data into UGen.bufOut in some way. UGen.bufIn and UGen.bufOut are 2D arrays of floats of the form float[numChannels][bufferSize]. The length of the buffers is given by UGen.bufferSize, and the number of channels of the input and output buffers are given by UGen.ins and UGen.outs respectively.

Specified by:
calculateBuffer in class UGen

reset

public void reset()
Use this to reset the filter if it explodes.


getMaxDelay

public int getMaxDelay()
Gets the maximum delay in samples.

Returns:
The maximum delay.

getDelay

public int getDelay()
Gets the current delay in samples.

Returns:
The delay in samples.

setDelay

public CombFilter setDelay(int delay)
Sets the delay time in samples. This will remove the delay UGen, if there is one.

Parameters:
delay - The delay in samples.
Returns:
This CombFilter instance.

setDelay

public CombFilter setDelay(UGen delay)
Sets a UGen to specify the delay in samples (converted to ints).

Parameters:
delay - The delay UGen.
Returns:
This CombFilter instance.

getDelayUGen

public UGen getDelayUGen()
Gets the delay UGen, if it exists.

Returns:
The delay UGen.

getG

public float getG()
Gets the g parameter.

Returns:
The g parameter.

setG

public CombFilter setG(float g)
Sets the g parameter to a float value. This will remove the g UGen, if there is one.

Parameters:
g - The g parameter.
Returns:
This CombFilter instance.

setG

public CombFilter setG(UGen g)
Sets a UGen to specify the g parameter. Passing a null value will freeze the parameter at its current value.

Parameters:
g - The g UGen.
Returns:
This CombFilter instance.

getGUGen

public UGen getGUGen()
Gets the g UGen, if it exists.

Returns:
The g UGen.

getH

public float getH()
Gets the h parameter.

Returns:
The h parameter.

setH

public CombFilter setH(float h)
Sets the h parameter to a float value. This will remove the h UGen, if there is one.

Parameters:
h - The h parameter.
Returns:
This CombFilter instance.

setH

public CombFilter setH(UGen h)
Sets a UGen to specify the h parameter. Passing a null value will freeze the parameter at its current value.

Parameters:
h - The h UGen.
Returns:
This CombFilter instance.

getHUGen

public UGen getHUGen()
Gets the h UGen, if it exists.

Returns:
The h UGen.

getA

public float getA()
Gets the 'a' parameter.

Returns:
The 'a' parameter.

setA

public CombFilter setA(float a)
Sets the 'a' parameter to a float value. This will remove the 'a' UGen, if there is one.

Parameters:
a - The 'a' parameter.
Returns:
This CombFilter instance.

setA

public CombFilter setA(UGen a)
Sets a UGen to specify the 'a' parameter. Passing a null value will freeze the parameter at its current value.

Parameters:
a - The 'a' UGen.
Returns:
This CombFilter instance.

getAUGen

public UGen getAUGen()
Gets the 'a' UGen, if it exists.

Returns:
The 'a' UGen.

setParams

public CombFilter setParams(int delay,
                            float a,
                            float g,
                            float h)
Sets all the parameters at once. This will clear parameter UGens, if they exist.

Parameters:
delay - The delay in samples.
a - The 'a' parameter.
g - The g parameter.
h - The h parameter.
Returns:
This CombFilter instance.

setParams

public CombFilter setParams(UGen delUGen,
                            UGen aUGen,
                            UGen gUGen,
                            UGen hUGen)
Sets the parameter UGens. Passing null values will freeze the parameters at their previous values.

Parameters:
delUGen - The delay UGen.
aUGen - The 'a' UGen.
gUGen - The g UGen.
hUGen - The h UGen.
Returns:
This CombFilter instance.

setParams

public CombFilter setParams(DataBead paramBead)
Sets the filter parameters with a DataBead.

Use the following properties to specify filter parameters:

Parameters:
paramBead - The DataBead specifying parameters.

messageReceived

public void messageReceived(Bead message)
Description copied from class: Bead
Responds to an incoming message. Subclasses can override this in order to handle incoming messages. Typically a Bead would send a message to another Bead with itself as the arugment.

Overrides:
messageReceived in class Bead
Parameters:
message - the message

getParams

public DataBead getParams()
Gets a DataBead with properties "a", "g", "h", and "delay" set to the corresponding filter parameters.

Returns:
The parameter DataBead.

getStaticParams

public DataBead getStaticParams()
Gets a DataBead with properties "a", "g", "h", and "delay" set to static float values corresponding to the current filter parameters.

Returns:
The static parameter DataBead.

getFilterResponse

public IIRFilter.IIRFilterAnalysis getFilterResponse(float freq)
Specified by:
getFilterResponse in class IIRFilter