/YIN-Pitch

YIN pitch estimation algorithm implementation using Python.

Primary LanguageJupyter NotebookGNU Affero General Public License v3.0AGPL-3.0

YIN-Pitch

This repository contains a Python implementation of the YIN algorithm for fundamental frequency estimation. The YIN algorithm is a widely used method for estimating the fundamental frequency (pitch) of an audio signal. Based on the paper by Alain de Cheveigné and Hideki Kawahara, "YIN, a fundamental frequency estimator for speech and music", J. Acoust. Soc. Am. 111, 1917 (2002); https://doi.org/10.1121/1.1458024

The YIN algorithm

The YIN algorithm is a time-domain method based on the computation of the Cumulative Mean Normalized Difference Function (CMNDF) to find the fundamental frequency of a given audio signal.

Fragment of the input signal in the time domain.

This implementation includes the following components:

  • Calculation of the difference function and the CMNDF
  • Threshold-based candidate for the fundamental frequency
  • Parabolic interpolation to refine the estimate of the fundamental frequency
  • Visualization of the pitch contour over a spectrogram

Cmndf and predicted tau value.

Predicted tau: 159.15 samples
Predicted fundamental frequency: 301.61 Hz

Results

The script computes the estimated f0 values for the input signal and plots them on top of the spectrogram. The results of the pitch estimation for the different input audios (taken from freesound.org) are included next:

Sound 1: https://freesound.org/people/TheScarlettWitch89/sounds/427200/

Image

Pitch estimation for the example sound 1 (Female alto vocal range)

Sound 2: https://freesound.org/people/daalvinz/sounds/367215/

Image

Pitch estimation for the example sound 2 (Male baritone vocal range)

Sound 3: https://freesound.org/people/HerbertBoland/sounds/30084/

Image

Pitch estimation for the example sound 3 (Female soprano vocal range)

Sound 4: https://freesound.org/people/TheScarlettWitch89/sounds/417938/

Image

Pitch estimation for the example sound 4 (Female mezzo soprano vocal range)

Usage

  1. Clone the repository:
git clone https://github.com/ABSounds/YIN-Pitch.git
  1. Install the required packages:
pip install numpy scipy matplotlib tqdm
  1. Run the YIN_pitch.ipynb Jupyter Notebook

References

For more information on the YIN pitch estimation algorithm, please refer to the following paper: