- Introduced by
- Alain de Cheveigné
- Year
- 2002
- Type
- Fundamental frequency estimation
- Family
- Feature extraction
What does it do?
Pitch detection, also called fundamental frequency (f0) estimation, is the task of estimating the perceived pitch of a monophonic (single-source) audio signal over time.
The YIN estimator, described by de Cheveigné and Kawahara (2002), is a well-known example for both speech and music. Monophonic input is considerably easier than polyphonic input, where several sources sound at once and pitch detection becomes a distinct and harder problem.
The intuition behind the method
Musical pitch is closely tied to the fundamental frequency (f0) of a sound's vibration, but real waveforms are rarely perfectly periodic. Autocorrelation-based methods compare the signal with delayed copies of itself; the lag at which the correlation peaks corresponds to the period, and its inverse gives the f0. Spectral methods instead look for the lowest strong peak in the frequency domain. Noise, weak fundamentals and rich harmonic content make both routes harder.
History
The YIN estimator was published by de Cheveigné and Kawahara in 2002 in The Journal of the Acoustical Society of America. Its abstract describes an autocorrelation-based method with several modifications that together prevent errors. The method was evaluated on speech recordings with laryngograph reference signals.
When to use it
Choose pitch detection when the source is monophonic and has a clear periodic component, such as solo singing, a solo instrument, speech, or animal calls. YIN is a reasonable choice when low latency and few parameters to tune matter, and when the frequency range of interest is not bounded in advance, since its abstract notes no upper limit on the search range. Do not use it for polyphonic recordings, where several sources sound together; a standard monophonic estimator will fail there. Avoid it on heavily noisy audio or on sources with weak or missing fundamentals, where octave and voicing errors become more likely.
Limitations and considerations
- Octave errors: the estimate can lock onto a multiple or submultiple of the true f0, and resolving this requires additional cues for some sources.
- Noise and weak fundamentals: accuracy falls when the periodicity that these methods depend on is obscured by noise or absent from the spectrum.
- Polyphonic input is outside the scope of standard monophonic estimators; separating several simultaneous f0 values is a much harder open problem.
- Substantially aperiodic signals, such as breathy or noisy phonation, need the extensions that the signal model allows; the basic method does not handle them well.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- On speech recordings with laryngograph reference signals, error rates were about three times lower than those of the best competing methods tested. This advantage was measured on speech.
- It has no upper limit on the frequency search range, so it suits high-pitched voices and music, as stated in the paper.
- The algorithm is relatively simple, can be implemented efficiently with low latency, and involves few parameters that must be tuned.
- Its signal model is periodic and can be extended to handle particular forms of aperiodicity that arise in specific applications.
Applications
- Vocal training and singing voice analysis for music education.
- Music transcription and symbolic notation generation from monophonic sources.
- Instrument tuning and intonation analysis.
- Speech processing, such as speech recognition and speaker identification.
- Bird song analysis and bioacoustics research.
How it works
How it works
The audio is divided into short overlapping frames (typically 10–50 ms). Each frame is then analysed for periodicity, for example through its autocorrelation, its spectral peaks, or a cepstral representation.
YIN, as described on this page, uses fixed signal-processing rules and has no training stage. Learned estimators instead require labelled audio with reference f0 values, and their behaviour depends on that training data.
The estimator is applied frame by frame to produce an f0 value for each frame. In YIN, the frame is compared with delayed copies of itself: for each candidate lag, the squared difference between the signal and its shifted version is computed (the difference function). This difference is then normalised by its running mean over lags (the cumulative mean normalised difference), a step that helps prevent subharmonic and octave errors. The smallest lag at which this normalised value first falls below an absolute threshold is selected, and that lag is refined by parabolic interpolation; f0 is the sampling rate divided by the refined lag. Each frame also needs a voicing decision (voiced or unvoiced), and the estimates must be checked for octave errors, where the reported f0 is a multiple or submultiple of the true value.
Accuracy is commonly reported in cents (1 cent = 1/100 semitone) or as a gross pitch error rate. Results should be checked against reference recordings with known f0 that cover the sources of interest, such as singing, instruments and speech.
Common pitfalls
- Treating the estimated f0 as the perceived pitch. Pitch is perceptual and also depends on harmonic content, so the physical f0 value alone does not determine what a listener hears.
- Assuming pitch is constant within a frame. Frame-level estimates cover a short window, and during vibrato or portamento the reported value can average over a range of pitches.
- Ignoring voicing. Unvoiced frames (consonants, breath) have no meaningful pitch, so returning an f0 value for them produces spurious output.
Frequently asked questions
What is the difference between pitch and frequency?
Frequency is a physical property measured in hertz. Pitch is the perceptual attribute. Two instruments playing the same frequency sound at the same pitch, but their timbres differ because of harmonic structure.
Why is octave error a problem in pitch detection?
An octave is a doubling of frequency, so f0 and 2 × f0 are heard as the same note at different heights. Some algorithms confuse the two; distinguishing them requires additional cues.
Can pitch detection work on polyphonic music?
Standard pitch detection cannot reliably handle polyphony. Polyphonic pitch detection is an open research problem requiring specialized models that can estimate multiple f0 values simultaneously.
How accurate must pitch detection be for practical use?
Required accuracy depends on the application. Music transcription, scientific analysis and tuning set different tolerances, and the acceptable error should be fixed in advance from the criteria of the specific study.
Related methods
Sources
de Cheveigné, A., & Kawahara, H. (2002). YIN, a fundamental frequency estimator for speech and music. The Journal of the Acoustical Society of America, 111(4), 1917-1930.
Open DOI referenceMcLeod, P., & Wyvill, G. (2005). A smarter way to find pitch. In Proceedings of the International Computer Music Conference.
Open publication referenceMauch, M., Cannam, C., Bittner, R., Fazekas, G., Salamon, J., Wade, J., & Benetos, E. (2015). Computer-aided Research on Monophonic Singing. In Frontiers in Psychology.
Open publication reference