ts/Tanmay’s place
Writing · November 27, 2026

What can you see in a song?

A friend of mine wrote his 12th grade IB paper on Fourier transforms and music. It came up when we were talking the other day, and I realized I remembered the name and almost nothing else. So I went back to figure out the part I actually cared about.

When two notes play at the same time, a microphone doesn't get two separate sounds. It gets one. The recording is a single line wiggling up and down, and yet when I play it back I can still hear both notes. If everything gets mixed into one line, how would a computer find the notes again?

What the microphone gets

Sound starts with something moving back and forth. A speaker has a cone that pushes the air in front of it and pulls it back, over and over, and those pushes travel out to your ear. How many times a second the cone repeats is the pitch. The first note here repeats 220 times a second, written as 220 Hz, which is the A below middle C.

One note moves the speaker

Drag through time, slowed way down. The speaker cone pushes the air and pulls it back, and the line on the right traces where the cone is.

The push travels through the airCone
Where the cone isEarlierTimeLater
Silent and slowed down. A real note moves the cone hundreds of times a second.

The cone is pushed out, squeezing the air in front of it.

Now play a second note on the same speaker, one that repeats 330 times a second. The cone can't be in two places at once, so at every instant it goes wherever the two notes add up to. Sometimes both notes push the same way and the cone moves further. Sometimes they push opposite ways and mostly cancel. What comes out is one new, lumpier line, and that's the only thing the microphone ever hears.

Two notes, one speaker

The speaker can only be in one place at a time, so the two notes get added together. Try the two moments, or drag through time.

The lower note pushes this farThe higher note adds thisWhere the speaker ends upResting position
Lower noteHigher noteBoth togetherEarlierTimeLater

Both notes push the same way here, so the speaker moves further.

A digital recording doesn't even keep the whole line. It saves where the line is at regular moments, thousands of times a second (a CD saves 44,100 readings every second). Each reading is just a number, and nothing in that number says which part belongs to which note. Any single reading could have come from almost any mix of notes, so if the notes can be found at all, it has to be from the pattern across lots of readings.

What the recording saves

Drag to pick a reading. On the left are the few readings around it, each one just a number for how far the speaker was from rest.

Saved readings, one after anotherEarlierEarlierThis readingLaterLaterEach bar is how far the speaker was from rest
Each dot is a saved readingEarlierTimeLater

This reading is 0.94. On its own it says nothing about which notes are playing.

How to check for one note

The trick is to stop asking “which notes are in here?” and ask a smaller question: “is this one particular note in here?” To answer it, make a clean copy of the note you're looking for and hold it up against the recording, one reading at a time.

At each instant, multiply the two together. If the recording and the clean copy are on the same side of the middle, both above or both below, the result is positive. If they're on opposite sides, it's negative. So every instant casts a small vote for or against “these two line up.”

Checking one instant

Drag through the first few thousandths of a second. The top line is the recording of both notes. The bottom line is a clean copy of the lower note.

The recordingAbove the middle
The note I'm checking forAbove the middle
1.75 ms

Both are on the same side of the middle, so this instant adds to the score.0.210 × 0.661 = 0.139

One instant doesn't prove much, because a note that isn't there will still line up by accident some of the time. So you keep a running score across the whole clip. If the note really is in the recording, the recording keeps lining up with the clean copy, the votes for it keep winning and the score climbs. If it isn't, the accidental agreements and disagreements even out and the score ends right back at zero.

Keeping score over the whole clip

Pick a pitch to check for. Each bar is one instant: gold adds to the score and purple takes away. The line below is the score so far.

Each instantAdds Takes away
The score so far
Zero
Start of the clipEnd
All of it

The score ends above zero, so the lower note is in the recording. How high it ends tells you how loud it is.

See the numbers

The clip is 400 readings long. The raw total is 120.000. Multiplying by 2 and dividing by 400 turns it into the note’s loudness on the same scale as the recording, 0.600.

That's honestly the whole idea. How high the score ends up tells you how loud that note is in the recording, and a score of zero means it isn't there.

Checking every pitch

Now run that check for every pitch instead of just one. Line up the scores from low pitches to high ones and you get a picture with a peak wherever a note is hiding. That picture is called a spectrum, and working it out is what a Fourier transform does.

Checking every pitch

Left is the one line the speaker plays. Right is what you get by running the check at every pitch: a peak wherever a note is hiding. Pick a pitch and hear what the check finds there.

What the speaker playsBoth notes, added into one line
EarlierLater →
What the check findsEach peak is a note. Taller means louder.
Lower noteHigher note
Lower pitchHigher pitch →

Found the lower note.Press Hear what it found to listen to just this part.

