net.beadsproject.beads.ugens
Class WavePlayer

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

public class WavePlayer
extends UGen

WavePlayer iterates over wave data stored in a Buffer. The frequency of the WavePlayer is controlled by a UGen, meaning that WavePlayers can easily be combined to perform FM synthesis or ring modulation. The simplest use of WavePlayer is: WavePlayer wp = new WavePlayer(ac, 440.f, Buffer.SINE);

Author:
ollie
See Also:
Buffer, SineBuffer, SawBuffer, SquareBuffer

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
WavePlayer(AudioContext context, float frequency, Buffer buffer)
          Instantiates a new WavePlayer with given static frequency and Buffer.
WavePlayer(AudioContext context, UGen frequencyController, Buffer buffer)
          Instantiates a new WavePlayer with given frequency envelope and Buffer.
 
Method Summary
 void calculateBuffer()
          Called by the signal chain to update this UGen's ouput data.
 Buffer getBuffer()
          Gets the Buffer.
 float getFrequency()
          Gets the current frequency.
 UGen getFrequencyEnvelope()
          Deprecated. Use getFrequencyUGen().
 UGen getFrequencyUGen()
          Gets the UGen that controls the frequency.
 float getPhase()
          Gets the current phase;
 UGen getPhaseEnvelope()
          Deprecated. Use getPhaseUGen().
 UGen getPhaseUGen()
          Gets the phase controller UGen, if there is one.
 WavePlayer setBuffer(Buffer b)
          Sets the Buffer.
 WavePlayer setFrequency(float frequency)
          Sets the frequency to a static value.
 WavePlayer setFrequency(UGen frequencyUGen)
          Sets a UGen to control the frequency.
 void setFrequencyEnvelope(UGen frequencyEnvelope)
          Deprecated. Use setFrequency(UGen).
 WavePlayer setPhase(float phase)
          Sets the phase.
 WavePlayer setPhase(UGen phaseController)
          Sets a UGen to control the phase.
 void setPhaseEnvelope(UGen phaseEnvelope)
          Deprecated. Use setPhase(UGen).
 void start()
          Shortcut for pause(false).
 
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, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WavePlayer

public WavePlayer(AudioContext context,
                  UGen frequencyController,
                  Buffer buffer)
Instantiates a new WavePlayer with given frequency envelope and Buffer.

Parameters:
context - the AudioContext.
frequencyController - the frequency envelope.
buffer - the Buffer.

WavePlayer

public WavePlayer(AudioContext context,
                  float frequency,
                  Buffer buffer)
Instantiates a new WavePlayer with given static frequency and Buffer.

Parameters:
context - the AudioContext.
frequency - the frequency in Hz.
buffer - the Buffer.
Method Detail

start

public void start()
Description copied from class: Bead
Shortcut for pause(false).

Overrides:
start in class Bead

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

getFrequencyEnvelope

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

Gets the frequency envelope.

Returns:
the frequency envelope.

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.

setFrequencyEnvelope

@Deprecated
public void setFrequencyEnvelope(UGen frequencyEnvelope)
Deprecated. Use setFrequency(UGen).

Sets the frequency envelope. Note, if the phase envelope is not null, the frequency envelope will have no effect.

Parameters:
frequencyEnvelope - the new frequency envelope.

setFrequency

public WavePlayer setFrequency(UGen frequencyUGen)
Sets a UGen to control the frequency. Note that if the phase envelope is not null, the frequency controller will have no effect.

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

setFrequency

public WavePlayer setFrequency(float frequency)
Sets the frequency to a static value. Note that if the phase envelope is not null, the frequency will have no effect.

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

getPhaseEnvelope

@Deprecated
public UGen getPhaseEnvelope()
Deprecated. Use getPhaseUGen().

Gets the phase envelope.

Returns:
the phase envelope.

getPhaseUGen

public UGen getPhaseUGen()
Gets the phase controller UGen, if there is one.

Returns:
The phase controller UGen.

getPhase

public float getPhase()
Gets the current phase;

Returns:
The current phase.

setPhaseEnvelope

@Deprecated
public void setPhaseEnvelope(UGen phaseEnvelope)
Deprecated. Use setPhase(UGen).

Sets the phase envelope.

Parameters:
phaseEnvelope - the new phase envelope.

setPhase

public WavePlayer setPhase(UGen phaseController)
Sets a UGen to control the phase. This will override any frequency controllers.

Parameters:
phaseController - The new phase controller.
Returns:
This WavePlayer instance.

setPhase

public WavePlayer setPhase(float phase)
Sets the phase. This will clear the phase controller UGen, if there is one.

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

setBuffer

public WavePlayer setBuffer(Buffer b)
Sets the Buffer.

Parameters:
b - The new Buffer.

getBuffer

public Buffer getBuffer()
Gets the Buffer.

Returns:
The Buffer.