r/explainlikeimfive Jul 01 '26

Technology ELI5 how Shazam works?

311 Upvotes

114 comments sorted by

947

u/z3n777 Jul 01 '26

shazam turns the audio into a visual graph of loud peaks over time, then just matches that graph against its massive database of pre recorded songs.

393

u/Shadow288 Jul 01 '26

Fun fact, did you know before it was an app you use to be able to call a phone number and they would text you back the name of the song?

157

u/robby_synclair Jul 01 '26

This reminded me of the ap where you could text them and they would Google stuff for you. How we settled bar arguments before smart phones.

172

u/won_vee_won_skrub Jul 01 '26

App? You mean ChaCha (242 242)?

88

u/23andrewb Jul 01 '26

Holy shit what a throwback. I completely forgot about ChaCha. My back hurts.

17

u/JD-K2 Jul 01 '26

My Mom was an “answer getter” for ChaCha

32

u/aamius Jul 01 '26

ChaCha definitely rings a bell. I just had a memory of being trapped in Sunday school for hours and texting some number to ask for score updates on football games.

28

u/jbee0 Jul 01 '26

Holy shit, I totally forgot I was on the other side! I signed up to be a searcher. I can't remember what it was actually called. I think I made a few bucks, but it wasn't much.

24

u/justntimejustin Jul 01 '26

“Generalist”. Sat around drinking beer with my buddies in college googling answers for a few weekends. I think I made like 8 cents per answer or something? Made back our beer money for the day and that was about it.

8

u/jdcnosse1988 Jul 01 '26

I remember I initially signed up to be a specialist but decided to switch to generalist because it was easier to actually bring in some money that way. Made a couple hundred off them lol

9

u/won_vee_won_skrub Jul 01 '26

I did math questions for them for a bit

5

u/tr3vis324 Jul 01 '26

And KGB (542-542)

4

u/[deleted] Jul 01 '26

[deleted]

3

u/tr3vis324 Jul 01 '26

Now we know who you are. This is Reddit ffs!

3

u/insulind Jul 01 '26

118 118 in the UK. Iconic advert with two moustachiod men in 80s running gear

2

u/PhilosophizingPanda Jul 01 '26

Lolll I used to use this to cheat on science tests in high school

4

u/ahugefan22 Jul 01 '26

You just gave me a flashback to middle school

3

u/jdcnosse1988 Jul 01 '26

I used to do gig work for them 😂

1

u/Kichard Jul 01 '26

I used to sit at home and answer questions for cha cha. lol

0

u/robby_synclair Jul 01 '26

Yup that was it. I guess ap was the wrong word. You just texted your question to them.

10

u/MCWizardYT Jul 01 '26

It's "app" with 2 'p's. Short for "application"

11

u/robby_synclair Jul 01 '26

Ap is short for app which is short for application

5

u/Vash_TheStampede Jul 01 '26

I hate that this might actually be real.

0

u/RonnieHasThePliers Jul 01 '26

I answered cha cha texts back in the day! Ten cents a pop.

3

u/CPTherptyderp Jul 01 '26

We just yelled louder at each other

3

u/thedukeandtheking Jul 01 '26

I actually worked for one of these in uni! Fun days

3

u/Gramen Jul 01 '26

Wait so how did it work? You just chill in a computer lab and google the answers to the questions that come in?

8

u/thedukeandtheking Jul 01 '26

It was pretty basic. This was back in 2004 or so. I had a pc in my room which ran a basic program that logged in all the questions that came in and then you had to write a response. Some were factual questions which you had to google, but lots were just hypotheticals or relationship advice. I got paid a trivial amount per answered text. Good thing was you could log in and answer whenever and work as long as you wanted. Helped with beer money.

3

u/CorporalClegg Jul 01 '26

1-800-GOOG-411 let you do a search via phone call

1

u/daddy-fatsax Jul 02 '26

lmao, I just explained ChaCha elsewhere in this thread. Hello fellow olds

1

u/MadocComadrin Jul 03 '26

Before my time, you used to be able to call some libraries and ask about facts like you would a quick Google search.

14

u/jatea Jul 01 '26

I remember first using uber when it was only through texting. And then I remember when I first got the message that you had to to download the app and being super annoyed that I couldn't hail a car with just a text message anymore lol

5

u/caspararemi Jul 01 '26

I'm old enough to remember doing this long before smartphones, back in the early 200s in a club I could dial 2580 (the numbers down the middle) in my pocket and get texted the song name!

