net.beadsproject.beads.analysis
Class FeatureExtractor<R,P>

java.lang.Object
  extended by net.beadsproject.beads.core.Bead
      extended by net.beadsproject.beads.analysis.FeatureExtractor<R,P>
Direct Known Subclasses:
BasicDataWriter, BasicTimeDataWriter, FFT, Frequency, MelSpectrum, MFCC, PeakDetector, Power, PowerSpectrum, ReBin, SpectralCentroid, SpectralDifference, SpectralPeaks

public abstract class FeatureExtractor<R,P>
extends Bead

FeatureExtractor is an abstract base class for classes that perform some kind of analysis on incoming data. Both the incoming data (P) and the generated data (R) are generic types. Implementing classes use the method process(net.beadsproject.beads.core.TimeStamp, net.beadsproject.beads.core.TimeStamp, P) to process data.

Author:
ollie

Field Summary
protected  java.lang.String[] featureDescriptions
          An array of Strings providing descriptions of the feature data.
protected  R features
          The current feature data.
protected  java.lang.String name
          The name of the FeatureExtractor.
protected  int numFeatures
          The number of features.
 
Constructor Summary
FeatureExtractor()
          Instantiates a new FeatureExtractor.
 
Method Summary
 void addListener(FeatureExtractor<?,R> listener)
          Adds a FeatureExtractor to listen to this FeatureExtractor.
 void forward(TimeStamp startTime, TimeStamp endTime)
          Subclasses should call this at end of their process() method to forward features to listeners.
 java.lang.String[] getFeatureDescriptions()
          Gets the feature descriptions.
 R getFeatures()
          Gets the current features of type R, specified in the class def.
 java.lang.String getName()
          Gets the name.
 int getNumberOfFeatures()
          Gets the number of features.
abstract  void process(TimeStamp startTime, TimeStamp endTime, P data)
          Process some data of type P (specified by the class def).
 void removeListener(FeatureExtractor<?,R> listener)
          Removes a FeatureExtractor from the list of listeners.
 void setName(java.lang.String name)
          Sets the name.
 void setNumberOfFeatures(int numFeatures)
          Sets the number of features.
 
Methods inherited from class net.beadsproject.beads.core.Bead
getKillListener, isDeleted, isPaused, kill, message, messageReceived, pause, setKillListener, start, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

numFeatures

protected int numFeatures
The number of features.


features

protected R features
The current feature data.


name

protected java.lang.String name
The name of the FeatureExtractor.


featureDescriptions

protected java.lang.String[] featureDescriptions
An array of Strings providing descriptions of the feature data.

Constructor Detail

FeatureExtractor

public FeatureExtractor()
Instantiates a new FeatureExtractor. This constructor names the FeatureExtractor with the name of the implementing class.

Method Detail

process

public abstract void process(TimeStamp startTime,
                             TimeStamp endTime,
                             P data)
Process some data of type P (specified by the class def). This method must be overidden by implementing classes.

Parameters:
data - the data.

forward

public void forward(TimeStamp startTime,
                    TimeStamp endTime)
Subclasses should call this at end of their process() method to forward features to listeners.


addListener

public void addListener(FeatureExtractor<?,R> listener)
Adds a FeatureExtractor to listen to this FeatureExtractor.

Parameters:
listener - the FeatureExtractor that listens to this one.

removeListener

public void removeListener(FeatureExtractor<?,R> listener)
Removes a FeatureExtractor from the list of listeners.

Parameters:
listener - the FeatureExtractor to remove.

getFeatures

public R getFeatures()
Gets the current features of type R, specified in the class def.

Returns:
the features.

getNumberOfFeatures

public int getNumberOfFeatures()
Gets the number of features.

Returns:
the number of features.

setNumberOfFeatures

public void setNumberOfFeatures(int numFeatures)
Sets the number of features.

Parameters:
numFeatures - the new number of features.

setName

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

Overrides:
setName in class Bead
Parameters:
name - the new name.

getName

public java.lang.String getName()
Gets the name.

Overrides:
getName in class Bead
Returns:
the name.

getFeatureDescriptions

public java.lang.String[] getFeatureDescriptions()
Gets the feature descriptions. Implementing classes should make sure that this array has meaningful content.

Returns:
the feature descriptions.