net.beadsproject.beads.ugens
Class Compressor

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

public class Compressor
extends UGen
implements DataBeadReceiver

A simple multi-channel dynamic range compression UGen. Users can vary the threshold (set in RMS power units), the compression ratio, the rate of attack/decay, look-ahead time (delay), and the hardness/softness of the knee. The amount of compression can also be controlled by an alternate side-chain.

The following are the default parameter values:

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
 
Fields inherited from class net.beadsproject.beads.core.UGen
bufferSize, bufIn, bufOut, context, ins, outputInitializationRegime, outputPauseRegime, outs
 
Constructor Summary
Compressor(AudioContext context)
          Constructor for a 1-channel compressor with no look-ahead time and other parameters set to their default values.
Compressor(AudioContext context, int channels)
          Constructor for a multi-channel compressor with no look-ahead time and other parameters set to their default values.
Compressor(AudioContext context, int channels, float lookAheadDelay)
          Constructor for a multi-channel compressor with the specified look-ahead time and other parameters set to their default values.
Compressor(AudioContext context, int channels, float lookAheadDelay, UGen sideChain)
          Constructor for a multi-channel compressor with the specified look-ahead time and side-chain, and other parameters set to their default values.
Compressor(AudioContext context, int channels, UGen sideChain)
          Constructor for a multi-channel compressor with the specified side-chain, no look-ahead time, and other parameters set to their default values.
 
Method Summary
 void calculateBuffer()
          Called by the signal chain to update this UGen's ouput data.
 float getAttack()
          Gets the attack factor.
 float getCurrentCompression()
          Gets the current scaling factor - the factor which scales the incoming signal, determined by the side chain.
 float getDecay()
          Gets the decay factor.
 float getKnee()
          Gets the knee softness.
 DataBead getParams()
          Gets a DataBead filled with properties set to corresponding compressor parameters: "threshold", "ratio", "attack", "decay", "knee".
 float getRatio()
          Gets the compression ratio.
 float getThreshold()
          Gets the threshold value.
 DataBeadReceiver sendData(DataBead db)
          Sets the compressor parameters with a DataBead.
 Compressor setAttack(float attack)
          Sets the attack factor.
 Compressor setDecay(float decay)
          Sets the decay factor.
 Compressor setKnee(float knee)
          Sets the knee softness.
 Compressor setRatio(float ratio)
          Sets the compression ratio.
 Compressor setSideChain(UGen sideChain)
          Sets the side chain.
 Compressor setThreshold(float threshold)
          Sets the threshold value.
 
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, messageReceived, setKillListener, setName, start, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Compressor

public Compressor(AudioContext context)
Constructor for a 1-channel compressor with no look-ahead time and other parameters set to their default values.

Parameters:
context - The audio context.

Compressor

public Compressor(AudioContext context,
                  int channels)
Constructor for a multi-channel compressor with no look-ahead time and other parameters set to their default values.

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

Compressor

public Compressor(AudioContext context,
                  int channels,
                  UGen sideChain)
Constructor for a multi-channel compressor with the specified side-chain, no look-ahead time, and other parameters set to their default values.

Parameters:
context - The audio context.
channels - The number of channels.
sideChain - The UGen to use as the side-chain.

Compressor

public Compressor(AudioContext context,
                  int channels,
                  float lookAheadDelay)
Constructor for a multi-channel compressor with the specified look-ahead time and other parameters set to their default values.

Parameters:
context - The audio context.
channels - The number of channels.
lookAheadDelay - The look-ahead time in milliseconds.

Compressor

public Compressor(AudioContext context,
                  int channels,
                  float lookAheadDelay,
                  UGen sideChain)
Constructor for a multi-channel compressor with the specified look-ahead time and side-chain, and other parameters set to their default values.

Parameters:
context - The audio context.
channels - The number of channels.
lookAheadDelay - The look-ahead time in milliseconds.
sideChain - The UGen to use as the side-chain.
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

setSideChain

public Compressor setSideChain(UGen sideChain)
Sets the side chain. The power of the side chain (measured by an RMS object) determines how much the compressor scales the input; by default (and if this method is passed null), the side chain is the same as the input.

Parameters:
sideChain - The side chain signal.
Returns:
This compressor instance.

getAttack

public float getAttack()
Gets the attack factor.

Returns:
The attack factor in decibels per millisecond.

setAttack

public Compressor setAttack(float attack)
Sets the attack factor.

Parameters:
attack - The attack factor in decibels per millisecond.
Returns:
This compressor instance.

getDecay

public float getDecay()
Gets the decay factor.

Returns:
The decay factor in decibels per millisecond.

setDecay

public Compressor setDecay(float decay)
Sets the decay factor.

Parameters:
decay - The decay factor in decibels per millisecond.
Returns:
This compressor instance.

getRatio

public float getRatio()
Gets the compression ratio.

Returns:
The compression ratio.

setRatio

public Compressor setRatio(float ratio)
Sets the compression ratio. (For example, a value of 2.4 yields a 2.4:1 compression ratio over the threshold. Values less than 1 will yield expansion rather than compression.)

Parameters:
ratio - The compression ratio.
Returns:
This compressor instance.

getThreshold

public float getThreshold()
Gets the threshold value.

Returns:
The threshold.

setThreshold

public Compressor setThreshold(float threshold)
Sets the threshold value.

Parameters:
threshold - The threshold.
Returns:
This compressor instance.

getKnee

public float getKnee()
Gets the knee softness.

Returns:
The knee softness.

setKnee

public Compressor setKnee(float knee)
Sets the knee softness. 0 results in a strictly hard knee; the higher the value, the more curvature to the knee.

Parameters:
knee - The knee softness.
Returns:
This compressor instance.

sendData

public DataBeadReceiver sendData(DataBead db)
Sets the compressor parameters with a DataBead. Use the following property names: "threshold", "ratio", "attack", "decay", "knee", and "sidechain".

Specified by:
sendData in interface DataBeadReceiver
Parameters:
db - The parameter DataBead.
Returns:
This compressor instance.

getParams

public DataBead getParams()
Gets a DataBead filled with properties set to corresponding compressor parameters: "threshold", "ratio", "attack", "decay", "knee".

Returns:
The

getCurrentCompression

public float getCurrentCompression()
Gets the current scaling factor - the factor which scales the incoming signal, determined by the side chain.

Returns:
The compression factor.