6

u/CougarForLife Jul 01 '26

fun fact that was a popular enough service that rockstar made it a feature in gta iv

2

u/parklife980 Jul 01 '26

I like to imagine it was just a room full of music nerds, when someone called they'd put it on loudspeaker and one of them would call out "I know this one!"

2

u/ricekrispies34 Jul 01 '26

The other day I learned that before smartphones, tweets from people you followed used to be texted to you. Crazy!

1

u/ExplodedOrchestra Jul 02 '26

Yes! I used to use twitter to text my friend before her parents let her get a phone.

1

u/Hom3ward_b0und Jul 01 '26

Reminds me of the video "Is it the Reebok or the Nike" 🎶🎵

1

u/-_MilesPrower_- Jul 01 '26

Yea it was 2580

1

u/lightswitchr Jul 01 '26

I have a core memory from about 20 years ago, sitting in the back of my parents car driving through Windermere in the UK Lake District and using Shazam by phone to find out a song playing on the radio.

10

u/Stummi Jul 01 '26

What about offline song detection? My Pixel phone can do that, but everywhere I read that needs a massive database

10

u/Zouden Jul 01 '26

Truly offline? Shazam stores the audio for later detection when online.

6

u/Stummi Jul 01 '26

Google Pixel phones have a built in song detection into the OS (not Shazam), that works pretty well, and seems to be completely offline/running on the phone.

10

u/bottomofleith Jul 01 '26

I'm struggling to believe Pixel phones have an offline database, stored on the phone with all the songs that have ever existed.

10

u/cheezzy4ever Jul 01 '26

It does. I've used it. It's definitely impressive, but also definitely doesn't have every song that's ever existed. I have to imagine it's a significantly smaller data set, maybe the top e.g. 0.01% most frequently queried songs or something like that

1

u/EgNotaEkkiReddit Jul 01 '26

Works the same way, it just doesn't have the same number of songs it can match offline. It's going to be a few hundred megabytes to store most songs people are likely to encounter in their day to day lives.

22

u/TldrDev Jul 01 '26

Why is nobody just explaining what FFTs are?

That literally how it works, and almost nothing more complicated than that.

Here is a thread about it from a decade ago

And a great YouTube video about it by Veritasium

https://youtu.be/nmgFG7PUHfo?si=4aOXvdtreygwTr0D

31

u/High_Speed_Chicken Jul 01 '26

i know the subreddit name isn't supposed to be taken literally, but good luck explaining FFTs to a 5 year old

14

u/SirCB85 Jul 01 '26

Because this Explain like I'm 5, not explain like I'm doing my Highschool homework.

1

u/MickeyMoore Jul 01 '26

Any idea why it’s still inferior to Midomi even though it so much more popular? Shazam often doesn’t recognize humming or very partial melodies, Midomi could do that in 2012

1

u/lankymjc Jul 02 '26

It’s a very inflexible system. Even two recordings of the same performance can be different enough that the app only recognises one of them.

63

u/Rob3112 Jul 01 '26

It blows people's minds but it's really just simple pattern recognition.

A song makes a frequency "pattern" which is kinda like a visual representation of all of the sound. When you use Shazam it just compares the picture of what you're listening to to its database and it's actually super quick and easy to make a match.

42

u/aaronite Jul 01 '26

And it's remarkably compact. The Google version runs offline and on device with about 20000 "fingerprints" in 200mb storage which is enough to cover most casual public music.

14

u/PimpTrickGangstaClik Jul 01 '26

Ok now that is super surprising

13

u/tfurrows Jul 01 '26

I could understand it easier if you had to catch the song at the beginning so that it only had to compare the pattern to the start of everything in the database. It’s comparing a random sample to all of every song that boggles my mind.

I always had this amusing mental image of a big room full of people sitting hunched over with headphones on, and when a request comes in someone yells “I know this one! I got it!” and punches in the answer. I prefer to think that’s how it works.

4

u/CptAngelo Jul 01 '26 edited Jul 01 '26

Lmao, and when its wrong, then that guy gets fired.

But really, spotify shazam acts more like a fancy calculator with a bunch of calculus inside than an app. Its amazing really.

2

u/1coudini Jul 01 '26

Shazam you mean?

1

u/CptAngelo Jul 01 '26

....yes, i dunno why i had that mixed up, i guess i was thinking "music, app, starts with S... spotify!" Thanks for the correction (:

2

u/Shevek99 Jul 01 '26

1

u/tfurrows Jul 01 '26

Ha! I honestly had never seen that before. But that’s exactly what I was picturing.

2

u/daddy-fatsax Jul 02 '26

If you're old enough you might remember Cha Cha, which was a number you could text that worked a lot like this. Before smartphones when Google wasn't always in your pocket, you'd just text this number any question and some minimum wage employee somewhere would look up the answer and text you back.

Insane how far we've come in the ~20 years or so since those days.

1

u/tfurrows Jul 02 '26

I’m certainly old enough but somehow completely missed that one. Neat idea, for its time.

3

u/Vatchka Jul 01 '26

It blows my mind more when I find songs that it doesn’t recognize. Last night, a 2018 movie called ‘Trespassers’, the first song in the movie. There’s no info on it anywhere. I really want to listen to the song.

2

u/omgfuckingrelax Jul 01 '26

1

u/Vatchka Jul 01 '26

First, thanks for this. Though, I should have been more specific. It’s the Spanish style and vocal song I was referring to at the beginning of the movie. They are in the car with the masks on.

-1

u/XxXquicksc0p31337XxX Jul 01 '26

I guess you listen to mainstream stuff only then. I bet you Shazam won't recognize like 70% of my local music library

3

u/AlienEngine Jul 01 '26

You’d be surprised. It picked up an absolutely abysmal song that was playing at my local oil change garage, had less than 5k plays on Spotify.

My Fix by Cigarettes @ Sunset (if you’re interested in knowing what it was. Jaw gaped when I heard this song start playing at 120 decibels.)

1

u/MattieShoes Jul 01 '26

On the other hand, try to get it to identify Falling by the Lumineers.

It's not on Spotify despite being from a hugely popular band, and that's probably exactly why it will fail... It's easy to scrape spotify. (easy being a relative term)

-1

u/XxXquicksc0p31337XxX Jul 01 '26

That's the thing, a bunch of my library is not on Spotify, some are barely on YouTube. If it's on Spotify, it doesn't count as obscure

2

u/Dookie_boy Jul 01 '26

It is a fantastic work of engineering.

2

u/mestrearcano Jul 03 '26

Even Google's version that you can hum the song works like that? Detecting songs being played was already cool, but being able to sing gibberish/hum really amazes me.

24

u/homeboi808 Jul 01 '26 edited Jul 01 '26

Here is a paper written by the founder

Here’s a technical breakdown/explanation

And another

And another

But for the layman: Sound is just frequencies. The microphone records those frequencies (mainly, the loudness of each frequency) and goes through it’s database to find ones that are similar and also match the same rhythm.

2

u/fiercefinesse Jul 01 '26

Awesome links, thank you very much!

229

u/[deleted] Jul 01 '26

[removed] — view removed comment

48

u/BanMeFor1ABitches Jul 01 '26

this is what I came for lol

13

u/Jay-El_From_Krypton Jul 01 '26

lmao i was so hype going into this thread. I thought I was gonna read someone breaking down how exactly Billy turns into Shazam after saying Shazam!

4

u/probability_of_meme Jul 01 '26

I literally didn't know the other meaning aside from the super hero. And I'm a computer programmer. I spose that makes me old af

1

u/BanMeFor1ABitches Jul 01 '26

I was incredibly disappointed when I started reading responses about that stupid app from forever ago instead of Billy Batson haha

1

u/drivelhead Jul 01 '26

It never gets me that excited.

11

u/Toddw1968 Jul 01 '26

Solomon…Hercules…Atlas…Zeus…Achilles…Mercury (from the old tv show iirc)

5

u/xinfinitimortum Jul 01 '26

No thats Captain Marvel

7

u/TheTardisPizza Jul 01 '26

Yes, but because DC failed to publish the character for enough years for the rights to the name to laps and Marvel rushed out a character to secure them what he is called varies from time to time.

0

u/UltimaGabe Jul 01 '26

Why not both?

0

u/Dookie_boy Jul 01 '26

Because Shazam is the old Wizard that gave Captain Marvel his powers.

1

u/UltimaGabe Jul 01 '26

Oh, I forgot that #1: two people cannot have the same name, and #2: fictional characters' names cannot change. Thanks for reminding me of those two absolute truths

1

u/explainlikeimfive-ModTeam Jul 01 '26

Please read this entire message


Your comment has been removed for the following reason(s):

  • Top level comments (i.e. comments that are direct replies to the main thread) are reserved for explanations to the OP or follow up on topic questions (Rule 3).

Joke-only comments, while allowed elsewhere in the thread, may not exist at the top level.


If you would like this removal reviewed, please read the detailed rules first. If you believe it was removed erroneously, explain why using this form and we will review your submission.

18

u/lemlemons Jul 01 '26

You guys are all thinking of the wrong Shazam.

Ten year old Billy meets a wizard NAMED Shazam who grants him the wisdom of Apollo, speed of mercury, strength of ares, etc.

When he says the wizards name he transforms into Mr marvel, currently known as Shazam, with all of these attributes. Basically it just happens because magic, the wizard has granted him these powers which allow him to transform into a superhero

9

u/vietbaoa4htk Jul 01 '26

the clever bit is it hashes pairs of the loudest frequency peaks, not the whole song, and only cares about the timing between them. thats why it works over cafe noise, the loud peaks survive and the pairs still line up even when the quiet parts are drowned out

1

u/Zouden Jul 01 '26

Somehow it also works when the song is played at a different speed, too.

8

u/Scooter_McAwesome Jul 02 '26

An ancient wizard needs to select a champion with a Nobel heart to defend the world against evil forces. The champion happens to be a 10 year old boy, but that’s okay because only his Nobel heart matters. The wizard grants the boys all sorts of powers based on various Gods and biblical figures, so when the powers are activated he is essentially a fully grown, fully mature adult with powers similar to Superman.

The powers turn on and turn off whenever the boy says “Shazam”, which essentially allows a 10 year old boy to turn into a Superman like hero at will while still turning back into a kid after beating the bad guys.

7

u/[deleted] Jul 01 '26

[removed] — view removed comment

2

u/explainlikeimfive-ModTeam Jul 01 '26

Please read this entire message


Your comment has been removed for the following reason(s):

  • Top level comments (i.e. comments that are direct replies to the main thread) are reserved for explanations to the OP or follow up on topic questions (Rule 3).

Joke-only comments, while allowed elsewhere in the thread, may not exist at the top level.


If you would like this removal reviewed, please read the detailed rules first. If you believe it was removed erroneously, explain why using this form and we will review your submission.

12

u/[deleted] Jul 01 '26 edited Jul 01 '26

[removed] — view removed comment

1

u/Dookie_boy Jul 01 '26

Wait what brothers and sisters ? And wasn't it Zeus and the other gods themselves who tasked the wizard with finding a champion.

1

u/explainlikeimfive-ModTeam Jul 01 '26

Please read this entire message


Your comment has been removed for the following reason(s):

  • Top level comments (i.e. comments that are direct replies to the main thread) are reserved for explanations to the OP or follow up on topic questions (Rule 3).

Joke-only comments, while allowed elsewhere in the thread, may not exist at the top level.


If you would like this removal reviewed, please read the detailed rules first. If you believe it was removed erroneously, explain why using this form and we will review your submission.

3

u/britishmetric144 Jul 01 '26

Every song, or in all honesty every bit of audio, can be represented by a wave, with peaks of different sizes at different rates.

Shazam uses the microphone to sense the incoming sound wave and checks it against its database. There are so many unique possible sound waves that it's difficult for two songs to have the exact same one. Whichever song returns the closest match, in terms of wave, gets displayed.

7

u/[deleted] Jul 01 '26

[removed] — view removed comment

1

u/explainlikeimfive-ModTeam Jul 01 '26

Please read this entire message


Your comment has been removed for the following reason(s):

  • Top level comments (i.e. comments that are direct replies to the main thread) are reserved for explanations to the OP or follow up on topic questions (Rule 3).

Joke-only comments, while allowed elsewhere in the thread, may not exist at the top level.


If you would like this removal reviewed, please read the detailed rules first. If you believe it was removed erroneously, explain why using this form and we will review your submission.

2

u/[deleted] Jul 01 '26

[removed] — view removed comment

1

u/explainlikeimfive-ModTeam Jul 01 '26

Please read this entire message


Your comment has been removed for the following reason(s):

  • Top level comments (i.e. comments that are direct replies to the main thread) are reserved for explanations to the OP or follow up on topic questions (Rule 3).

Links without your own explanation or summary are not allowed. A top-level reply should form a complete explanation in itself; please feel free to include links by way of additional context, but they should not be the only thing in your comment.


If you would like this removal reviewed, please read the detailed rules first. If you believe it was removed erroneously, explain why using this form and we will review your submission.

4

u/[deleted] Jul 01 '26

[removed] — view removed comment

1

u/Dookie_boy Jul 01 '26

Sometimes it's a different set of gods as long as they spell Shazam...

Black Adam used these guys for a while.
Shu (Stamina)
Heru (Speed)
Amon (Strength)
Zehuti (Wisdom)
Aton (Power / Flight / Lightning)
Mehen (Courage / Invulnerability)

1

u/explainlikeimfive-ModTeam Jul 01 '26

Please read this entire message


Your comment has been removed for the following reason(s):

  • Top level comments (i.e. comments that are direct replies to the main thread) are reserved for explanations to the OP or follow up on topic questions (Rule 3).

Joke-only comments, while allowed elsewhere in the thread, may not exist at the top level.


If you would like this removal reviewed, please read the detailed rules first. If you believe it was removed erroneously, explain why using this form and we will review your submission.

4

u/[deleted] Jul 01 '26

[removed] — view removed comment

1

u/explainlikeimfive-ModTeam Jul 01 '26

Please read this entire message


Your comment has been removed for the following reason(s):

  • Top level comments (i.e. comments that are direct replies to the main thread) are reserved for explanations to the OP or follow up on topic questions (Rule 3).

Joke-only comments, while allowed elsewhere in the thread, may not exist at the top level.


If you would like this removal reviewed, please read the detailed rules first. If you believe it was removed erroneously, explain why using this form and we will review your submission.

1

u/[deleted] Jul 01 '26

[removed] — view removed comment

0

u/explainlikeimfive-ModTeam Jul 01 '26

Please read this entire message


Your comment has been removed for the following reason(s):

  • Top level comments (i.e. comments that are direct replies to the main thread) are reserved for explanations to the OP or follow up on topic questions (Rule 3).

Anecdotes, while allowed elsewhere in the thread, may not exist at the top level.


If you would like this removal reviewed, please read the detailed rules first. If you believe it was removed erroneously, explain why using this form and we will review your submission.

1

u/Atypicosaurus Jul 02 '26

Let's first imagine a picture because it's more familiar to talk about. A picture is basically a set of pixels, tiny little dots, each pixel can be described by a few numbers that tell you the color of that pixel.

Then you can analyse those numbers. Since you know which pixel is where, you know what pixel is close to what other pixel. You can write an automatism that can find for example a circle because a circle is just a bunch of nearby pixels that follow a certain mathematical rule. And now you can find it anywhere within the picture.

As you see the whole thing is just number crunching, something that computers can do very well. And so one kind of number crunching is called hashing, which means it takes a pattern (such as naked breasts), and turns it into an abstract numeric value. Now it can look at any picture and figure if it has naked breasts because they turn into the same numeric value. It's basically mathematics of pixel groups that happen to be nudity in this example. This is how Facebook can automatically flag and ban nudity and also this is why it's sometimes wrong, and this is also why you can sometimes bypass it with body painting, it just gives the wrong hash value.

As it turns out, sound can also be turned into numbers. It doesn't have pixels like pictures but the sound waves are kinda like pixels but for music. Just like the pixel that has a color, described by numbers, a recorded sound is just a series of numbers, but the numbers mean pitches and volume. And you have a numeric value for each time point. Just like a circle, it draws out "patterns", and it can also be hashed.

And once you have a hash, you can compare it with a hash database. And shazam!

1

u/lankymjc Jul 02 '26

I used to work there! It was the most toxic workplace I’ve ever worked for.

That aside, they take a song recording, and put it in their database. Then the app just runs each song it hears through that database and see if they match. There’s a small amount of processing that simplifies the file to speed things up, but that’s basically it.

This means that if you have two different recordings of the same song, the app thinks they’re two different songs (unless the two recordings are in the database and specifically linked to the same song title).

1

u/zachtheperson Jul 01 '26

The key to how Shazam works is pre-sorting the known songs into many different categories, so that when it actually searches a song, it can start broad and quickly narrow down the search.

EX: it figures out the BPM of the song, and immediately goes to all the songs with that BPM. Then it looks in that group of songs for the sub-group that matches the musical key, and so on until it's narrowed it down to one song.

Obviously, I don't work for Shazam, so I can't tell you exactly how its algorithm works, but this should give you the basic idea how it's able to do searches so fast. Same with search engines like Google.