r/howdidtheycodeit • u/ChalupaPickle • Aug 25 '21
Question How did they code the app shazam?
Is it as simple as gaining access to your mic and searching a database based off what words it hears? It picks the exact song within 5 seconds of hearing it. Surely it doesn't just search for the words it hears because for 5 seconds the words it hears could be any song.
58
Upvotes
14
u/jake_boxer Aug 25 '21
You’re right, it’s not just the words, it’s the whole waveform. To massively simplify: it’s matching that up against a database of waveforms and finding the closest match.
24
u/pygrkm Aug 25 '21
Once I watched this wonderful video on how the Shazam app works. Not only the video itself explains how Shazam works but also it provides required background if you are not familiar with 'sound'. When I first watched it, I was really impressed.
https://www.youtube.com/watch?v=kMNSAhsyiDg&ab_channel=RealEngineering
7
u/tekkub Aug 25 '21
It’s pretty simple really. The app listens for peaks, places where a given frequency is loudest. It gathers a bunch of those and then creates a fingerprint based on the frequencies of the peaks and the time between them. On the server they have a list of fingerprints for each song they’ve processed.
If your app finds enough fingerprints to make a reliable match, it can identify your song.
6
u/Justsumgi Aug 25 '21
Interestingly, Apple is coming out with ShazamKit - a framework for both iOS and Android to do Shazam-like audio recognition
https://developer.apple.com/shazamkit/
2
u/RustyMetal13 Aug 25 '21
Computerphile has a really great explanation on this topic. Check out, https://www.youtube.com/watch?v=RRsq9apr5QY