A labs.llc instrument · the microphone is the input

Play a note.
Read the cents.

A chromatic tuner. Press Listen, play one string, and the page tells you which note it is, which octave it is in, its frequency to two decimal places, and how far from true it sits — in cents, which is the unit that means the same thing at every pitch. There are string targets for ten tunings, from a guitar in standard to a cello, and A4 moves anywhere between 415 and 466 Hz.

The audio never leaves this browser. There is no upload, no server and no recording: the microphone is opened only while you are using it, each window of samples is measured and overwritten by the next, and nothing is kept. This property makes no network request for audio of any kind, in either direction.

The pitch is found by autocorrelation rather than by taking the tallest peak of a spectrum. That distinction is the difference between a tuner and a toy on a low string, and the method section says exactly why.

The tuner

One string at a time

The microphone is not opened until you press the button, and it is closed again the moment you stop, when the tab goes into the background, or when the page is left. While it is open the browser shows its own recording indicator; when this page is not listening, that indicator is off, and that is the honest test of everything said here.

The tuner

Deviation
Frequency
Against
Clarity

Cents are hundredths of a semitone, so a hundred of them is the distance from one fret to the next. The shaded band on the dial is five cents either side of true: that is close enough that a string’s own settling will move it further than the reading did.

The instruments

Real strings, real targets

Choose an instrument and its open strings appear as a row, each with the frequency it should be at — computed from your own A4, not read out of a table, so the whole row moves when the calibration does. While the tuner is listening the nearest string lights up and shows its deviation, so tuning a guitar is six notes and no menu.

Press a string to hear it. The reference tone is an oscillator with a short attack and a short release, so it starts and stops without a click, and it holds for twenty seconds unless you press it again. If the microphone is open it will hear the tone as well as the instrument, so use headphones or stop the tone before you play.

The strings

The open strings — press one to sound it

Chromatic is the default and needs no instrument: it names the nearest of the twelve notes and measures against that, which is what you want for anything not on the list — a harmonica reed, a tuning fork, a saw. Choosing an instrument does one further thing, and the method section explains why: it narrows the range the detector searches to that instrument’s own, which is what keeps two strings ringing together from being read as the slower pitch they make between them.

The pitch

Where A is

Everything on this page hangs off one number. A4 — the A above middle C — is 440 Hz by international agreement, and every other pitch is 440 × 2^(n/12) from it. Move A4 and the whole grid moves with it: the note names do not change, the frequencies do.

415 Hz is worth a word. It is a semitone below 440 — 440 ÷ 2^(1/12) is 415.30 — and it is the convention most modern period ensembles play at, which is why a harpsichord will often be sitting there. It is a convention rather than a historical fact: pitch in the seventeenth century varied by town, by organ and by decade, and no single number describes it. At the other end, 466 Hz is a semitone above 440 and turns up in some renaissance and early-baroque repertoire. Between them, plenty of European orchestras tune to 442 or 443.

Calibration

440.0 Hz

Your setting is kept in this browser under one key (labs.tuner.a4) and nowhere else. Clear the site’s data and it goes back to 440.

The method

How the note is arrived at

Why not an FFT

The obvious tuner is a spectrum and its loudest bin. It fails twice, and both failures are on the instrument most people arrive with. The first is resolution: at 44.1 kHz a 2,048-point transform has bins 21.5 Hz apart, and a semitone at the guitar’s low E — 82.41 Hz to 87.31 Hz — is 4.9 Hz. More than four semitones fit inside one bin down there, so the answer at the bottom of the instrument is not a note, it is a neighbourhood. The second is the missing fundamental: a plucked low E is a weak first harmonic underneath a much stronger second and third, so the loudest bin is routinely the octave or the twelfth, and a tuner reading it will tell you a perfectly tuned string is an octave sharp.

The period, not the peak

Autocorrelation asks a different question: at what delay does this signal most resemble itself? That delay is the period, and the period of a note is the period of its fundamental whether or not the fundamental is the loudest thing in it. The measure used here is the normalised square difference — McLeod’s function — which divides by the energy actually present at each delay. Plain autocorrelation falls off as the delay grows for no musical reason, because fewer samples overlap, and that bias pushes every reading towards the shorter period; normalising removes it and puts the result on a fixed scale from zero to one, which is what makes a clarity threshold mean something instead of being a number somebody tuned by ear.

The window, and the refinements

