# Shazam Algorithm Anatomy

By Numa

Topic: Computing, AI &amp; Electronics

[Open the interactive Jig](https://ask.jig.com/j/ZTJoPvMuKxWy)

## Guide

### 1. Name that tune

A song is playing and you want to know its name\. Shazam can tell you in seconds, even in a noisy café\. This little machine shows the recipe Avery Wang published in 2003, one station at a time\. Drag anywhere to turn it\.

Shazam launched in the UK in 2002\. You dialled 2580, held your phone up to the music and got the answer by text message\.

### 2. Listen for a few seconds

The phone records a short clip, about 5 to 10 seconds long\. It can be noisy, with chatter and clinking cups\. The phone does not send the whole recording\. It first boils the clip down to a small fingerprint\.

A fingerprint is a compact summary that identifies something, like the swirls on your fingertip\.

### 3. Turn sound into a picture

A tool called the Fourier transform takes a tiny slice of the clip and measures how loud each pitch is\. Sliding along the clip, slice by slice, it builds a spectrogram\. Time runs left to right, pitch runs front to back, and taller, warmer bars are louder\.

The glowing gate is the slice being measured\. Low notes sit at the front of the tray, high notes at the back\.

### 4. Keep only the brightest stars

Now most of the picture is thrown away\. Only the peaks stay: spots louder than everything around them\. Lifted up, they look like a star chart, so this is called a constellation map\. Add some café noise and see how many stars survive\.

Even how loud each star was is dropped\. Only its time and its pitch are kept\.

### 5. Pair the stars into hashes

One star alone is too common to be useful\. So each anchor star is paired with several stars in a target zone just after it\. Each pair becomes a hash: both pitches and the time gap between them, packed into one 32\-bit number\.

A hash is a short code made from data\. It uses the gap, not the clock time, so your clip can start anywhere in the song\.

### 6. Look it up instantly

The server keeps hashes from a huge music library in an index, like a card catalogue\. A hash goes straight to its own drawer, with no searching through the rest\. Each card inside says which song has that hash, and when\.

The 2003 paper describes a database of over a million tracks\.

### 7. Line up the times

Some cards are lucky accidents, so timing decides\. For every match, the time in the clip is subtracted from the time in the song\. For the right song these differences agree and pile up into one tall spike\. Chance matches scatter flat\.

Plotted as clip time against song time, a true match makes a straight diagonal line\.

### 8. Got it\!

The song with the tallest spike wins, and its title and artist travel back to the phone\. No lyrics and no melody guessing: just stars, pairs and a lightning\-fast lookup\.

The published method is classic signal processing, not machine learning\. Noise can hide some stars, but the ones left still line up\.
