net.beadsproject.beads.ugens
Class Envelope

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

public class Envelope
extends UGen

An Envelope generates a sequence of timed transitions (segments) between values as an audio signal. New segments are added to a running Envelope using variations of the method #addSegment(). With the method addSegment(float, float, float, Bead) a Bead can be provided which gets triggered when the segment has reached its destination. At any point in time, the Envelope maintains a current value. New segments define transitions from that current value to a destination value over a given duration. Instead of a linear transition, a curved transition can be used. The curve is defined as the mapping of the range [0,1] from y=x to y=x^p with a given exponent p.

Author:
ollie

Nested Class Summary
 class Envelope.Segment
          The nested class Segment.
 
Field Summary
 
Fields inherited from class net.beadsproject.beads.core.UGen
bufferSize, bufIn, bufOut, context, ins, outs
 
Constructor Summary
Envelope(AudioContext context)
          Instantiates a new Envelope with start value 0.
Envelope(AudioContext context, float value)
          Instantiates a new Envelope with the specified start value.
 
Method Summary
 void addSegment(float endValue, float duration)
          Adds a new Segment.
 void addSegment(float endValue, float duration, Bead trigger)
          Adds a new Segment.
 void addSegment(float endValue, float duration, float curvature, Bead trigger)
          Adds a new Segment.
 void calculateBuffer()
          Called by the signal chain to update this UGen's ouput data.
 void clear()
          Clears the list of Segments.
 float getCurrentValue()
          Gets the current value.
 boolean isLocked()
          Checks whether the Envelope is locked.
 void lock(boolean lock)
          Locks/unlocks the Envelope.
 void setValue(float value)
          Clears the list of Segments and sets the current value of the Envelope immediately.
 
Methods inherited from class net.beadsproject.beads.core.UGen
addDependent, addInput, addInput, clearInputConnections, getContext, getIns, getNumberOfConnectedUGens, getOuts, getValue, getValue, noInputs, pause, printInputList, printOutBuffers, removeAllConnections, removeDependent, 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

Envelope

public Envelope(AudioContext context)
Instantiates a new Envelope with start value 0.

Parameters:
context - the AudioContext.

Envelope

public Envelope(AudioContext context,
                float value)
Instantiates a new Envelope with the specified start value.

Parameters:
context - the AudioContext.
value - the start value.
Method Detail

lock

public void lock(boolean lock)
Locks/unlocks the Envelope.


isLocked

public boolean isLocked()
Checks whether the Envelope is locked.

Returns:
true if the Envelope is locked.

addSegment

public void addSegment(float endValue,
                       float duration,
                       float curvature,
                       Bead trigger)
Adds a new Segment.

Parameters:
endValue - the destination value.
duration - the duration.
curvature - the exponent of the curve.
trigger - the trigger.

addSegment

public void addSegment(float endValue,
                       float duration)
Adds a new Segment.

Parameters:
endValue - the destination value.
duration - the duration.

addSegment

public void addSegment(float endValue,
                       float duration,
                       Bead trigger)
Adds a new Segment.

Parameters:
endValue - the destination value.
duration - the duration.
trigger - the trigger.

setValue

public void setValue(float value)
Clears the list of Segments and sets the current value of the Envelope immediately.

Overrides:
setValue in class UGen
Parameters:
value - the new value.
See Also:
com.olliebown.beads.core.UGen#setValue(float)

clear

public void clear()
Clears the list of Segments.


getCurrentValue

public float getCurrentValue()
Gets the current value.

Returns:
the current value.

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