I build SongUp AI, and one of its free tools is an AI chord finder that works from an audio file: drop in an MP3 or WAV and you get the chords on a timeline, the key and the BPM. The whole analysis runs in a Web Worker in the browser, with no server and no ML model download. It's classic signal processing, and the interesting part was not the textbook pipeline but the fixes that made its output usable. Here's how it works.
1. Decode and downmix
The page decodes the file with the Web Audio API, mixes it to mono, and transfers the Float32Array to a worker (postMessage(..., [mono.buffer]), so it's moved, not copied). Everything below runs in that worker, so the page never freezes on a long song.
2. Chromagram: 12 numbers per moment
For each frame (FFT size 8192, hop 4096, Hann window) the worker looks at the magnitude spectrum between about 55 Hz (A1) and 2 kHz, keeps the spectral peaks (local maxima above 2% of the loudest bin), and adds each peak to its pitch class, weighted by how close it sits to the centre of that note. The result is 12 bins, C to B. That 12-number vector per frame is the chromagram: "how much C, how much C#, ..." at each moment.
Tuning fix. Plenty of recordings aren't tuned to A = 440. The worker estimates the song's tuning offset from the strong spectral peaks first (using a parabola through three log-magnitude bins to find the true peak between bins, and averaging the offsets on a circle so +49 and -49 cents don't cancel out to 0). It ignores bass peaks for this, because low notes sit too few FFT bins apart to measure cents reliably.
3. Key: Krumhansl-Schmuckler
Average the chromagram over the whole song and correlate it with the Krumhansl-Schmuckler major and minor key profiles, rotated to all 12 roots. The best of the 24 correlations is the key.
4. Chords: 168 templates and cosine similarity
Each chord is a 12-element binary template: 14 chord types (major, minor, 7, maj7, m7, 6, m6, add9, sus2, sus4, dim, dim7, m7b5, aug) times 12 roots = 168 templates. For each frame the worker picks the template with the highest cosine similarity to the chroma vector, with a minimum score below which the frame is "no chord".
That textbook version produced garbage on real music. Three changes fixed most of it:
- Smooth before matching. Average the chroma over about 0.45 s (5 frames, centred). One passing note or a snare hit no longer flips the chord for a single frame.
- Prefer plain triads. Extended chords contain the triad's notes plus more, so on noisy chroma they often score slightly higher, and every chord comes out as a 7th or an add9. Scoring extended types at 0.96 of their raw similarity means they only win when they clearly fit better.
- Use the key as a tie-breaker. A 2:20 pop song in F once came back with 173 chord changes, including Bmaj7 and F#maj7. Now, once the key is known, chords that belong to it (in C major: C, Dm, Em, F, G, Am, Bdim) get a small 6% bonus. Out-of-key chords still win when the evidence is clear; they just stop winning close calls.
5. Simplify the progression
Frame labels are merged into runs, and any run shorter than one beat is folded into a neighbour, shortest first, until none are left. Songs rarely change chord faster than a beat, and those short runs were almost always passing notes.
6. Tempo
BPM comes from onset-strength autocorrelation, limited to 40-200 BPM. It also gives the "one beat" length used in step 5.
Confidence scores
Every chord on the timeline shows its similarity score as a confidence bar. That turned out to be the most useful UI decision: instead of pretending to be right, the tool tells you which three chords to check by ear.
Limits
It's template matching, not a neural network, so dense mixes with heavy distortion, or jazz voicings beyond the 14 types, get approximated. It doesn't transpose, and it needs a file (up to 50 MB), not a YouTube link.
You can try it free (with a free account) at songupai.com/tools/chord-recognition. If you're doing pitch work, the same browser-only approach powers our free online autotune (YIN pitch tracking, snapped to a key and scale). Happy to go deeper on any step in the comments.
