A labs.llc instrument

Every note,
on every tuning.

A fretboard that is computed rather than drawn. Eleven tunings, fourteen scales and sixteen chord types, and every dot on the board is arithmetic: open string + fret, matched against a set of pitch classes. Switch to DADGAD and every shape redraws correctly, because there were never any shapes — only notes.

Click any fret and hear it. The strings are Karplus-Strong, which is to say the delay line is the pitch and the filter in the loop is the way the high harmonics die first — the same physics a real string obeys, which is why it sounds like one and not like a sample of one.

There is a real tuner too, on the microphone. Nothing is recorded and nothing is uploaded — every frame is measured and discarded.

Open the neck The tuner

The neck

Pick a key and look at it

Fretboard

The tuner

Play one string

Autocorrelation on the waveform, not a peak in a spectrum — which matters on a guitar, because a plucked low E has a weak fundamental under a very strong second harmonic, and a spectral tuner will happily tell you a perfectly tuned string is an octave sharp. Resolution is about a cent.

Pitch

The manual

How it is built

There are no chord diagrams in this page

A tuning is six MIDI numbers, a scale is a set of semitone offsets, a chord is a set of intervals, and a fret is open + n. Every dot, every highlight and every interval label falls out of that arithmetic. It is why an eleventh tuning is one line in js/theory.js rather than a new set of pictures, and why the ukulele and the four-string bass work without a single special case.

The string is rendered, not looped

The obvious way to build Karplus-Strong in a browser is a delay node fed back through a filter. The Web Audio spec requires any delay inside a cycle to behave as at least one render quantum — 128 samples, or 2.9ms, which is one wavelength of 344Hz. Every note above F4 would be clamped to the same pitch, and on a page whose whole purpose is telling you which note is under which finger, a neck that lies above the fifth fret is worse than no neck. So the string is rendered into a buffer in JavaScript, where the delay line is an array, the read pointer is fractional and the pitch is exact everywhere.

The fractional read is not a detail. Rounding the delay to a whole number of samples puts the top string about 26 cents sharp at the twelfth fret — audible, and precisely the kind of error the tuner on this same page would catch you out on.

Why the fret spacing looks right

Each fret sits at 1 − 2^(−n/12) of the scale length — the rule of 18. Evenly spaced frets are the thing that makes a drawn fretboard look wrong without your being able to say why.

The tuner's three refinements

Normalised square difference rather than raw autocorrelation, because raw correlation falls off as the lag grows for reasons that have nothing to do with music and biases every reading towards the shorter period. The first peak clearing the threshold rather than the global maximum, because the global maximum often sits at a multiple of the true period — that is the octave error. And parabolic interpolation on the winning lag, because one whole sample of period at 330Hz is five cents, and a tuner that cannot resolve better than five cents is not one you can tune to.

The microphone

Requested when you switch the tuner on and released when you switch it off, so the browser's recording indicator tells the truth. Frames are measured and discarded; nothing is stored and there is no server here to send anything to.