RunTheTests
/

Pitch Detector

Detect the pitch of any sustained note, in hertz and in cents from the nearest note.

not running

−50 ← cents → +50

How this test works

Pitch is found by autocorrelation: the algorithm looks for the period at which the waveform most resembles a delayed copy of itself, which is the fundamental. That is deliberately not the same as picking the loudest frequency in a spectrum, because on many instruments the loudest component is a harmonic rather than the fundamental — a naive detector reports the note an octave up. Two further refinements matter. The first correlation peak after the curve has fallen away is taken rather than the largest, which is the other route to the octave error. And the peak is interpolated against its neighbours, without which resolution is limited to one sample of period, around twenty cents at the top of the range and useless for tuning.

What the results mean

Frequency
The detected fundamental in hertz.
Nearest note
Where that frequency sits in equal temperament with A4 at 440 Hz.
Deviation in cents
A cent is a hundredth of a semitone. Trained ears notice five to ten; under about five is indistinguishable.
Clarity
How strong the autocorrelation peak was. Below about 85% no reading is shown at all, because a weak peak means a guess.

Common problems and fixes

It shows nothing while I am playing
Either the note is too quiet, too percussive, or outside the detection range. A sustained bowed or plucked note held for a second reads reliably; a struck drum does not.
It reads an octave above what I played
That is the classic autocorrelation failure and this implementation guards against it, but a note with a very weak fundamental can still trigger it. Play closer to the microphone.
The reading jumps around
Room reflections. Move closer to the microphone or into a less reverberant space — the clarity figure will rise as the reading steadies.

Frequently asked questions

What is a cent?

A hundredth of a semitone, so 1200 cents to an octave. It is the unit that makes tuning error comparable across the range, since the same error in hertz is a much bigger deal at low pitch than at high.

Why does it use autocorrelation rather than an FFT?

Because the loudest frequency component of a real instrument is often a harmonic, not the fundamental. Autocorrelation finds the repeating period of the whole waveform, which is the note you actually hear.

Can it detect chords?

No. Autocorrelation finds one repeating period, and a chord has several simultaneous fundamentals with no single period. It will either report one of them or nothing.

More in Audio