jAudioFeatureExtractor.AudioFeatures
Class FeatureExtractor

java.lang.Object
  extended by jAudioFeatureExtractor.AudioFeatures.FeatureExtractor
Direct Known Subclasses:
AreaMoments, AreaMomentsConstantQMFCC, AreaMomentsLogConstantQ, AreaMomentsMFCC, AreaPolynomialApproximation, AreaPolynomialApproximationConstantQMFCC, AreaPolynomialApproximationLogConstantQ, BeatHistogram, BeatHistogramLabels, BeatSum, Compactness, ConstantQ, ConstantQMFCC, FFTBinFrequencies, FractionOfLowEnergyWindows, HarmonicSpectralCentroid, HarmonicSpectralFlux, HarmonicSpectralSmoothness, LogConstantQ, LPC, LPCRemoved, MagnitudeSpectrum, MetaFeatureFactory, MFCC, Moments, PeakFinder, PowerSpectrum, RelativeDifferenceFunction, RMS, SpectralCentroid, SpectralFlux, SpectralRolloffPoint, SpectralVariability, StrengthOfStrongestBeat, StrongestBeat, StrongestFrequencyVariability, StrongestFrequencyViaFFTMax, StrongestFrequencyViaSpectralCentroid, StrongestFrequencyViaZeroCrossings, ZeroCrossings

public abstract class FeatureExtractor
extends java.lang.Object

The prototype for feature extractors. Each class that extends this class will extract a particular feature from a window of audio samples. Such classes do not store feature values, only extract them.

Classes that extend this class should have a constructor that sets the three protected fields of this class.

Daniel McEnnis 05-07-05 Added code to allow generic access to feature attributes

Daniel McEnnis 05-08-05 Added setWindow and setParent features following the composite pattern for new features.

Author:
Cory McKay

Field Summary
protected  FeatureDefinition definition
          Meta-data describing a feature.
protected  java.lang.String[] dependencies
          The names of other features that are needed in order for a feature to be calculated.
protected  int[] offsets
          The offset in windows of each of the features named in the dependencies field.
protected  DataModel parent
          If a feature alters its number of dimensions, it needs to be able to notify the holding object that a visible change has occured.
 
Constructor Summary
FeatureExtractor()
           
 
Method Summary
abstract  java.lang.Object clone()
          Create an identical copy of this feature.
abstract  double[] extractFeature(double[] samples, double sampling_rate, double[][] other_feature_values)
          The prototype function that classes extending this class will override in order to extract their feature from a window of audio.
 java.lang.String[] getDepenedencies()
          Returns the names of other features that are needed in order to extract this feature.
 int[] getDepenedencyOffsets()
          Returns the offsets of other features that are needed in order to extract this feature.
 java.lang.String getElement(int index)
          Function permitting an unintelligent outside function (ie.
 FeatureDefinition getFeatureDefinition()
          Returns meta-data describing this feature.
 void setElement(int index, java.lang.String value)
          Function permitting an unintelligent outside function (ie.
 void setParent(DataModel parent)
          Gives features a reference to the container frame to notify it that features have changed state and need to be redrawn.
 void setWindow(int windowSize)
          Function that must be overridden to allow this feature to be set globally by GlobalChange frame.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

definition

protected FeatureDefinition definition
Meta-data describing a feature.


dependencies

protected java.lang.String[] dependencies
The names of other features that are needed in order for a feature to be calculated. Will be null if there are no dependencies.


offsets

protected int[] offsets
The offset in windows of each of the features named in the dependencies field. An offset of -1, for example, means that the feature in dependencies with the same indice should be provided to this class's extractFeature method with a value that corresponds to the window prior to the window corresponding to this feature. Will be null if there are no dependencies. This must be null, 0 or a negative number. Positive numbers are not allowed.


parent

protected DataModel parent
If a feature alters its number of dimensions, it needs to be able to notify the holding object that a visible change has occured.

Constructor Detail

FeatureExtractor

public FeatureExtractor()
Method Detail

getFeatureDefinition

public FeatureDefinition getFeatureDefinition()
Returns meta-data describing this feature.

IMPORTANT: Note that a value of 0 in the returned dimensions of the FeatureDefinition implies that the feature dimensions are variable, and depend on the analyzed data.


getDepenedencies

public java.lang.String[] getDepenedencies()
Returns the names of other features that are needed in order to extract this feature. Will return null if no other features are needed.


getDepenedencyOffsets

public int[] getDepenedencyOffsets()
Returns the offsets of other features that are needed in order to extract this feature. Will return null if no other features are needed.

The offset is in windows, and the indice of the retuned array corresponds to the indice of the array returned by the getDependencies method. An offset of -1, for example, means that the feature returned by getDependencies with the same indice should be provided to this class's extractFeature method with a value that corresponds to the window prior to the window corresponding to this feature.


extractFeature

public abstract double[] extractFeature(double[] samples,
                                        double sampling_rate,
                                        double[][] other_feature_values)
                                 throws java.lang.Exception
The prototype function that classes extending this class will override in order to extract their feature from a window of audio.

Parameters:
samples - The samples to extract the feature from.
sampling_rate - The sampling rate that the samples are encoded with.
other_feature_values - The values of other features that are needed to calculate this value. The order and offsets of these features must be the same as those returned by this class's getDependencies and getDependencyOffsets methods respectively. The first indice indicates the feature/window and the second indicates the value.
Returns:
The extracted feature value(s).
Throws:
java.lang.Exception - Throws an informative exception if the feature cannot be calculated.

getElement

public java.lang.String getElement(int index)
                            throws java.lang.Exception
Function permitting an unintelligent outside function (ie. EditFeatures frame) to get the default values used to populate the table's entries. The correct index values are inferred from definition.attribute value.

Parameters:
index - which of AreaMoment's attributes should be edited.
Throws:
java.lang.Exception

setElement

public void setElement(int index,
                       java.lang.String value)
                throws java.lang.Exception
Function permitting an unintelligent outside function (ie. EditFeatures frame) to set the default values used to popylate the table's entries. Like getElement, the correct index values are inferred from the definition.attributes value.

Parameters:
index - attribute to be set
value - new value of the attribute
Throws:
java.lang.Exception

setWindow

public void setWindow(int windowSize)
               throws java.lang.Exception
Function that must be overridden to allow this feature to be set globally by GlobalChange frame.

Parameters:
windowSize - the number of windows of offset to be used in calculating this feature
Throws:
java.lang.Exception

setParent

public void setParent(DataModel parent)
Gives features a reference to the container frame to notify it that features have changed state and need to be redrawn.

Parameters:
parent - container frame which holds the model for displaying features in the feature display panel.

clone

public abstract java.lang.Object clone()
Create an identical copy of this feature. This permits FeatureExtractor to use the prototype pattern to create new composite features using metafeatures.

Overrides:
clone in class java.lang.Object