Transcription
Hey, how does Shazam know what song I'm listening to? It doesn't. It's just math.
What? How is that possible?
First, your phone records the raw audio data, which essentially is just a bunch of air pressure fluctuations sampled thousands of times per second. And then it is stored as numbers. Then it runs the fast Fourier transform on that whole waveform, also known as an FFT. It essentially breaks down the whole signal into its component frequencies. That gives you frequency over time data. Essentially, you know these frequencies were present at this intensity at this time slice. Plot that frequency data with time on one axis and frequency data on the other axis. And that gives you a spectrogram. Essentially, a visual map where brightness indicates how intense a frequency is at any moment.
But then how does that frequency data turn into a song?
It only keeps the spectral peaks, which are the loudest points that stand out. Those peaks get plotted as dots, which are called a constellation map, which is unique to every single song. The constellation map essentially becomes an acoustic footprint of the song. Your phone sends the constellation map to Shazam's server, where it's used to query millions of songs to find a match. It's not comparing sounds per se, it's comparing mathematical footprints that land at the same coordinates.