The window is 8,192 samples — 186 ms at 44.1 kHz, about five and a half periods of a five-string bass’s low B at 30.87 Hz. Twenty of them are measured a second. The winning delay is then interpolated with a parabola through its two neighbours, because one whole sample of delay is 3.2 cents at the guitar’s low E and 12.9 cents at the E two octaves above it, and a tuner that cannot resolve better than thirteen cents is a tuner you cannot tune to. And the delay taken is the FIRST peak that clears ninety per cent of the tallest, not the tallest itself: the tallest peak of this function often sits at a multiple of the true period, and taking it is the other way to report an octave that was never played.

When it declines to answer

Two gates, and both of them produce a sentence rather than a reading. A frame quieter than −46 dBFS is refused outright: with no signal an autocorrelation still returns its best guess, and that guess wanders and looks exactly like a string drifting. A frame whose clarity is under 0.6 is refused as well — a room, a breath, a knock on the body of the instrument are not pitches, and the honest answer is to say nothing rather than to name the loudest thing present.

Two strings at once

This is worth stating plainly, because it is where every autocorrelation tuner is weakest and the failure looks like a bug. Two notes sounding together are not two pitches to this method — they are one signal, and that signal really is periodic, at the slower rate the pair repeats at. An E and an A together repeat about 27.5 times a second, so the mathematically correct answer to “what is the period of this window” is a note neither string is playing. Nothing in the arithmetic is wrong there; the question was.

So when an instrument is chosen the page hands the detector the range that instrument’s strings actually live in, a minor third either side. Most of those composite periods then fall below the range and are refused rather than reported, which is why the panel says it cannot hear a pitch instead of naming one nobody played. It is not a cure: where the two notes make a simple ratio the composite lands inside the range anyway — a B and the E above it are three to four, and repeat at exactly the E two octaves down, which is a guitar string. Chromatic mode has no range to narrow at all. Either way the rule is the same one every tuner has: play one note at a time, and let the last one stop ringing.

The needle

What the needle points at is the median of the last five accepted readings. A median of an odd-length list is one of the values in that list, so the number on screen is always a number some frame actually measured — an average is not, and an average is what puts a tuner between two notes when one frame reports the octave. Between two of those targets the needle eases, which is animation from one measurement to the next; it never extrapolates, never decays towards zero, and does not move at all while nothing is arriving. When the sound stops, the last reading stays on screen, dimmed, and says it is being held.

Where the audio goes

Nowhere. The stream from getUserMedia reaches an AnalyserNode and stops there; the analyser is not connected to the speakers, because connecting a microphone to the speakers is feedback. Each window is copied into one reused array, measured, and overwritten by the next one. There is no fetch, no XMLHttpRequest, no WebSocket and no upload target in any of this property’s own code — the three scripts it adds are js/pitch.js, js/mic.js and js/tone.js, with js/app.js for the page, and you are welcome to read all four.

One thing on this page does reach the network, and it is worth naming rather than leaving for you to find in the developer tools: the site’s Google Analytics tag, which every page on labs.llc carries. It loads in the head, records that a page was viewed and sets its own cookie. It is nothing to do with the tuner, it is not passed a single sample, and it runs whether or not you ever press Listen.

If the microphone will not open

Every way that can go is answered in words on the panel above rather than by a dead needle: a page not served over HTTPS, where browsers do not offer the microphone at all; a browser without the API; a refusal, which will not prompt again until you change it at the padlock; a prompt dismissed without an answer, which will; no microphone on the machine; one held by another application; and one unplugged in the middle of a session. The difference between a refusal and a dismissal is read from the Permissions API where the browser offers it, and where it does not, the page says both possibilities instead of picking one.

About

A tuner, not a laboratory

This is a chromatic tuner and nothing more. It measures one pitch at a time and will not do polyphony: play two strings together and the clarity gate closes, which is the correct answer rather than a guess at which of them you meant. It has no strobe display, no temperament tables beyond equal temperament, and no intonation or string-gauge calculator.

It does not claim laboratory accuracy. The arithmetic resolves a period far more finely than a cent, but what reaches it has been through a microphone, a preamplifier and a converter of unknown quality, in a room, and the instrument itself is moving: a string settles for a minute after it is stretched, and wood and a plectrum both bend a pitch by more than the numbers on this page are printed to. The reading is honest about the signal it was given; it says nothing about the signal it was not.

Everything the page shows is measured here and now, or computed from your own A4. There is no stored sample, no example reading and no demonstration mode: before the first note is played every figure on the panel is an em dash, and that is deliberate.

The settings the tuner itself keeps in this browser are two — the reference pitch (labs.tuner.a4) and the instrument you last chose (labs.tuner.instrument). The site’s chrome adds one more, which edition you are reading, and the analytics tag named in the method section sets a cookie of its own. That is the whole list. No audio is stored, in this browser or anywhere else.