net.beadsproject.beads.ugens
Class OnePoleFilter

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

public class OnePoleFilter
extends IIRFilter
implements DataBeadReceiver

A simple one-pole filter implementation. Cut-off frequency can be specified either by UGen or a float.

It uses the formula: y(n) = a * x(n) + (1 - a) * y(n - 1)

Version:
0.9
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  boolean isFreqStatic
           
protected  float samplingfreq
           
protected  float two_pi_over_sf
           
 
Fields inherited from class net.beadsproject.beads.core.UGen
bufferSize, bufIn, bufOut, context, ins, outputInitializationRegime, outputPauseRegime, outs
 
Constructor Summary
OnePoleFilter(AudioContext con, float freq)
          Constructor for cut-off frequency specified by a static float.
OnePoleFilter(AudioContext con, UGen freq)
          Constructor for cut-off frequency specified by a UGen.
 
Method Summary
 void calculateBuffer()
          Called by the signal chain to update this UGen's ouput data.
protected  void calcVals()
           
 IIRFilter.IIRFilterAnalysis getFilterResponse(float freq)
           
 float getFreq()
          Deprecated. Use getFrequency().
 float getFrequency()
          Gets the current cut-off frequency.
 UGen getFrequencyUGen()
          Gets the cut-off frequency UGen; returns null if frequency is static.
 UGen getFreqUGen()
          Deprecated. Use getFrequencyUGen().
 DataBead getParams()
          Gets a DataBead with the filter frequency (whether float or UGen), stored in the key "frequency".
 DataBead getStaticParams()
          Gets a DataBead with property "frequency" set to its current float value.
 void messageReceived(Bead message)
          Responds to an incoming message.
 DataBeadReceiver sendData(DataBead db)
          Sets the filter frequency with a DataBead.
 OnePoleFilter setFreq(float freq)
          Deprecated. Use setFrequency(float).
 OnePoleFilter setFreq(UGen freqUGen)
          Deprecated. Use setFrequency(UGen).
 OnePoleFilter setFrequency(float freq)
          Sets the cut-off frequency to a static float.
 OnePoleFilter setFrequency(UGen freqUGen)
          Sets a UGen to specify the cut-off frequency; passing null freezes the frequency at its current value.
 OnePoleFilter 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

samplingfreq

protected float samplingfreq

two_pi_over_sf

protected float two_pi_over_sf

isFreqStatic

protected boolean isFreqStatic
Constructor Detail

OnePoleFilter

public OnePoleFilter(AudioContext con,
                     float freq)
Constructor for cut-off frequency specified by a static float.

Parameters:
con - The audio context.
freq - The cut-off frequency.

OnePoleFilter

public OnePoleFilter(AudioContext con,
                     UGen freq)
Constructor for cut-off frequency specified by a UGen.

Parameters:
con - The audio context.
freq - The cut-off frequency UGen.
Method Detail

calcVals

protected void calcVals()

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

getFrequency

public float getFrequency()
Gets the current cut-off frequency.

Returns:
The cut-off frequency.

setFrequency

public OnePoleFilter setFrequency(float freq)
Sets the cut-off frequency to a static float.

Parameters:
freq - The cut-off frequency.
Returns:
This filter instance.

setFrequency

public OnePoleFilter setFrequency(UGen freqUGen)
Sets a UGen to specify the cut-off frequency; passing null freezes the frequency at its current value.

Parameters:
freqUGen - The cut-off frequency UGen.
Returns:
This filter instance.

getFrequencyUGen

public UGen getFrequencyUGen()
Gets the cut-off frequency UGen; returns null if frequency is static.

Returns:
The cut-off frequency UGen.

getFreq

@Deprecated
public float getFreq()
Deprecated. Use getFrequency().

Gets the current cut-off frequency.

Returns:
The cut-off frequency.

setFreq

@Deprecated
public OnePoleFilter setFreq(float freq)
Deprecated. Use setFrequency(float).

Sets the cut-off frequency to a static float.

Parameters:
freq - The cut-off frequency.
Returns:
This filter instance.

setFreq

@Deprecated
public OnePoleFilter setFreq(UGen freqUGen)
Deprecated. Use setFrequency(UGen).

Sets a UGen to specify the cut-off frequency; passing null freezes the frequency at its current value.

Parameters:
freqUGen - The cut-off frequency UGen.
Returns:
This filter instance.

getFreqUGen

@Deprecated
public UGen getFreqUGen()
Deprecated. Use getFrequencyUGen().

Gets the cut-off frequency UGen; returns null if frequency is static.

Returns:
The cut-off frequency UGen.

setParams

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

Use the "frequency" properties to specify filter frequency.

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 the filter frequency (whether float or UGen), stored in the key "frequency".

Returns:
The DataBead with the stored parameter.

getStaticParams

public DataBead getStaticParams()
Gets a DataBead with property "frequency" set to its current float value.

Returns:
The DataBead with the static float parameter value.

sendData

public DataBeadReceiver sendData(DataBead db)
Sets the filter frequency 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