net.beadsproject.beads.analysis
Class FeatureTrack

java.lang.Object
  extended by net.beadsproject.beads.analysis.FeatureTrack
All Implemented Interfaces:
java.io.Serializable, java.lang.Iterable<FeatureFrame>, SegmentListener

public class FeatureTrack
extends java.lang.Object
implements java.io.Serializable, java.lang.Iterable<FeatureFrame>, SegmentListener

Stores a set of features associated with a continuous period of audio data. A FeatureTrack can hold different views on the data. Time-based features are stored in lists mapping segments to features.

Author:
ollie
See Also:
Serialized Form

Constructor Summary
FeatureTrack()
          Instantiates a new FeatureTrack.
 
Method Summary
 void add(FeatureFrame ff)
          Adds the specified FeatureFrame.
 void addFeatureExtractor(FeatureExtractor<?,?> e)
          Adds a new FeatureExtractor.
 void clear()
          Clears all memory of feature frames.
 FeatureFrame get(int index)
          Gets the FeatureFrame at the given index.
 FeatureFrame getFrameAt(double timeMS)
          Gets the frame for the given offset, in milliseconds, into the FeatureLayer.
 FeatureFrame getFrameBefore(double timeMS)
          Gets the frame for the given offset, in milliseconds, into the FeatureLayer, or the last frame before then.
 int getFrameMemory()
           
 FeatureFrame getLastFrame()
          Gets the last FeatureFrame in this FeatureTrack.
 int getNumberOfFrames()
          Returns the number of FeatureFrames stored in this FeatureTrack.
 java.util.Iterator<FeatureFrame> iterator()
          Returns an iterator over the FeatureFrames.
 void newSegment(TimeStamp startTime, TimeStamp endTime)
          Tells this FeatureTrack to log a new FeatureFrame, with the given startTime and endTime.
 void remove(FeatureFrame ff)
          Removes the specified FeatureFrame.
 void removeFeatureExtractor(FeatureExtractor<?,?> e)
          Removes the specified FeatureExtractor.
 void removeRange(double startRangeMS, double endRangeMS)
          Remove all feature frames in the given range.
 void setFrameMemory(int frameMemory)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FeatureTrack

public FeatureTrack()
Instantiates a new FeatureTrack.

Method Detail

add

public void add(FeatureFrame ff)
Adds the specified FeatureFrame. Note that this will not add the frame if there is already a frame with the same start time. Use removeRange to make space available.

Parameters:
ff - the FeatureFrame.

remove

public void remove(FeatureFrame ff)
Removes the specified FeatureFrame.

Parameters:
ff - the FeatureFrame to remove.

removeRange

public void removeRange(double startRangeMS,
                        double endRangeMS)
Remove all feature frames in the given range.

Parameters:
startRangeMS - the beginning of the range.
endRangeMS - the end of the range.

get

public FeatureFrame get(int index)
Gets the FeatureFrame at the given index.

Parameters:
index - the index.
Returns:
the FeatureFrame.

getFrameAt

public FeatureFrame getFrameAt(double timeMS)
Gets the frame for the given offset, in milliseconds, into the FeatureLayer.

Parameters:
timeMS - the millisecond offset.
Returns:
the FeatureFrame at this time.

getFrameBefore

public FeatureFrame getFrameBefore(double timeMS)
Gets the frame for the given offset, in milliseconds, into the FeatureLayer, or the last frame before then.

Parameters:
timeMS - the millisecond offset.
Returns:
the FeatureFrame at this time.

getLastFrame

public FeatureFrame getLastFrame()
Gets the last FeatureFrame in this FeatureTrack.

Returns:
the last FeatureFrame in this FeatureTrack.

addFeatureExtractor

public void addFeatureExtractor(FeatureExtractor<?,?> e)
Adds a new FeatureExtractor. When newSegment() is called, the FeatureTrack creates a new FeatureFrame with the given start and end times and adds the data from all of its FeatureExtractors to the FeatureFrame.

Parameters:
e - the FeatureExtractor.

removeFeatureExtractor

public void removeFeatureExtractor(FeatureExtractor<?,?> e)
Removes the specified FeatureExtractor.

Parameters:
e - the FeatureExtractor.

newSegment

public void newSegment(TimeStamp startTime,
                       TimeStamp endTime)
Tells this FeatureTrack to log a new FeatureFrame, with the given startTime and endTime. The FeatureTrack will gather features from its various FeatureExtractors at this point.

Specified by:
newSegment in interface SegmentListener
Parameters:
startTime - the start time.
endTime - the end time.
Throws:
java.lang.CloneNotSupportedException

iterator

public java.util.Iterator<FeatureFrame> iterator()
Returns an iterator over the FeatureFrames.

Specified by:
iterator in interface java.lang.Iterable<FeatureFrame>

getFrameMemory

public int getFrameMemory()

setFrameMemory

public void setFrameMemory(int frameMemory)

getNumberOfFrames

public int getNumberOfFrames()
Returns the number of FeatureFrames stored in this FeatureTrack.

Returns:
number of FeatureFrames.

clear

public void clear()
Clears all memory of feature frames.