jAudioFeatureExtractor.AudioFeatures
Class PeakFinder

java.lang.Object
  extended by jAudioFeatureExtractor.AudioFeatures.FeatureExtractor
      extended by jAudioFeatureExtractor.AudioFeatures.PeakFinder

public class PeakFinder
extends FeatureExtractor

Implements a very basic peak detection algorithm. Peaks are calculated by finding local maximum in the values of the frequency bins. All maxima within a threshold of the largest value is considered a peak. The thresholds of all peaks are provided in order without its bin location in the original signal.

Author:
Daniel McEnnis

Field Summary
 
Fields inherited from class jAudioFeatureExtractor.AudioFeatures.FeatureExtractor
definition, dependencies, offsets, parent
 
Constructor Summary
PeakFinder()
          Basic constructor that sets the definition and dependencies (and their offsets) of this feature.
 
Method Summary
 java.lang.Object clone()
          Create an identical copy of this feature.
 double[] extractFeature(double[] samples, double sampling_rate, double[][] other_feature_values)
          Extracts a set of peaks from this window.
 java.lang.String getElement(int index)
          Function permitting an unintelligent outside function (ie.
 void setElement(int index, java.lang.String value)
          Function permitting an unintelligent outside function (ie.
 void setPeakThreshold(int peak)
          Sets the minumum fraction of the max point that will register as a peak.
 
Methods inherited from class jAudioFeatureExtractor.AudioFeatures.FeatureExtractor
getDepenedencies, getDepenedencyOffsets, getFeatureDefinition, setParent, setWindow
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PeakFinder

public PeakFinder()
Basic constructor that sets the definition and dependencies (and their offsets) of this feature.

Method Detail

extractFeature

public double[] extractFeature(double[] samples,
                               double sampling_rate,
                               double[][] other_feature_values)
                        throws java.lang.Exception
Extracts a set of peaks from this window.

Specified by:
extractFeature in class FeatureExtractor
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.

As a metafeature, recursively calls children for the feature requested.

Overrides:
getElement in class FeatureExtractor
Parameters:
index - which of AreaMoment's attributes should be edited.
Throws:
java.lang.Exception

setPeakThreshold

public void setPeakThreshold(int peak)
                      throws java.lang.Exception
Sets the minumum fraction of the max point that will register as a peak. The value is interpreted as 1/N of the maximum.

Parameters:
peak - sets 1/N as threshold for peak detection.
Throws:
java.lang.Exception - thrown if a non-positive threshold is set.

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.

As a metafeature, recursively calls children to set the feature requested.

Overrides:
setElement in class FeatureExtractor
Parameters:
index - attribute to be set
value - new value of the attribute
Throws:
java.lang.Exception

clone

public 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.

Specified by:
clone in class FeatureExtractor