Multi-note Music Tuner
This page listens to sound, splits it into the frequencies it's made of with a fast Fourier transform (FFT), and names the note at each strong frequency along with how many cents (hundredths of a semitone) sharp or flat it is. Unlike most tuners, it can follow several notes at once, so you can check a double stop or a chord. It began as a Processing sketch I wrote to tune my violin and look at its harmonics.
Choose an input and press Start. The microphone is processed entirely in your browser and isn't recorded or sent anywhere. If you don't want to use a microphone, try the test tone.
Tuner
About this graph
The tuner names the two loudest notes, lower note on the left, and shows how many cents sharp or flat each one is from equal temperament. A needle is in the green zone when its note is within 5 cents. A note's loudness includes its harmonics, so a low note whose fundamental is weak still counts as loud. Below the notes is the interval between them, with how far it is from the equal-tempered interval and from the pure one (a whole-number ratio, like 3:2 for a perfect fifth), which is what you hear as beat-free when tuning strings to each other.
Spectrum
About this graph
Each peak is a frequency in the sound. The white curve on each peak is the Gaussian fitted to it, which locates the peak more precisely than the FFT alone (see "How it works" below). Below each note is a small tuner: the mark is in the green zone when the note is within 5 cents of equal temperament. Peaks marked ×2, ×3, … are harmonics of a lower note, so they aren't named as separate notes. Hover over the chart to read off a frequency.
Note history
About this graph
The notes heard over the last ten seconds, like a piano roll. The line inside each bar shows the exact pitch, so it sits in the middle of its row when in tune, above the middle when sharp, and below it when flat, and is colored from green (in tune) to red (a quarter tone off). Vibrato shows up as a wavy line. Only notes within the spectrum's note range are shown; amber marks along the top or bottom edge show when higher or lower notes were heard.
How it works
Every frame, the most recent \(N\) audio samples (8192 by default, about a sixth of a second) are multiplied by a window function that fades them in and out, and then transformed with an FFT. The FFT measures the strength of the sound at evenly spaced frequencies, or bins, \(f_s / N\) apart, where \(f_s\) is the sample rate. At 48 kHz that's about 5.9 Hz, which near A3 (220 Hz) is almost half a semitone: far too coarse for tuning on its own.
The trick that makes the tuner precise comes from M. Gasior and J. L. Gonzalez, "Improving FFT Frequency Measurement Resolution by Parabolic and Gaussian Spectrum Interpolation". With a Gaussian window, the peak that a pure tone makes in the spectrum has the shape of a Gaussian, so the logarithm of its magnitude is a parabola. If bin \(k\) is a local maximum and \(\alpha, \beta, \gamma\) are the logarithms of the magnitudes in bins \(k-1\), \(k\), and \(k+1\), the parabola through those three points peaks at \[ f = \left(k + \delta\right) \frac{f_s}{N}, \qquad \delta = \frac{1}{2} \cdot \frac{\alpha - \gamma}{\alpha - 2\beta + \gamma}, \] which finds the tone's frequency to a small fraction of a bin. This is what the white curves on the spectrum show. Other windows give peaks that are only approximately Gaussian, so the estimate is less exact; try "None (rectangular)" to see the wide skirts that a window is meant to prevent.
Most instruments don't make pure tones. A violin's G string, for example, vibrates at 196 Hz and at every whole-number multiple of it, 392 Hz, 588 Hz, and so on. These harmonics would otherwise be named as notes of their own, so any peak within 35 cents of a whole-number multiple of a lower peak is treated as its harmonic instead. (The catch is that a note played together with its octave is also hidden; uncheck "Detect and ignore harmonics" to see every peak.) Low notes often have a fundamental much quieter than their harmonics, so a peak below the threshold is still counted as a note when at least two of the stronger peaks are its harmonics. The tuner at the top shows the fundamental of the loudest sound.
Steady background noise, from a fan, a refrigerator, or traffic, mostly sits at low frequencies, where it can make the biggest peak in the spectrum. Calibrate background noise records the spectrum over four seconds of quiet. Noise rises and falls at random, so each bin's noise level is taken as the level it stays below 95% of the time. A fan's hum also drifts slightly in pitch, so each bin's level is then raised to the highest level within two bins on either side. From then on, that level (times the noise removal strength) is subtracted from each bin of every new spectrum, which is called spectral subtraction. It removes only noise that stays about the same, and it also takes a little off quiet notes at the frequencies where the noise was loud.
The note names use twelve-tone equal temperament with A4 at the reference pitch, so a note is \(12 \log_2(f / f_{\text{A4}})\) semitones above A4. Intervals tuned by ear are often not equal-tempered: a pure major third is 14 cents flatter than an equal-tempered one, so in a well-tuned chord the third may read as flat.