net.beadsproject.beads.analysis.featureextractors
Class OnsetDetector

java.lang.Object
  extended by net.beadsproject.beads.core.Bead
      extended by net.beadsproject.beads.analysis.FeatureExtractor<float[],float[]>
          extended by net.beadsproject.beads.analysis.featureextractors.OnsetDetector

public class OnsetDetector
extends FeatureExtractor<float[],float[]>

Detects peaks in a continuous stream of one element inputs. Attach to an OnsetDetectionFunction (like SpectralDifference) to get Onsets. Use addMessageListener to receive a message when an onset is detected. The algorithm follows the one described in: Dixon, S (2006) "Onset Detection Revisited" Proc. of the 9th Int. Conference on Digital Audio Effects (DAFx-06), Montreal, Canada, September 18-20, 2006

Author:
ben

Field Summary
protected  java.util.ArrayList<FeatureExtractor<?,float[]>> thresholdListeners
          thresholdListeners receive the filtered threshold value TODO: DISABLE AFTER DEBUG, BP170309
 
Fields inherited from class net.beadsproject.beads.analysis.FeatureExtractor
featureDescriptions, features, name, numFeatures
 
Constructor Summary
OnsetDetector()
           
 
Method Summary
 void addMessageListener(Bead b)
           
 void addThresholdListener(FeatureExtractor<?,float[]> fe)
           
 int getBufferSize()
          Get the correct BufferSize for the OnsetDetector Any
 int getLagInFrames()
           
 float getLastOnsetValue()
           
 void process(float[] input)
          process: assumes input is a 1 element array
 void removeMessageListener(Bead b)
           
 void setAlpha(float alpha)
           
 void setFilter(Buffer b)
          Sets the window for the local averaging.
 void setThreshold(float thresh)
           
 
Methods inherited from class net.beadsproject.beads.analysis.FeatureExtractor
getFeatureDescriptions, getFeatures, getName, getNumberOfFeatures, setName, setNumberOfFeatures
 
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

thresholdListeners

protected java.util.ArrayList<FeatureExtractor<?,float[]>> thresholdListeners
thresholdListeners receive the filtered threshold value TODO: DISABLE AFTER DEBUG, BP170309

Constructor Detail

OnsetDetector

public OnsetDetector()
Method Detail

setThreshold

public void setThreshold(float thresh)

setAlpha

public void setAlpha(float alpha)

getLastOnsetValue

public float getLastOnsetValue()
Returns:
the value at the last onset

getLagInFrames

public int getLagInFrames()
Returns:
The lag in frames between onsets occurring and actually being detected

getBufferSize

public int getBufferSize()
Get the correct BufferSize for the OnsetDetector Any

Returns:

setFilter

public void setFilter(Buffer b)
Sets the window for the local averaging.

Parameters:
b - Buffer must be of size == getBufferSize(), and integrates to 1.

process

public void process(float[] input)
process: assumes input is a 1 element array

Specified by:
process in class FeatureExtractor<float[],float[]>
Parameters:
input - the data.

addMessageListener

public void addMessageListener(Bead b)

removeMessageListener

public void removeMessageListener(Bead b)

addThresholdListener

public void addThresholdListener(FeatureExtractor<?,float[]> fe)