be.hogent.tarsos.dsp.pitch
Class FastYin

java.lang.Object
  extended by be.hogent.tarsos.dsp.pitch.FastYin
All Implemented Interfaces:
PitchDetector

public final class FastYin
extends java.lang.Object
implements PitchDetector

An implementation of the YIN pitch tracking algorithm which uses an FFT to calculate the difference function. This makes calculating the difference function more performant. See the YIN paper. This implementation is done by Matthias Mauch and is based on Yin which is based on the implementation found in aubio by Paul Brossier.

Author:
Matthias Mauch, Joren Six, Paul Brossier

Field Summary
static int DEFAULT_BUFFER_SIZE
          The default size of an audio buffer (in samples).
static int DEFAULT_OVERLAP
          The default overlap of two consecutive audio buffers (in samples).
 
Constructor Summary
FastYin(float audioSampleRate, int bufferSize)
          Create a new pitch detector for a stream with the defined sample rate.
FastYin(float audioSampleRate, int bufferSize, double yinThreshold)
          Create a new pitch detector for a stream with the defined sample rate.
 
Method Summary
 PitchDetectionResult getPitch(float[] audioBuffer)
          The main flow of the YIN algorithm.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_BUFFER_SIZE

public static final int DEFAULT_BUFFER_SIZE
The default size of an audio buffer (in samples).

See Also:
Constant Field Values

DEFAULT_OVERLAP

public static final int DEFAULT_OVERLAP
The default overlap of two consecutive audio buffers (in samples).

See Also:
Constant Field Values
Constructor Detail

FastYin

public FastYin(float audioSampleRate,
               int bufferSize)
Create a new pitch detector for a stream with the defined sample rate. Processes the audio in blocks of the defined size.

Parameters:
audioSampleRate - The sample rate of the audio stream. E.g. 44.1 kHz.
bufferSize - The size of a buffer. E.g. 1024.

FastYin

public FastYin(float audioSampleRate,
               int bufferSize,
               double yinThreshold)
Create a new pitch detector for a stream with the defined sample rate. Processes the audio in blocks of the defined size.

Parameters:
audioSampleRate - The sample rate of the audio stream. E.g. 44.1 kHz.
bufferSize - The size of a buffer. E.g. 1024.
yinThreshold - The parameter that defines which peaks are kept as possible pitch candidates. See the YIN paper for more details.
Method Detail

getPitch

public PitchDetectionResult getPitch(float[] audioBuffer)
The main flow of the YIN algorithm. Returns a pitch value in Hz or -1 if no pitch is detected.

Specified by:
getPitch in interface PitchDetector
Parameters:
audioBuffer - The buffer with audio information. The information in the buffer is not modified so it can be (re)used for e.g. FFT analysis.
Returns:
a pitch value in Hz or -1 if no pitch is detected.