net.beadsproject.beads.ugens
Class DelayEvent

java.lang.Object
  extended by net.beadsproject.beads.core.Bead
      extended by net.beadsproject.beads.core.UGen
          extended by net.beadsproject.beads.ugens.DelayEvent
Direct Known Subclasses:
DelayData, DelayTrigger

public abstract class DelayEvent
extends UGen

An abstract UGen that waits for a specified amount of time before "triggering" (executing some code). The trigger() method is called when the delay time has elapsed. DelayEvent is the base class for DelayTrigger (used to send Bead messages) and DelayData (used to send DataBeads).

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
DelayEvent(AudioContext context, double delay)
          Instantiates a new DelayEvent with the specified millisecond delay and receiver.
DelayEvent(AudioContext context, double delay, boolean triggerAfter)
          Instantiates a new DelayEvent with the specified millisecond delay and receiver.
 
Method Summary
 void calculateBuffer()
          Called by the signal chain to update this UGen's ouput data.
 double getCount()
          Gets the current count.
 double getSampleDelay()
          Gets the sample delay.
 boolean isTriggeredAfter()
          Returns true if the DelayEvent is triggered during the frame after the delay time expires; returns false if it is triggered during the frame in which the delay time expires.
 void reset()
          Reset timer to zero.
 DelayEvent setSampleDelay(float sampleDelay)
          Sets the sample delay; this may cause the DelayEvent to trigger immediately.
abstract  void trigger()
          Called when the delay time has elapsed.
 DelayEvent triggeredAfter(boolean f)
          Sets whether the Delay event fires during the frame in which the delay time expires (false, the default), or the frame after ( true).
 
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

DelayEvent

public DelayEvent(AudioContext context,
                  double delay)
Instantiates a new DelayEvent with the specified millisecond delay and receiver. By default, the object will be triggered at the beginning of the frame in which the delay time expires.

Parameters:
context - The audio context.
delay - The delay time in milliseconds.
receiver - The receiver.

DelayEvent

public DelayEvent(AudioContext context,
                  double delay,
                  boolean triggerAfter)
Instantiates a new DelayEvent with the specified millisecond delay and receiver. triggerAfter indicates whether the object is triggered at the beginning of the frame in which the delay time elapses ( false), or after (true).

Parameters:
context - The audio context.
delay - The delay in milliseconds.
receiver - The receiver.
triggerAfter - Whether the object fires just before or just after the delay time expires.
Method Detail

reset

public void reset()
Reset timer to zero.


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

trigger

public abstract void trigger()
Called when the delay time has elapsed. Implement this method with code to be executed after the delay.


getSampleDelay

public double getSampleDelay()
Gets the sample delay.

Returns:
the sample delay in milliseconds.

setSampleDelay

public DelayEvent setSampleDelay(float sampleDelay)
Sets the sample delay; this may cause the DelayEvent to trigger immediately.

Parameters:
sampleDelay - The new sample delay in milliseconds.
Returns:
This DelayEvent instance.

getCount

public double getCount()
Gets the current count.

Returns:
The count in milliseconds.

isTriggeredAfter

public boolean isTriggeredAfter()
Returns true if the DelayEvent is triggered during the frame after the delay time expires; returns false if it is triggered during the frame in which the delay time expires.

Returns:
True or false.

triggeredAfter

public DelayEvent triggeredAfter(boolean f)
Sets whether the Delay event fires during the frame in which the delay time expires (false, the default), or the frame after ( true).

Parameters:
f - Whether to fire after the frame when the delay time expires.
Returns:
This DelayEvent instance.