See the numbers

The check at 220 Hz scores 0.60. The lower note was mixed in at 0.60 and the higher note at 0.40, and the check gets both back exactly. The pitch in between scores 0.00. These two notes were chosen to fit a whole number of repeats in the clip, which is why the cancellation is perfect here. Sine score 0.60, cosine score 0.00.

There's one catch I skipped. A note can start a little later than the clean copy, the way you can clap at the right speed but slightly behind the beat. When that happens the two seem to disagree even though they're the same pitch. So the real version checks each pitch twice, with two clean copies that start a quarter of a repeat apart, and combines the two scores. Between them they catch the note no matter when it started. Computers do all of this with something called the FFT, short for fast Fourier transform, which gets the same answer with far less arithmetic.

Real sounds are messier than my two notes. I picked these so each one fits a whole number of repeats into the clip, which is why the wrong pitch cancels to exactly zero. In a real recording a note usually lands between the pitches being checked and smears into a few of its neighbors. A single instrument isn't one pitch either. A piano and a voice can hit the same note and still sound different, because each one stacks its own mix of higher pitches on top.

The spectrum turns out to be useful for a lot more than this. A steady whistle in a recording shows up as one thin peak that stays put while the music changes around it, so you can turn down just that sliver of pitch and leave the rest alone. Shazam works from the same kind of picture. It picks out the loudest peaks over time and matches their pattern against its library of songs.

The formula, and where the integral comes in

Take four evenly spaced readings of a note. Say the recording reads 0, 0.6, 0, −0.6 and the clean copy reads 0, 1, 0, −1. Multiplying each pair gives 0, 0.6, 0, 0.6. Two readings below the middle agree just as much as two above it, so they count as a vote for.

The total is 1.2. The clean copy checked against itself totals 2, so dividing by 2 gives the note's original strength, 0.6. The check for the lower note in the figures does the same thing with 400 readings. Its total is 120, the clean copy against itself is 200, and that's where 0.6 comes from.

The written version is X(f) = ∫ x(t) e−i2πft dt. Here x(t) is the recording at time t and f is the pitch being checked. The e part packs both clean copies, the one that starts on time and the one a quarter of a repeat later, into a single expression, and the i keeps their two scores separate. The ∫ is an integral. It's what adding up the votes becomes when the readings are infinitely close together: instead of adding a list of numbers, you measure the area under the curve of votes, with anything below the middle counting against.

What about a whole song?

A spectrum of a whole song tells you which pitches show up somewhere in it, but not when. To get the when, take a short slice of the recording, about a twentieth of a second, run the check on just that slice, then slide over a little and do it again. Put those slices side by side and you get a spectrogram, where time runs left to right, pitch goes up and brighter means louder.

Reading a spectrogram

A made-up loop: a bass note, then a hi-hat comes in. Play it, then mute the hi-hat and play it again.

0:00.00:04.0
At the line

The bass holds one low pitch, so it draws one steady line along the bottom.

How this picture is made

The loudest pitch at the line is about 125 Hz.

Each column is the check from earlier, run on about 0.05 seconds of sound (2,048 readings, with the edges faded so the cut doesn’t add a click). The picture covers 62.5 Hz to 8,000 Hz, spaced so each step up is the same musical interval. Brightness is on a decibel scale, which matches how loudness sounds better than raw numbers do. A single instrument usually shows up as several lines, because one note contains a few pitches stacked on top of each other.

A held note like the bass draws flat lines, because it's the same pitch the whole time. There are two here because even one bass note has a quieter, higher pitch stacked on top of it, the same stacking that makes a piano sound different from a voice. A hi-hat is the opposite. Each tick is very short and has a big spread of high pitches all at once, so it draws a tall, thin streak.

How long to make each slice is a real choice. A short slice shows exactly when a tick lands but blurs together pitches that are close. A long slice pulls close pitches apart but smears quick sounds across time. You can't have both at once, so the right slice depends on what you're looking for.

Street Lights is one of my favorite songs, so I wanted to try this on something I actually listen to. Here are its first ten seconds.

The opening of Street Lights

The first ten seconds of the song, drawn the same way. Drag the white line and hear the second around it.

I can't read this like sheet music, but I can line it up with what I hear. Find a spot where something new comes in and listen to the second around it. Does it hold steady like the bass, or flicker like the hi-hat?

Sources

Tanmay’s place

Your memory card

Six souvenirs are hidden around the site. You’ll find them by looking around.

0 / 6 souvenirs collected

Find all six for a small surprise back at home.

Save it or share it. It’s made in your browser, and nothing gets uploaded.

Your card stays in this browser. No account needed. Clearing browser data clears your card.