net.beadsproject.beads.analysis
Class Segmenter

java.lang.Object
  extended by net.beadsproject.beads.core.Bead
      extended by net.beadsproject.beads.core.UGen
          extended by net.beadsproject.beads.analysis.Segmenter
Direct Known Subclasses:
ShortFrameSegmenter, SimplePowerOnsetDetector

public abstract class Segmenter
extends UGen

A Segmenter is an abstract base class for classes that divide a stream of audio data into segments. Whenever a segment is created, using the method segment(float[], int), it is passed on to any FeatureExtractors that are registered as responders to this Segmenter. Other Beads can be added as listeners, that are triggered when segment(float[], int) is called. An implementation of a Segmenter must implement the method UGen.calculateBuffer(), and determine when segment(float[], int) should be called, passing the audio data accordingly (this may require the Segmenter to record audio data). In addition, the Segmenter keeps track of analysis data in a FeatureTrack for any FeatureExtractors registered as extractors with this Segmenter.

NOTE: It is critical that the second argument passed to the method segment(float[], int) correctly indicates the length since the previous segment.

Author:
ollie

Field Summary
protected  double currentTime
          The current time in milliseconds since start.
protected  double previousEndTime
          The previous end time in milliseconds since start.
 
Fields inherited from class net.beadsproject.beads.core.UGen
bufferSize, bufIn, bufOut, context, ins, outs
 
Constructor Summary
Segmenter(AudioContext context)
          Instantiates a new Segmenter.
 
Method Summary
 void addListener(Bead bead)
          Adds a Bead as a listener.
 void addListener(FeatureExtractor<?,float[]> fe)
          Adds a FeatureExtractor as a responder to this Segmenter.
protected  void segment(float[] data, int sampleOffset)
          Called by instantiations of Segmenter, to indicate that a new segment has been created.
 void startTime()
          Sets the start time to now (now being determined by the AudioContext).
 java.lang.String toString()
          Returns a String specifying the Bead's class and it's name.
 
Methods inherited from class net.beadsproject.beads.core.UGen
addDependent, addInput, addInput, calculateBuffer, clearInputConnections, getContext, getIns, getNumberOfConnectedUGens, getOuts, getValue, getValue, noInputs, pause, printInputList, printOutBuffers, removeAllConnections, removeDependent, setValue, update, zeroIns, zeroOuts
 
Methods inherited from class net.beadsproject.beads.core.Bead
getKillListener, getName, isDeleted, isPaused, kill, message, messageReceived, setKillListener, setName, start
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

currentTime

protected double currentTime
The current time in milliseconds since start.


previousEndTime

protected double previousEndTime
The previous end time in milliseconds since start.

Constructor Detail

Segmenter

public Segmenter(AudioContext context)
Instantiates a new Segmenter.

Parameters:
context - the AudioContext.
Method Detail

startTime

public void startTime()
Sets the start time to now (now being determined by the AudioContext).


addListener

public void addListener(FeatureExtractor<?,float[]> fe)
Adds a FeatureExtractor as a responder to this Segmenter.

Parameters:
fe - the FeatureExtractor.

addListener

public void addListener(Bead bead)
Adds a Bead as a listener. Listeners are triggered whenever the segment(float[], int) method is called.

Parameters:
bead - the Bead.

segment

protected void segment(float[] data,
                       int sampleOffset)
Called by instantiations of Segmenter, to indicate that a new segment has been created. The caller must pass the segment data as well as an integer indicating the number of samples since the last segment.

Parameters:
data - the audio data.
length - the number of samples since the previous data.

toString

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

Overrides:
toString in class Bead
Returns:
String describing the Bead.