● A free public tool  ·  Built by Poptani Labs  ·  No sign-up  ·  Your data never leaves your browser
Built in the Lab · 5-minute read

How Shazam names that tune in seconds — with no idea what the song sounds like

A spectrogram of the refrain of Midge Ure's song "Breathe", showing bright bands of sound energy across time and frequency
Image: '"Breathe" - Midge Ure - refrain spectrogram.png' by Sonic Visualizer, CC BY-SA 4.0, via Wikimedia Commons

This is a research-based piece, drawn from the sources listed at the end. You are in a café, a song you love is playing, and you have no idea what it is called. You hold up your phone, tap a button, and within seconds the title and artist appear. Shazam does not understand music the way you do — it has never heard the melody and does not know the lyrics. What it does is stranger: it turns a few seconds of sound into a pattern of dots, then looks that pattern up like a word in a dictionary.

The problem: a song you cannot describe

The recording your phone hears is never the clean studio version. There is chatter, clinking glasses, a humming fan — and the clip starts at a random point in the song, so the system cannot simply line two waveforms up and compare them. Shazam's answer, designed by Avery Wang and published in his 2003 paper "An Industrial-Strength Audio Search Algorithm", was to compare a compact fingerprint of the sound instead: something that survives noise and distortion but is still unique to one song. The paper reported it could identify a short clip captured through a phone microphone, even with voices and other noise in the foreground, from a database of over a million tracks.

Step one: turn sound into a picture

First, the sound is drawn. Your phone slices the recording into tiny overlapping windows, each a few tens of milliseconds long, and works out which frequencies are present in each slice. Stack those slices side by side and you get a spectrogram: a picture of sound where time runs left to right, frequency runs bottom to top, and brightness shows how loud each frequency is at each moment. But a spectrogram is huge, so the next step is to throw most of it away.

Step two: keep only the brightest stars

Shazam keeps only the spectrogram's loudest moments: the points where the energy is higher than in the surrounding area. These peaks are the strongest notes and drum hits, the parts of the sound most likely to survive background noise and a crackly phone connection. Background chatter adds low-level energy across the picture, but rarely the loudest point in any region, so the surviving peaks are mostly the song's own. Plot them as dots and you get what Wang called a "constellation map" — a sparse scatter that looks, fittingly, like a field of stars. Two recordings of the same song give nearly the same constellation, quiet room or noisy bar — much like how a QR code survives a smudged print by keeping only what is robust.

Step three: fingerprints made of pairs

A single dot is not enough — plenty of songs share a loud note at some frequency. The clever part is pairing dots up. For each peak, the system looks at a nearby peak a little later in time and combines the two frequencies and the gap between them into a single short number, a hash: the fingerprint of that pair of peaks. A few seconds of music yield a handful of hashes that together are effectively unique to that song, and the database stores each hash alongside its song and its time within the song. When you tap the button, your phone does the same work on your clip and sends its hashes off for lookup. If several of them match the same song, with their time gaps lining up, the system has found its match. So it works from just a few seconds, wherever in the song you start: the relative gaps between peaks are the same. The lookup is fast because hashes are indexed like words in a dictionary — the system does not listen to every song in turn, any more than this site's search reads every page in turn.

The fun anecdote: dial 2580, hold up the phone, wait for a text

Long before there was an app, Shazam was a phone number. Founded in 1999 by Chris Barton, Philip Inghelbrecht, Dhiraj Mukherjee, and Avery Wang, the service launched in the UK in August 2002 under the name "2580" — the short code you dialled from your mobile. You rang the number, held your phone up to the speaker for about thirty seconds, and hung up. A text message then arrived with the song title and artist. The first song ever identified during the public beta, in April 2002, was T. Rex's "Jeepster". In September 2018 Apple acquired the company for a reported $400 million. The phone number is gone, but the idea — a fingerprint, a lookup, an answer — has not changed since Wang's paper.

Why it still works in a noisy bar

Every design choice here was made for robustness rather than fidelity. Peaks survive noise because they are the loudest thing in their neighbourhood. Hashes survive a recording that starts mid-chorus because they encode relative timing, not absolute position. And matching many hashes at once survives the odd wrong one, because a few corrupted fingerprints cannot outvote a consistent set. None of this requires the system to know anything about music — no melody, no harmony, no genre. The next time a song you cannot name floats past, remember: your phone draws a picture of the sound, picks out its brightest stars, and asks a vast catalogue whether it has seen this constellation before — like GPS finding your position from satellite signals, the answer comes from measuring precisely, not from understanding.

Under the Hood

Shazam never listens to a song the way you do. It draws a picture of the sound, keeps only the brightest dots, and matches their pattern against a catalogue — a trick from a 2003 paper that still powers the button in your pocket. The deeper lesson: you do not need to understand something to recognise it. You only need a fingerprint that survives the real world, and a fast way to look it up.

Related on Poptani Labs: How GPS finds you: satellites, clocks, and a little bit of Einstein, How a QR code survives a smudge: the squares that fix themselves, How this site's search works: an index, not a reading list. More in this category: Built in the Lab.

Sources: Avery Li-Chun Wang, 'An Industrial-Strength Audio Search Algorithm' (ISMIR 2003), Shazam (music app) — Wikipedia, UC Berkeley Haas, 'Shazam' — the founders' story, CDM, 'Shazam is 20 years old: history, trivia, and tips'

← All posts