Autocorrelation vs YIN: Periods, Candidates and Pitch Errors

Autocorrelation compares a signal with delayed copies of itself; YIN uses a related difference-based approach with normalization and candidate selection to estimate a fundamental period. Both can support single-pitch estimation, and neither method name guarantees correct results for every sound.

The useful comparison concerns the input, analysis window, search range, candidate rules and evaluation task. A synthetic sine tone, a changing voice and a chord do not pose the same problem.

Begin with period rather than a note name

A period estimator looks for repeating structure. If the sample rate is fs and a selected period spans p samples, the corresponding frequency is fs/p.

At 48,000 samples per second, a period of 240 samples corresponds to 200 Hz. A period of 120 samples corresponds to 400 Hz.

Only after estimating frequency does an interface map the result to a note, octave and cents under a tuning reference. The result-reading guide separates those stages.

What autocorrelation compares

Autocorrelation measures similarity between a waveform and delayed versions of it. A delay that aligns repeating structure can produce a useful peak.

The zero-delay match is not the desired musical period. Search ranges and normalization help distinguish plausible nonzero candidates from trivial or misleading matches.

Implementation details matter because different delays can involve different overlapping samples and energies. “Autocorrelation” describes a family of related calculations rather than one fixed product configuration.

What the difference approach changes

A squared-difference calculation asks how much the signal and a delayed copy differ. Repeating structure can produce a low difference at a plausible period.

YIN adds a cumulative normalization and a rule for choosing a suitable minimum, followed by refinement in common implementations. It is related to autocorrelation rather than an unrelated technique.

The official librosa YIN documentation describes its particular sequence. That is useful technical evidence, not proof that every program named YIN shares identical defaults or performance.

Why candidate selection matters

A periodic waveform can also match after two or more cycles. Selecting twice the true period gives half the frequency, an octave-low result.

Strong harmonic structure can create another plausible shorter candidate. Selecting half the period gives double the frequency, an octave-high result.

The wrong-octave guide explains how to diagnose the numerical pattern. No normalization rule removes every ambiguity in every musical input.

A lag example with three outcomes

Suppose the verified input has a 200 Hz fundamental and the sample rate is 48 kHz. The correct period is 240 samples.

Selecting 120 samples produces 400 Hz, while selecting 480 produces 100 Hz. All three can look related in a periodic signal, but only one matches the defined reference task.

These are calculated candidate examples, not benchmark results from newly tested tools. A fair test must state how the expected fundamental was established.

Window length is a separate decision

A 4096-sample record at 48 kHz spans about 85.33 milliseconds. A longer record can contain more cycles of a low tone, but also more time during which the source may change.

The hop between successive analyses is another value. Updating every 20 milliseconds does not mean each estimate used only 20 milliseconds of audio.

The tracking-versus-detection guide explains that distinction. Claims about responsiveness need the complete pipeline, not one parameter alone.

An implementation can use FFT internally

Autocorrelation can be calculated with different computational strategies, including Fourier-transform methods. Using an FFT internally does not make the estimator equivalent to choosing the largest spectrum peak.

The question is what quantity the implementation computes and how it selects a period. A broad time-domain versus frequency-domain label can hide that distinction.

The site’s saved source uses an NSDF/McLeod-style estimator rather than claiming to run YIN. This article compares concepts; it does not relabel the installed engine or claim a new performance test.

Keep monophonic and polyphonic tasks separate

One periodic source can contain many harmonics. Several independently played notes create another problem because their fundamentals and harmonics overlap.

An algorithm returning one candidate per frame does not become a chord recognizer merely because the input contains a chord.

The multiple-note guide explains the wider task. Compare methods on the same intended output rather than treating a missed chord tone as a small tuning error.

Evaluate implementations under comparable conditions

Use the same signal, sample rate, frequency search range and evaluation reference. State whether you are judging correct octave, fine cents error, coverage or time tracking.

A tool that rejects an ambiguous frame differs from one that always returns a number. Compare both correctness and accepted coverage rather than rewarding output quantity alone.

The accuracy guide explains these measures. A single easy tone cannot establish a universal ranking between algorithms.

Use the comparison practically

For a suitable isolated live sound, the homepage pitch detector offers a practical estimate. Reduce competing sources and inspect repeatable central portions.

For repeatable saved material, the audio file pitch detector can support a time-based check within its limits. It does not separate every instrument in a mix.

The microphone guide addresses input problems that no algorithm label can automatically solve. A better-controlled signal can be more useful than assuming a different method must fix every result.

A declared frequency search range also limits candidate choice. If a test excludes the true 200 Hz fundamental by searching only above 300 Hz, failure to return 200 Hz is not an independent comparison of the algorithms’ unrestricted ability. Keep allowed frequencies matched when comparing implementations.

Frequently asked questions

Is YIN always more accurate than autocorrelation?

No universal result follows from the names alone. Implementations, parameters, signals and evaluation measures must be specified.

Does YIN detect every note in a chord?

A single-F0 YIN estimator is not a complete polyphonic transcription system. Several simultaneous notes require a different output model.

Does a longer window always help?

It can improve some low-frequency observations while reducing time localization. The source must remain suitable across the record.

Is the site’s detector a YIN implementation?

The verified saved source uses an NSDF/McLeod-style engine. Comparing YIN here does not imply the tool runs it or that a new benchmark was performed.

Reference

The official librosa YIN documentation describes its normalized-difference and candidate-selection workflow.

Scroll to Top