# spafe.frequencies.fundamental_frequencies¶

Credits to:
Patrice Guyot. (2018, April 19). Fast Python implementation of the Yin algorithm (Version v1.1.1). Zenodo. http://doi.org/10.5281/zenodo.1220947
class spafe.frequencies.fundamental_frequencies.FundamentalFrequenciesExtractor(debug=False)[source]

Bases: object

compute_yin(sig, fs, dataFileName=None, w_len=512, w_step=256, f0_min=50, f0_max=3000, harmo_thresh=0.1)[source]

Compute the Yin Algorithm. Return fundamental frequency and harmonic rate.

Parameters: sig (list) – Audio signal (list of float) fs (int) – sampling rate (= average number of samples pro 1 second) w_len (int) – size of the analysis window (in #samples) w_step (int) – size of the lag between two consecutives windows (in #samples) f0_min (int) – Minimum fundamental frequency that can be detected (in Hertz) f0_max (int) – Maximum fundamental frequency that can be detected (in Hertz) harmo_tresh (int) – Threshold of detection. The yalgorithmù return the first minimum of the CMND fubction below this threshold. tuple include the following pitches : list of fundamental frequencies, harmonic_rates: list of harmonic rate values for each fundamental frequency value (= confidence value) argmins : minimums of the Cumulative Mean Normalized DifferenceFunction times : list of time of each estimation (tuple)
cumulativeMeanNormalizedDifferenceFunction(df, N)[source]

Compute cumulative mean normalized difference function (CMND). This corresponds to equation (8) in [1].

Parameters: df (list) – Difference function N (int) – length of data tau_max (int) – integration window size cumulative mean normalized difference function (list)
differenceFunction(x, N, tau_max)[source]

Compute difference function of data x. This corresponds to equation (6) in [1] Fastest implementation. Use the same approach than differenceFunction_scipy. This solution is implemented directly with np fft.

Parameters: x (array) – audio data N (int) – length of data tau_max (int) – integration window size difference function (list)
getPitch(cmdf, tau_min, tau_max, harmo_th=0.1)[source]
Return fundamental period of a frame based on CMND function.
• cmdf: Cumulative Mean Normalized Difference function
Parameters: tau_min (int) – minimum period for speech tau_max (int) – maximum period for speech harmo_th (float) – harmonicity threshold to determine if it is necessary to compute pitch frequency fundamental period if there is values under threshold, 0 otherwise (float)
main(sig, fs, w_len=1024, w_step=256, f0_min=70, f0_max=200, harmo_thresh=0.85, audioDir='./', dataFileName=None)[source]

Run the computation of the Yin algorithm on a example file.

Parameters: sig (list) – Audio signal (list of float) fs (int) – sampling rate (= average number of samples pro 1 second) w_len (int) – size of the analysis window (in #samples) w_step (int) – size of the lag between two consecutives windows (in #samples) f0_min (int) – Minimum fundamental frequency that can be detected (in Hertz) f0_max (int) – Maximum fundamental frequency that can be detected (in Hertz) harmo_tresh (int) – Threshold of detection. The yalgorithmù return the first minimum of the CMND fubction below this threshold. tuple include the following pitches : list of fundamental frequencies, harmonic_rates: list of harmonic rate values for each fundamental frequency value (= confidence value) argmins : minimums of the Cumulative Mean Normalized DifferenceFunction times : list of time of each estimation (tuple)