com.icdif.audio.analysis
Class PeakDetector

java.lang.Object
  extended by com.icdif.audio.analysis.PeakDetector

public class PeakDetector
extends java.lang.Object

This class receives the Detection Function and calculates the Onsets. In order to do this, first it calculates the threshold values, then it chooses from the Detection Function the values bigger than the threshold and, finally, it selects the peaks from this last array

Author:
wanderer

Constructor Summary
PeakDetector(java.util.ArrayList<java.lang.Float> detectionFunction)
          Instantiates the class by passing the spectral Flux that'll be used to calculate the threshold
PeakDetector(java.util.ArrayList<java.lang.Float> detectionFunction, int thresholdWindowSize, float multiplier)
          Instantiates this class by passing the spectral Flux and the parameters that'll be used to calculate the threshold and the peaks.
 
Method Summary
 void calcPeaks()
          Fills the array containing the peaks.
 java.util.ArrayList<java.lang.Float> getDetectionFunction()
           
 java.util.ArrayList<java.lang.Float> getFilteredSpectralFlux()
           
 java.util.ArrayList<java.lang.Double> getOnsets()
          Gets the onsets as instants in time
 java.util.ArrayList<java.lang.Float> getPeaks()
          An array containing the peaks and zeros
 java.util.ArrayList<java.lang.Double> getPeaksAsInstantsInTime(int spectralWindowSize, int sampleRate)
          Gets an array containing the time instants (in seconds) of every onset TODO: Cuidado q os parametros a receber aqui podem ser diferentes para outras funções de detecção
 java.util.ArrayList<java.lang.Float> getThreshold()
           
 void printOnsetsToFile(java.lang.String filename)
          Prints the time instants onsets to a file
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PeakDetector

public PeakDetector(java.util.ArrayList<java.lang.Float> detectionFunction)
Instantiates the class by passing the spectral Flux that'll be used to calculate the threshold

Parameters:
detectionFunction -

PeakDetector

public PeakDetector(java.util.ArrayList<java.lang.Float> detectionFunction,
                    int thresholdWindowSize,
                    float multiplier)
Instantiates this class by passing the spectral Flux and the parameters that'll be used to calculate the threshold and the peaks.

Parameters:
detectionFunction -
thresholdWindowSize - - by default it is 10 samples in each side
multiplier - - by default it is 1.6
Method Detail

calcPeaks

public void calcPeaks()
Fills the array containing the peaks. Any value > 0 in this array is a peak. In order to calculate the peaks, it needs to calculate the threshold and the filtered Detection Function as intermediate steps.


getPeaksAsInstantsInTime

public java.util.ArrayList<java.lang.Double> getPeaksAsInstantsInTime(int spectralWindowSize,
                                                                      int sampleRate)
Gets an array containing the time instants (in seconds) of every onset TODO: Cuidado q os parametros a receber aqui podem ser diferentes para outras funções de detecção

Parameters:
spectralWindowSize - the size of the spectral window, i.e., the hopsize
sampleRate - the sample rate of the signal
Returns:
the time instances of every onset

printOnsetsToFile

public void printOnsetsToFile(java.lang.String filename)
Prints the time instants onsets to a file

Parameters:
filename - the full path of the file where to write

getDetectionFunction

public java.util.ArrayList<java.lang.Float> getDetectionFunction()
Returns:
the spectralFlux

getThreshold

public java.util.ArrayList<java.lang.Float> getThreshold()
Returns:
the threshold

getFilteredSpectralFlux

public java.util.ArrayList<java.lang.Float> getFilteredSpectralFlux()
Returns:
the filteredSpectralFlux

getPeaks

public java.util.ArrayList<java.lang.Float> getPeaks()
An array containing the peaks and zeros

Returns:
the peaks

getOnsets

public java.util.ArrayList<java.lang.Double> getOnsets()
Gets the onsets as instants in time

Returns:
the array list of onsets