net.beadsproject.beads.ugens
Class CrossoverFilter

java.lang.Object
  extended by net.beadsproject.beads.core.Bead
      extended by net.beadsproject.beads.core.UGen
          extended by net.beadsproject.beads.ugens.CrossoverFilter
All Implemented Interfaces:
DataBeadReceiver

public class CrossoverFilter
extends UGen
implements DataBeadReceiver

A multi-channel 4th-order Linkwitz-Riley crossover filter. For each input channel, the filter outputs both a low-pass and a high-pass channel. If the filter has two inputs, for example, then it will output four channels:

A key feature of Linkwitz-Riley filters is that the low- and high-pass bands added together produce a flat frequency response, making them particularly useful as crossover filters. A 4th-order version is equivalent to cascading two identical 2nd-order Butterworth filters.

Version:
0.9.5
Author:
Benito Crawford

Nested Class Summary
 
Nested classes/interfaces inherited from class net.beadsproject.beads.core.UGen
UGen.OutputInitializationRegime, UGen.OutputPauseRegime
 
Field Summary
static float SQRT2
           
 
Fields inherited from class net.beadsproject.beads.core.UGen
bufferSize, bufIn, bufOut, context, ins, outputInitializationRegime, outputPauseRegime, outs
 
Constructor Summary
CrossoverFilter(AudioContext context)
          Constructor for a one-channel crossover filter, initialized with a cutoff frequency of 800Hz.
CrossoverFilter(AudioContext context, int channels)
          Constructor for a crossover filter with the specified number of channels, initialized with a cutoff frequency of 800Hz.
CrossoverFilter(AudioContext context, int channels, float freq)
          Constructor for a crossover filter with the specified number of channels, set at the specified frequency.
 
Method Summary
 void calculateBuffer()
          Called by the signal chain to update this UGen's ouput data.
 CrossoverFilter drawFromHighOutput(int channel, UGen target, int targetInputIndex)
           
 CrossoverFilter drawFromHighOutput(UGen target)
           
 CrossoverFilter drawFromLowOutput(int channel, UGen target, int targetInputIndex)
           
 CrossoverFilter drawFromLowOutput(UGen target)
           
 int getChannels()
          Gets the number of channels.
 float getFreq()
          Deprecated. Use getFrequency().
 float getFrequency()
          Gets the current cutoff frequency.
 UGen getFrequencyUGen()
          Gets the UGen controlling the cutoff frequency, if there is one.
 UGen getFreqUGen()
          Deprecated. Use getFrequencyUGen().
 void messageReceived(Bead message)
          Responds to an incoming message.
 void reset()
          Resets the filter in case it "explodes".
 DataBeadReceiver sendData(DataBead db)
          Sets the crossover frequency with a DataBead.
 CrossoverFilter setFreq(float freq)
          Deprecated. Use setFrequency(float).
 CrossoverFilter setFreq(UGen freqUGen)
          Deprecated. Use setFrequency(UGen).
 CrossoverFilter setFrequency(float freq)
          Sets the cutoff frequency to a static float value.
 CrossoverFilter setFrequency(UGen freqUGen)
          Sets a UGen to control the cutoff frequency.
 
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

SQRT2

public static final float SQRT2
Constructor Detail

CrossoverFilter

public CrossoverFilter(AudioContext context)
Constructor for a one-channel crossover filter, initialized with a cutoff frequency of 800Hz.

Parameters:
context - The audio context.

CrossoverFilter

public CrossoverFilter(AudioContext context,
                       int channels)
Constructor for a crossover filter with the specified number of channels, initialized with a cutoff frequency of 800Hz.

Parameters:
context - The audio context.
channels - The number of channels.

CrossoverFilter

public CrossoverFilter(AudioContext context,
                       int channels,
                       float freq)
Constructor for a crossover filter with the specified number of channels, set at the specified frequency.

Parameters:
context - The audio context.
channels - The number of channels.
freq - The initial cutoff frequency.
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()
Resets the filter in case it "explodes".


getFrequency

public float getFrequency()
Gets the current cutoff frequency.

Returns:
The cutoff frequency.

setFrequency

public CrossoverFilter setFrequency(float freq)
Sets the cutoff frequency to a static float value.

Parameters:
freq - The cutoff frequency in Hertz.
Returns:
This filter instance.

setFrequency

public CrossoverFilter setFrequency(UGen freqUGen)
Sets a UGen to control the cutoff frequency. Note that the frequency is only updated every frame, not every sample.

Parameters:
freqUGen - The UGen to control the cutoff frequency.
Returns:
This filter instance.

getFrequencyUGen

public UGen getFrequencyUGen()
Gets the UGen controlling the cutoff frequency, if there is one.

Returns:
The UGen controlling the cutoff frequency.

getFreq

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

Gets the current cutoff frequency.

Returns:
The cutoff frequency.

setFreq

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

Sets the cutoff frequency to a static float value.

Parameters:
freq - The cutoff frequency in Hertz.
Returns:
This filter instance.

setFreq

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

Sets a UGen to control the cutoff frequency. Note that the frequency is only updated every frame, not every sample.

Parameters:
freqUGen - The UGen to control the cutoff frequency.
Returns:
This filter instance.

getFreqUGen

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

Gets the UGen controlling the cutoff frequency, if there is one.

Returns:
The UGen controlling the cutoff frequency.

getChannels

public int getChannels()
Gets the number of channels.

Returns:
The number of channels.

sendData

public DataBeadReceiver sendData(DataBead db)
Sets the crossover frequency with a DataBead. If the value of the property "frequency" is either a UGen or can be interpreted as a float, the cutoff frequency will be set appropriately.

Specified by:
sendData in interface DataBeadReceiver
Parameters:
db - The DataBead message.
Returns:
Typically, the object instance: this.

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

drawFromLowOutput

public CrossoverFilter drawFromLowOutput(UGen target)

drawFromLowOutput

public CrossoverFilter drawFromLowOutput(int channel,
                                         UGen target,
                                         int targetInputIndex)

drawFromHighOutput

public CrossoverFilter drawFromHighOutput(UGen target)

drawFromHighOutput

public CrossoverFilter drawFromHighOutput(int channel,
                                          UGen target,
                                          int targetInputIndex)