How it works

Every stage of the pipeline runs in your browser, frame by frame, with no network round-trip. Here's each step.

Pitch → chroma

A bank of Goertzel filters is tuned directly to each semitone from C1 to C7, derived from your reference pitch. Low notes get a longer window than high notes so the bass stays accurate without slowing everything down. Energies are log-compressed and folded into 12 pitch classes.

Rejecting percussion

A cymbal, rimshot or pick attack is loud across the whole spectrum but gone within a few frames. A held note is present in every one. So the analyser takes the running minimum of each pitch across the last few frames: transients fall to near zero, sustained harmony passes through intact. That's the sustain gate, and it's the biggest accuracy win on a loud stage. The input card reports how much it's rejecting.

Two threads

Detection runs on the browser's audio thread, which keeps a rolling buffer and hands over frames on a fixed cadence — so a heavy repaint on a projector can't starve the analyser. Where the environment refuses to load that module, it falls back to analysing in the render loop and says so on the input card. The maths is the same in both paths; only the cadence differs.

Chroma → chord

The 12-value chroma is matched by cosine similarity against templates for major, minor, diminished, augmented, sus2/sus4, 6, m6, 7, maj7, m7 and m7♭5 in all twelve roots. The detected bass note breaks ties toward the root, and a short hysteresis window stops the display flickering between neighbours.

Chroma → key

Chroma is accumulated over your chosen window and correlated against the Krumhansl–Kessler major and minor key profiles across all 24 keys. The winning correlation gives the key; the gap to second place gives the confidence bar.

Onsets → BPM

Spectral flux — the frame-to-frame rise in the spectrum — is resampled to an even grid and autocorrelated across lags from 60 to 200 BPM. Half and double-time candidates are folded toward the range a band actually counts in. Tapping takes the median inter-tap gap, so one late tap can't drag the count, and overrides detection for 25 seconds before going stale.

Tempo → the beat grid

Once a tempo is known, chord lengths are read in bars and beats rather than seconds, and the hold threshold before a chord is logged scales to the beat — so a passing chord at 80 BPM isn't judged by the same stopwatch as one at 160. Cycle length is summed on the quantised grid to name the form in bars.

Reference tones

Tones are additive — a fundamental plus a few harmonic partials — generated live rather than played from files, so they follow your reference pitch exactly and retune while sounding. They come out of this device's output, so the mic will hear them; that's expected.

Privacy and permissions

  • Audio is read frame by frame from the live input and analysed in place. Nothing is buffered to disk, recorded, or sent over the network — this page makes no network requests while listening.
  • The mic only opens after you press Start listening and your browser grants it. Stop releases the device and the indicator light goes out.
  • Your settings are stored locally on this device only.

Built with Ox

Ox Onstage was built by Josh, founder of Ox, as a working demonstration of what Ox, Ox Sites, and Ox Build can produce — a real-time DSP application with a self-test suite, shipped as a published site rather than a static brochure page.

← Back to the live display