net.beadsproject.beads.core
Class Bead

java.lang.Object
  extended by net.beadsproject.beads.core.Bead
Direct Known Subclasses:
AudioContextStopTrigger, BeadArray, FeatureRecorder, KillTrigger, Pattern, PauseTrigger, StartTrigger, UGen

public abstract class Bead
extends java.lang.Object

Bead is an abstract class which defines basic behaviour such as starting and stopping, pausing and handling messages.

Messages: A Bead can send a message to another Bead using the message(Bead) method. Implementations of Bead handle these messages by subclassing the messageReceived(Bead) method. BeadArray can be used to gather Beads into groups, which is useful for defining message channels in a system.

Pausing: the method pause(boolean) toggles the pause mode of a Bead. Beads are unpaused by default. A paused Bead will no longer respond to incoming messages.

Deleting: The method kill() deletes a Bead. Deleted Beads are automatically removed from BeadArrays. The method setKillListener(Bead) allows you to specify another Bead that gets notified when this Bead is killed.

UGens: An important subclass of Bead is UGen. When a UGen is paused, it does not calculate audio. When it is deleted, it is automatically removed from any signal chains.

Author:
ollie

Constructor Summary
Bead()
          Instantiates a new bead.
 
Method Summary
 Bead getKillListener()
          Gets this Bead's kill listener.
 java.lang.String getName()
          Gets the Bead's name.
 boolean isDeleted()
          Determines if this Bead is deleted.
 boolean isPaused()
          Checks if this Bead is paused.
 void kill()
          Stops this Bead, and flags it as deleted.
 void message(Bead message)
          Send this Bead a message.
protected  void messageReceived(Bead message)
          Responds to an incoming message.
 void pause(boolean paused)
          Toggle the paused state of the Bead.
 void setKillListener(Bead killListener)
          Sets this Bead's kill listener.
 void setName(java.lang.String name)
          Sets the Bead's name.
 void start()
          Shortcut for pause(false).
 java.lang.String toString()
          Returns a String specifying the Bead's class and it's name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Bead

public Bead()
Instantiates a new bead.

Method Detail

getName

public java.lang.String getName()
Gets the Bead's name.

Returns:
the name.

setName

public void setName(java.lang.String name)
Sets the Bead's name.

Parameters:
name - the new name.

toString

public java.lang.String toString()
Returns a String specifying the Bead's class and it's name.

Overrides:
toString in class java.lang.Object
Returns:
String describing the Bead.

message

public final void message(Bead message)
Send this Bead a message. Typically if another Bead was sending the message, it would send itself as the argument.

Parameters:
message - the Bead is the message.

messageReceived

protected void messageReceived(Bead message)
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.

Parameters:
message - the message

start

public void start()
Shortcut for pause(false).


kill

public void kill()
Stops this Bead, and flags it as deleted. This means that the Bead will automatically be removed from any BeadArrays.


isPaused

public boolean isPaused()
Checks if this Bead is paused.

Returns:
true if paused

pause

public void pause(boolean paused)
Toggle the paused state of the Bead.

Parameters:
paused - true to pause Bead.

setKillListener

public void setKillListener(Bead killListener)
Sets this Bead's kill listener. The kill listener will receive a message containing this Bead as an argument when this Bead is killed.

Parameters:
killListener - the new kill listener.

getKillListener

public Bead getKillListener()
Gets this Bead's kill listener.

Returns:
the kill listener.

isDeleted

public boolean isDeleted()
Determines if this Bead is deleted.

Returns:
true if this Bead's state is deleted, false otherwise.