Autocorrelation vs YIN: Periods, Octave Errors and Practical Choices

Autocorrelation looks for repeating waveform structure; YIN builds a modified period estimator using a difference function, normalisation, candidate selection and refinement. Both are useful approaches to monophonic fundamental-frequency estimation, and neither guarantees a correct result on every recording.

The important comparison is not “old algorithm versus perfect algorithm.” It is how the methods select a period, reject uncertain frames and trade time resolution against the evidence needed for a reliable estimate.

How autocorrelation finds a period

Autocorrelation compares a signal with delayed versions of itself. A repeating waveform tends to resemble itself again after one period. At a sample rate Fs and a candidate delay of k samples, the estimated frequency is Fs/k.

A simplified measure is R(k) = Σ x(j) × x(j+k), summed over an appropriate shared window. The zero-delay value is large by construction, so it is not a useful pitch-period choice.

Real implementations need normalisation, a lag search range and peak-selection rules. Searching for the largest value anywhere without accounting for those details is not a robust general pitch detector.

Why octave errors happen

A complex waveform can have convincing similarity at several delays. Choosing half the true period doubles the frequency, an octave high. Choosing twice the period halves frequency, an octave low.

Harmonic structure, a weak fundamental, transients and noise can change which candidate appears strongest. A high correlation value alone does not prove the selected octave is correct.

The unstable-reading guide explains what those jumps look like in practice. They are different from the small continuous movement of a real vibrato note.

What YIN changes

De Cheveigné and Kawahara’s 2002 YIN paper presents modifications to an autocorrelation-related approach. Its aim is to reduce errors in fundamental-frequency estimation, not to transcribe every simultaneous note in a chord.

  1. Difference function: compare delayed samples using squared differences, d(k) = Σ[x(j)−x(j+k)]². A good period creates a dip rather than a similarity peak.
  2. Cumulative mean normalisation: compare each difference with the mean of shorter-lag differences, using d′(0)=1.
  3. Candidate selection: use a threshold and a suitable local minimum rather than automatically accepting the deepest dip anywhere.
  4. Interpolation: refine the candidate between whole-sample delays.
  5. Local refinement and reliability decisions: use the method’s surrounding analysis and acceptance rules to improve the estimate.

In the normalisation, d′(k) = d(k) / [(1/k) × Σ d(i), for i=1 through k]. The windowing and candidate rules remain important; copying the equation alone does not reproduce a fully configured implementation.

Why interpolation matters

At 48 kHz, an ideal 440 Hz period spans about 109.09 samples. Whole-sample delay 109 corresponds to about 440.37 Hz, while 110 corresponds to about 436.36 Hz.

Interpolation can estimate a fractional delay instead of forcing the answer onto those integer positions. A parabola through a candidate dip and its neighbours is one common refinement.

This improves the resolution of the estimate for suitable signals. It does not guarantee accuracy when the chosen dip belongs to the wrong octave, the signal is unvoiced or competing sources dominate.

Comparison of the approaches

Algorithmic distinctions, not guaranteed performance scores
AspectAutocorrelation approachYIN approach
Basic evidenceSimilarity at candidate delaysNormalised delayed difference
Candidate featureA suitable nonzero-lag peakA suitable dip
Octave handlingDepends on normalisation and selection rulesUses its normalisation and threshold procedure
Subsample estimateCan be addedInterpolation is part of the method
Uncertain audioNeeds sensible rejectionStill needs sensible rejection and voicing interpretation

The YIN paper reports improved error performance under its evaluation conditions. That does not establish one universal cents advantage or prove that every YIN implementation outperforms every autocorrelation-derived method.

Frame length and lowest detectable pitch

Low frequencies have long periods. At 50 Hz, one cycle lasts 20 ms. A short window with insufficient repeating structure cannot support the same decisions as a longer observation.

Longer frames can help low-note analysis but blur rapid changes and add observation time. Hop size controls how often estimates are produced; it is not the same as frame duration or end-to-end latency.

Set plausible minimum and maximum frequencies for the actual source. An excessively narrow range can exclude the correct pitch, while an unnecessarily broad search admits additional ambiguous candidates.

How pYIN differs from YIN

Mauch and Dixon’s pYIN keeps multiple candidates with probabilities and uses temporal inference to find a likely sequence. That allows later track decisions to consider alternatives discarded by a one-candidate frame-wise method.

It is a probabilistic extension, not simply a moving average and not itself a deep neural network. Temporal decoding can improve a track while introducing its own assumptions about transitions and voicing.

See tracking versus detection for why connecting frames is a separate problem from estimating one frame.

Which method should you choose?

For a clear live single note, test a suitable implementation for response, range and voicing behaviour. For offline singing analysis, temporal candidate handling may be valuable. For chords or a full mix, first decide whether the task is monophonic or genuinely multi-pitch.

The main detector here uses the related McLeod pitch method with its own selection and filtering. Explaining YIN does not imply that every tool on the site implements that exact algorithm.

Compare methods on the same signals and reference targets. The accuracy guide separates small tuning errors from octave mistakes and missing estimates.

Frequently asked questions

Does YIN eliminate octave errors?

No. It addresses important error mechanisms, but difficult signals, settings and implementation choices can still produce mistakes.

Is autocorrelation too slow for live use?

Not inherently. Cost depends on the implementation, window, lag range and hardware. Some calculations can be accelerated using FFT-related methods.

Is one threshold correct for every voice?

No. The appropriate setting depends on the signal and implementation. A stricter threshold can reject useful breathy or quiet frames as well as errors.

Can either method analyse a whole chord reliably?

Standard monophonic versions estimate one fundamental. Recovering all notes in a chord requires an appropriate multi-pitch method.

Reference basis: de Cheveigné and Kawahara’s YIN publication, Mauch and Dixon’s pYIN paper and the documented classical DSP implementation used here.

Scroll to Top