Class PitchDetector


  • public class PitchDetector
    extends java.lang.Object
    Perform pitch detection on an input signal using an autocorrelation estimate. The autocorrelation estimate is computed using the DFT (an FFT algorithm is used) for efficiency.
    Since:
    Ptolemy II 1.0
    Version:
    $Id$
    Author:
    Brian K. Vogel
    Pt.AcceptedRating:
    Red (vogel)
    Pt.ProposedRating:
    Red (vogel)
    • Constructor Summary

      Constructors 
      Constructor Description
      PitchDetector​(int vectorSize, int sampleRate)
      Initialize the pitch detector.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      double[] performPitchDetect​(double[] inputArray)
      Perform pitch detection.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PitchDetector

        public PitchDetector​(int vectorSize,
                             int sampleRate)
        Initialize the pitch detector. Parameter vectorSize sets the vector size to be used by performPitchDetect(). vectorSize may be any length.
        Parameters:
        vectorSize - The length of the array parameter to performPitchDetect().
        sampleRate - The sample rate to use, in Hz. 22050 or 44100 is recomended.
    • Method Detail

      • performPitchDetect

        public double[] performPitchDetect​(double[] inputArray)
        Perform pitch detection. The input signal should uniformly partitioned into vectorSize length chunks of data. performPitchDetect() should be called on each consecutive vector of input data. A vectorSize length array of doubles containing the data is passed to performPitchDetect() via inputArray[]. Each element of inputArray[] is assumes to contain a single data sample. The _sampleRate parameter contains that sample rate, in Hz. performPitchDetect() returns a vectorSize length array of doubles containing the pitch estimates.

        Note that there is a 2048 sample delay between an element of inputArray[] and the corresponding element of the returned vector of pitch estimates.

        Parameters:
        inputArray - The array of audio sample to process.
        Returns:
        An array of pitch estimates of the same length as the input array parameter.