net.beadsproject.beads.ugens
Class Phasor

java.lang.Object
  extended by net.beadsproject.beads.core.Bead
      extended by net.beadsproject.beads.core.UGen
          extended by net.beadsproject.beads.ugens.Phasor

public class Phasor
extends UGen

Produces a cycling linear ramp from 0 to 1, like the Phasor object in Max/MSP. More accurate than WavePlayer for slow speeds, as it calculates it's value for each sample, rather than stepping through a buffer.

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
protected  float frequency
           
protected  double one_over_sr
           
protected  double phase
           
 
Fields inherited from class net.beadsproject.beads.core.UGen
bufferSize, bufIn, bufOut, context, ins, outputInitializationRegime, outputPauseRegime, outs
 
Constructor Summary
Phasor(AudioContext con)
          Basic constructor.
Phasor(AudioContext con, float frequency)
          Constructor that sets the initial frequency to a float value.
Phasor(AudioContext con, UGen frequencyUGen)
          Constructor that sets a UGen to control the frequency.
 
Method Summary
 void calculateBuffer()
          Called by the signal chain to update this UGen's ouput data.
 float getFrequency()
          Gets the current frequency.
 UGen getFrequencyUGen()
          Gets the UGen that controls the frequency.
 float getPhase()
          Gets the current phase.
 Phasor setFrequency(float frequency)
          Sets the frequency to a static value.
 Phasor setFrequency(UGen frequencyUGen)
          Sets a UGen to control the frequency.
 Phasor setPhase(float phase)
          Sets the phase.
 
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
 

Field Detail

frequency

protected float frequency

phase

protected double phase

one_over_sr

protected double one_over_sr
Constructor Detail

Phasor

public Phasor(AudioContext con)
Basic constructor.

Parameters:
con - The AudioContext.

Phasor

public Phasor(AudioContext con,
              float frequency)
Constructor that sets the initial frequency to a float value.

Parameters:
con - The AudioContext.
frequency - The initial frequency.

Phasor

public Phasor(AudioContext con,
              UGen frequencyUGen)
Constructor that sets a UGen to control the frequency.

Parameters:
con - The AudioContext.
frequencyUGen - The frequency controller 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

getFrequencyUGen

public UGen getFrequencyUGen()
Gets the UGen that controls the frequency.

Returns:
The frequency controller UGen.

getFrequency

public float getFrequency()
Gets the current frequency.

Returns:
The current frequency.

setFrequency

public Phasor setFrequency(UGen frequencyUGen)
Sets a UGen to control the frequency.

Parameters:
frequencyUGen - The new frequency controller.
Returns:
This Phasor instance.

setFrequency

public Phasor setFrequency(float frequency)
Sets the frequency to a static value.

Parameters:
frequency - The new frequency value.
Returns:
This Phasor instance.

getPhase

public float getPhase()
Gets the current phase.

Returns:
The current phase.

setPhase

public Phasor setPhase(float phase)
Sets the phase.

Parameters:
phase - The new phase.
Returns:
This Phasor instance.