Skip to content

About

Real-time chromatic tuner for guitar, bass, ukulele and violin, on the web and Android

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

40 Commits

Folders and files

Repository files navigation

String Tuner

Live Demo

String Tuner on a phone: a string too low, a string in tune, every string in tune

A chromatic instrument tuner that runs in the browser and on Android. It listens to your microphone in real time, detects the pitch of the note you're playing, and tells you how many cents sharp or flat you are from the target string.

Features

  • Pitch detection built for tuning strings: accurate to a fraction of a cent (pedal tuners are rated ±1 cent), in tune within ±3 cents, and not thrown off by the string you tuned before still ringing
  • Multiple instrument categories: guitar, bass, ukulele, and violin — each with tailored signal-processing parameters
  • Preset tunings (Standard, Drop D, Half Step Down, Open tunings, scordatura variants, and more)
  • Reference pitch calibration, as on a pedal tuner: A4 from 436 to 445 Hz in 1 Hz steps (440 by default), and every string's target follows it
  • Sequential string-by-string tuning flow — starts on the lowest/thickest string, confirms in tune, then auto-advances; tap any chip to jump to a specific string
  • Visual stability ring (fills as pitch holds steady) and cents needle with opacity tied to signal confidence
  • Per-string tuned status — confirmed strings turn green with a check; tapping re-checks them
  • Supports flat note display (e.g. Eb instead of D#)
  • Liquid Glass interface in dark and light themes, with a layout for phones (portrait and landscape), tablets and desktop
  • Accessible: 44 pt touch targets, full keyboard use, states shown with icons and words as well as colour, and support for Reduce Motion, Reduce Transparency and Increase Contrast
  • English, Italian, and Chinese (Simplified) UI languages
  • Installable as a web app, and packaged as a native Android app via Capacitor

Screenshots

Desktop, dark theme: the ring on the left, the strings, the meter and Stop on the right
Desktop, light theme: the A string 30 cents low, with Tune up Desktop: the list of tunings as a dialog, in two columns
Phone in landscape: controls on the left, the ring on the right Tablet in portrait, light theme: the tuner on a card
Phone: the tunings sheet and the settings sheet

The pictures are taken from the running app. scripts/screenshots makes them again (so far, the two sheets).

Tech Stack

Design

The interface is a small design system in src/ui:

  • Tokens: colours for both themes, spacing, radii, type and effects.
  • Materials: the glass and thin materials, as classes.
  • Components: buttons, segmented controls, sheets, list rows and the rest.

The screens in src/components are built only from these pieces.

The source designs are in mockup/:

  • FigCraft file: the screens for every size, in both themes.
  • Background: the "strings in resonance" artwork.
  • Tokens: the exported design variables.
  • Foundations boards: colours, spacing, type and control states.

The large files are stored with Git LFS. Run git lfs install once, then git lfs pull to download them after cloning.

Signal Processing Architecture

The tuner always knows which string it is listening for, and every stage is aimed at it.

Layer Where Rate Responsibility
Capture useAudioCapture ~60fps (16ms) Microphone, low-pass filter, noise gate, deliver AudioFrame
Detector src/tuner/detector.ts per frame Pitch of the string to a fraction of a cent, its clarity, its share of the sound
Engine src/tuner/engine.ts per frame Reading, needle, in tune, confirm, next string
Presentation useTuner ~30fps (33ms) Write Vue reactive refs, update needle/ring/hint

Capture (useAudioCapture)

  1. Raw microphone — echo cancellation, noise suppression and automatic gain are turned off. They are tuned for speech: they fade out a sustained note as if it were noise and keep changing the level.
  2. Low-pass filter — a Butterworth biquad at 3× the string (280–2000 Hz): the fundamental and the first harmonics pass, the upper harmonics that mislead period detection are damped.
  3. Noise gate — a frame is analysed only above −60 dBFS and 6 dB above the room's own noise level, which the gate keeps learning from the unpitched frames.

Detector (per frame)

  1. Decimation — the filtered input is averaged down to a rate that still gives ≥ 64 samples per period, so a 31 Hz bass B costs as little as a violin E.
  2. Coarse pitch: McLeod Pitch Method — the normalised square difference function of a 60 ms (at least 4 periods) span, the same span at every lag, up to a fifth below the string, in double precision through one FFT pair; the first key maximum ≥ 0.9 of the highest, refined by parabolic interpolation.
  3. Fine pitch: phase measurement — as a strobe tuner does: the phase advance of the fundamental and of the 2nd harmonic between two Hann-windowed frames of 12 periods. A period method reads a blend of everything that rings (with the previous string still sounding, the new one several cents flat); in these narrow bands a string a third or a fourth away hardly counts. Only this fine pitch is ever shown: in the first moments of a note, before both frames hold it, there is no reading at all.
  4. Fundamental share — how much of the sound is at the pitch and its octave. B3 and E4 ringing together repeat at the period of E2 with no E2 in them: that phantom has none.
  5. Harmonic spread — the cents between the pitch the fundamental gives and the one the 2nd harmonic gives: within a cent for a string read cleanly, wide when noise in the bands pulls each its own way.

Engine (per frame)

  1. Clarity gate — 0.85 to start a reading, 0.75 to carry one on through the tail of the note (violin: 0.80 / 0.70). Another string ringing as loud lowers the clarity of the whole sound without spoiling the narrow-band pitch, so a frame down to 0.55 still counts when its harmonics agree within a cent.
  2. Range — up to a fifth either way reads as this string (direction to turn); a pitch an octave up (±300¢) is its 2nd harmonic. Anything else, a tuned string still ringing, or a phantom is ignored.
  3. Median of 5 readings — a single wrong frame never shows.
  4. Needle smoothing — 60 ms when steady, 25 ms while the pitch moves (a peg being turned); slower for readings whose harmonics disagree (noise).
  5. In tune — within ±3 cents after at least 3 readings, staying in until ±4 cents (no flicker at the edge); confirmed after a hold time in tune.
  6. Latch-and-fade — the reading stays 500 ms after the sound stops; the needle stays where it was.

Per-instrument configuration

Instrument Hold time in tune Clarity to start Clarity to carry on
Guitar 1000ms 0.85 0.75
Bass 1200ms 0.85 0.75
Ukulele 700ms 0.85 0.75
Violin 600ms 0.80 0.70

Measured on the virtual instrument (npm test)

Measurement Result
Error on a held note < 0.03 cent on guitar; < 0.2 cent in a noisy room (< 0.5 on ukulele)
First reading after a pluck 80–220 ms on guitar, already within half a cent; 0.15–0.36 s on bass
Needle behind a peg being turned 130–220 ms
Previous string ringing 6 dB down < 1 cent of error (a period method alone: 15–22 cents)

About

Real-time chromatic tuner for guitar, bass, ukulele and violin, on the web and Android

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages