net.beadsproject.beads.ugens
Class Panner

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

public class Panner
extends UGen
implements DataBeadReceiver

A simple panning object that takes a mono input and gives stereo output. Power is kept constant regardless of position; note that center-panning a signal will yield the input signal multiplied by 1 / sqrt(2) in each output channel as a result. A pan value of -1 pans completely to the left, 1 pans completely to the right, and 0 results in center panning. It uses an array to approximate square roots for efficiency.

Version:
0.9.1
Author:
Benito Crawford

Nested Class Summary
 
Nested classes/interfaces inherited from class net.beadsproject.beads.core.UGen
UGen.OutputInitializationRegime, UGen.OutputPauseRegime
 
Field Summary
protected  boolean isPosStatic
           
protected  float p1
           
protected  float p2
           
protected  float pos
           
protected  UGen posUGen
           
static float[] ROOTS
           
protected static int rootSize
           
 
Fields inherited from class net.beadsproject.beads.core.UGen
bufferSize, bufIn, bufOut, context, ins, outputInitializationRegime, outputPauseRegime, outs
 
Constructor Summary
Panner(AudioContext con)
          Constructor that sets the pan to the middle by default.
Panner(AudioContext con, float ipos)
          Constructor that sets the pan to a static value.
Panner(AudioContext con, UGen posUGen)
          Constructor that sets a UGen to specify the pan value.
 
Method Summary
protected static float[] buildRoots(int rs)
          Calculates an array of square-roots from 0 to 1.
 void calculateBuffer()
          Called by the signal chain to update this UGen's ouput data.
 DataBead getParams()
          Gets a DataBead with the pan position (whether float or UGen), stored in the key "position".
 float getPos()
          Gets the current pan position.
 UGen getPosUGen()
          Gets the pan UGen, if it exists.
 DataBead getStaticParams()
          Gets a DataBead with property "position" set to its current float value.
 void messageReceived(Bead message)
          Responds to an incoming message.
 DataBeadReceiver sendData(DataBead db)
          Sets the pan position with a DataBead.
 Panner setParams(DataBead paramBead)
          Sets the parameter with a DataBead.
 Panner setPos(float pos)
          Sets the pan position to a static float value.
 Panner setPos(UGen posUGen)
          Sets a UGen to specify the pan position.
 
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

rootSize

protected static int rootSize

ROOTS

public static float[] ROOTS

pos

protected float pos

p1

protected float p1

p2

protected float p2

posUGen

protected UGen posUGen

isPosStatic

protected boolean isPosStatic
Constructor Detail

Panner

public Panner(AudioContext con)
Constructor that sets the pan to the middle by default.

Parameters:
con - The audio context.

Panner

public Panner(AudioContext con,
              float ipos)
Constructor that sets the pan to a static value.

Parameters:
con - The audio context.
ipos - The initial pan value.

Panner

public Panner(AudioContext con,
              UGen posUGen)
Constructor that sets a UGen to specify the pan value.

Parameters:
con - The audio context.
posUGen - The pan 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

buildRoots

protected static float[] buildRoots(int rs)
Calculates an array of square-roots from 0 to 1.

Parameters:
rs - The size of the array minus 2.
Returns:
The array.

getPos

public float getPos()
Gets the current pan position.

Returns:
The pan position.

setPos

public Panner setPos(float pos)
Sets the pan position to a static float value.

Parameters:
pos - The pan position.
Returns:
This Panner instance.

setPos

public Panner setPos(UGen posUGen)
Sets a UGen to specify the pan position.

Parameters:
posUGen - The pan UGen.
Returns:
This Panner instance.

getPosUGen

public UGen getPosUGen()
Gets the pan UGen, if it exists.

Returns:
The pan UGen.

setParams

public Panner setParams(DataBead paramBead)
Sets the parameter with a DataBead.

Use the "position" property to specify pan position.

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

Returns:
The DataBead with the stored parameter.

getStaticParams

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

Returns:
The DataBead with the static float parameter value.

sendData

public DataBeadReceiver sendData(DataBead db)
Sets the pan position with a DataBead.

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