yin

Description: libf0 YIN implementation
Contributors: Sebastian Rosenzweig, Simon Schwär, Edgar Suárez, Meinard Müller
License: The MIT license, https://opensource.org/licenses/MIT
This file is part of libf0.
libf0.yin.yin(x, Fs=22050, N=2048, H=256, F_min=55.0, F_max=1760.0, threshold=0.15, verbose=False)[source]

Implementation of the YIN algorithm.

Parameters:
  • x (ndarray [shape=(L, )], real - valued) – Audio signal

  • Fs (int) – Sampling frequency

  • N (int) – Window size

  • H (int) – Hop size

  • F_min (float) – Minimal frequency

  • F_max (float) – Maximal frequency

  • threshold (float) – Threshold for cumulative mean normalized difference function

  • verbose (bool) – Switch to activate/deactivate status bar

Returns:

  • f0 (ndarray) – Estimated F0-trajectory

  • t (ndarray) – Time axis

  • ap (ndarray) – Aperiodicity (indicator for voicing: the lower, the more reliable the estimate)

libf0.yin.cumulative_mean_normalized_difference_function(frame, lag_max)[source]

Computes Cumulative Mean Normalized Difference Function (CMNDF).

Parameters:
  • frame (ndarray) – Audio frame

  • lag_max (int) – Maximum expected lag in the CMNDF

Returns:

cmndf – Cumulative Mean Normalized Difference Function

Return type:

ndarray

libf0.yin.absolute_thresholding(cmndf, threshold, lag_min, lag_max, parabolic_interp=True)[source]

Absolute thresholding: Set an absolute threshold and choose the smallest value of tau that gives a minimum of d’ deeper than that threshold. If none is found, the global minimum is chosen instead.

Parameters:
  • cmndf (ndarray) – Cumulative Mean Normalized Difference Function

  • threshold (float) – Threshold

  • lag_min (float) – Minimal lag

  • lag_max (float) – Maximal lag

  • parabolic_interp (bool) – Switch to activate/deactivate parabolic interpolation

libf0.yin.parabolic_interpolation(y1, y2, y3)[source]

Parabolic interpolation of an extremal value given three samples with equal spacing on the x-axis. The middle value y2 is assumed to be the extremal sample of the three.

Parameters:
  • y1 (f(x1))

  • y2 (f(x2))

  • y3 (f(x3))

Returns:

  • x_interp (Interpolated x-value (relative to x3-x2))

  • y_interp (Interpolated y-value, f(x_interp))

libf0.yin.aperiodicity(frame, lag_est)[source]

Compute aperiodicity of given frame (serves as indicator for reliability or voicing detection).

Parameters:
  • frame (ndarray) – Frame

  • lag_est (float) – Estimated lag

Returns:

ap – Aperiodicity (the lower, the more reliable the estimate)

Return type:

float