See README for copyright information.

YIN: fundamental frequency estimator


YIN estimates the fundamental frequency (F0) of an audio signal. Features are: YIN operates on vectors or files. YIN outputs a structure containing a set of four vectors: F0 vs time, two estimates of aperiodic/total power (one gross estimate, one fine estimate), and a period-smoothed estimate of instantaneous power.

If no output argment is specified, YIN plots F0 as a function of time (in octaves re: 440 Hz), aperiodicity, and power.

In the F0 plot, samples in blue are reckoned reliable (aperiodicity2*threshold).

Type 'help yin' for a description of the parameters. Read the reference below and the code to understand their meaning. In brief:

Parameter 'thresh' sets the proportion of aperiodic power that is tolerated within a "periodic" signal. This may vary according to the application.

For speech or musical instruments a value of 0.1 is usually adequate. Singing voice may require a smaller value (as low as 0.001) if a harmonic is reinforced by a sharp formant.

Some signals are inherently ambiguous. For example the response of a high-Q resonator excited by a pulse train may be seen either as a complex tone with an F0 equal to that of the pulse train, or as an amplitude modulated pure tone with an F0 equal to the resonant frequency. Neither is more "correct" than the other. To obtain the result that you expect, you must set the threshold to an appropriate value: small for the fundamental periodicity, large for the resonance periodicity.

YIN is described in:
de Cheveigné, A., and Kawahara, H. (2002). "YIN, a fundamental frequency estimator for speech and music," J. Acoust. Soc. Am., 111, 1917-1930. (pdf)


[Code is here] [Alain de Cheveigné]