net.beadsproject.beads.ugens
Class AllpassFilter

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.AllpassFilter
All Implemented Interfaces:
DataBeadReceiver

public class AllpassFilter
extends IIRFilter
implements DataBeadReceiver

A simple all-pass filter with variable delay. Implements the following formula: Y(n) = X(n-d) + g * (Y(n-d) - X(n)), for delay time d and factor g.

Version:
0.9.5
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
protected  int bufLen
           
protected  int delay
           
protected  UGen delayUGen
           
protected  float g
           
protected  UGen gUGen
           
protected  int ind
           
protected  boolean isDelayStatic
           
protected  boolean isGStatic
           
protected  int maxDelay
           
protected  float[] xn
           
protected  float[] yn
           
 
Fields inherited from class net.beadsproject.beads.core.UGen
bufferSize, bufIn, bufOut, context, ins, outputInitializationRegime, outputPauseRegime, outs
 
Constructor Summary
AllpassFilter(AudioContext context, int maxdel, int idel, float ig)
          Constructor with delay and g specified by floats.
AllpassFilter(AudioContext context, int maxdel, int idel, UGen ig)
          Constructor with delay specified by a float and g specified by a UGen.
AllpassFilter(AudioContext context, int maxdel, UGen idel, float ig)
          Constructor with delay specified by a UGen and g specified by a float.
AllpassFilter(AudioContext context, int maxdel, UGen idel, UGen ig)
          Constructor with delay and g specified by UGens.
 
Method Summary
 void calculateBuffer()
          Called by the signal chain to update this UGen's ouput data.
 int getDelay()
          Gets the current delay in samples.
 UGen getDelayUGen()
          Gets the delay UGen, if there is one.
 IIRFilter.IIRFilterAnalysis getFilterResponse(float freq)
           
 float getG()
          Gets the current g parameter.
 UGen getGUGen()
          Gets the g UGen, if there is one.
 DataBead getParams()
          Gets a DataBead with properties "delay" and "g" set to the corresponding filter parameters.
 DataBead getStaticParams()
          Gets a DataBead with properties "delay" and "g" set to static float values corresponding to the current filter parameters.
 void messageReceived(Bead message)
          Responds to an incoming message.
 DataBeadReceiver sendData(DataBead db)
          Sets the filter's parameters with a DataBead.
 AllpassFilter setDelay(int del)
          Sets the delay.
 AllpassFilter setDelay(UGen del)
          Sets a UGen to determine the delay in samples.
 AllpassFilter setG(float g)
          Sets the g parameter.
 AllpassFilter setG(UGen g)
          Sets a UGen to determine the g value.
 AllpassFilter setParams(DataBead paramBead)
          Sets the filter parameters with a DataBead.
 
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
 

Field Detail

g

protected float g

maxDelay

protected int maxDelay

delay

protected int delay

ind

protected int ind

bufLen

protected int bufLen

delayUGen

protected UGen delayUGen

gUGen

protected UGen gUGen

isDelayStatic

protected boolean isDelayStatic

isGStatic

protected boolean isGStatic

xn

protected float[] xn

yn

protected float[] yn
Constructor Detail

AllpassFilter

public AllpassFilter(AudioContext context,
                     int maxdel,
                     int idel,
                     float ig)
Constructor with delay and g specified by floats.

Parameters:
context - The AudioContext.
maxdel - The maximum delay in samples; cannot be changed.
idel - The initial delay in samples.
ig - The initial g parameter.

AllpassFilter

public AllpassFilter(AudioContext context,
                     int maxdel,
                     UGen idel,
                     float ig)
Constructor with delay specified by a UGen and g specified by a float.

Parameters:
context - The AudioContext.
maxdel - The maximum delay in samples; cannot be changed.
idel - The delay UGen.
ig - The initial g parameter.

AllpassFilter

public AllpassFilter(AudioContext context,
                     int maxdel,
                     int idel,
                     UGen ig)
Constructor with delay specified by a float and g specified by a UGen.

Parameters:
context - The AudioContext.
maxdel - The maximum delay in samples; cannot be changed.
idel - The initial delay in samples.
ig - The g UGen.

AllpassFilter

public AllpassFilter(AudioContext context,
                     int maxdel,
                     UGen idel,
                     UGen ig)
Constructor with delay and g specified by UGens.

Parameters:
context - The AudioContext.
maxdel - The maximum delay in samples; cannot be changed.
idel - The delay UGen.
ig - The g UGen.
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

getG

public float getG()
Gets the current g parameter.

Returns:
The g parameter.

setG

public AllpassFilter setG(float g)
Sets the g parameter. This clears the g UGen if there is one.

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

setG

public AllpassFilter setG(UGen g)
Sets a UGen to determine the g value.

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

getGUGen

public UGen getGUGen()
Gets the g UGen, if there is one.

Returns:
The g UGen.

getDelay

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

Returns:
The delay in samples.

setDelay

public AllpassFilter setDelay(int del)
Sets the delay.

Parameters:
del - The delay in samples. This will remove the delay UGen if there is one.
Returns:
This filter instance.

setDelay

public AllpassFilter setDelay(UGen del)
Sets a UGen to determine the delay in samples. Delay times are converted to integers. Passing a null value freezes the delay at its current value.

Parameters:
del - The delay UGen.
Returns:
This filter instance.

getDelayUGen

public UGen getDelayUGen()
Gets the delay UGen, if there is one.

Returns:
The delay UGen.

setParams

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

Use the following properties to specify filter parameters:

Parameters:
paramBead - The DataBead specifying parameters.
Returns:
This filter instance.

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 "delay" and "g" set to the corresponding filter parameters.

Returns:
The parameter DataBead.

getStaticParams

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

Returns:
The static parameter DataBead.

sendData

public DataBeadReceiver sendData(DataBead db)
Sets the filter's parameters with a DataBead.

Specified by:
sendData in interface DataBeadReceiver
Parameters:
db - The DataBead message.
Returns:
This filter instance.
See Also:
setParams(DataBead)

getFilterResponse

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