A four-minute song on CD takes up about 40 megabytes. Turn it into an MP3 and it's 4, sometimes less. To most ears, it sounds identical.
Where did the other 36 megabytes go?
Not into some clever repacking trick. They got deleted. MP3 compression works because it knows something about you: there's a huge amount of information in a sound wave that your ears physically cannot perceive. Find that information, and you can throw it away for free.
To find it, MP3 does four things in sequence: it turns the wave into numbers, rounds those numbers, breaks the wave into pure tones, and then uses a model of human hearing to figure out which of those tones nobody will notice are missing. We'll build all four, one at a time.
Turning a wave into numbers
Sound is a continuous wave of air pressure. Computers can't store continuous anything, they store numbers. So the first step is a flipbook: take a snapshot of the wave's height thousands of times per second, throw away everything in between, and hope the snapshots are close enough together that nobody notices the gaps.
How close is close enough? That depends on the highest pitch you're trying to capture. You need at least two snapshots per cycle of the wave, or the samples stop telling the truth. This is the Nyquist rule, and it's not a guideline, it's a hard mathematical wall.
We write the highest frequency you can safely capture at a given sample rate as:
Drop below that, and something strange happens. The samples don't just get blurry, they start describing a different, wrong tone entirely. This is called aliasing, and it's why old digital recordings sometimes have weird ghost pitches buried in them.
A 440 Hz tone, sampled at your chosen rate. Drag below the Nyquist limit and watch the dots imply a completely different, wrong tone.
Drag the sample rate down past 880 Hz (twice our 440 Hz tone) and watch the red curve appear, that's the fake, lower pitch the samples now imply. Your ears would hear that red curve, not the real gray one. CD audio samples at 44,100 Hz specifically because human hearing tops out around 20,000 Hz, and .
How precise does "loud" need to be?
Sampling answers when we measure. Now: how precisely do we record what we measure?
Picture a ruler with only a few tick marks on it. Every measurement gets rounded to the nearest tick, whether it lands exactly there or not. That's quantization, and the tick marks are set by bit depth: with bits per sample, you get evenly spaced levels to round to.
Fewer bits, fewer ticks, more rounding. That rounding isn't silent, it shows up as a faint hiss called quantization noise. Audio engineers measure how bad that hiss is with signal-to-noise ratio, and there's a clean formula for it:
Every extra bit buys you about 6 dB of cleaner signal. That's why CD audio uses 16 bits: dB, quiet enough that the rounding noise sits far below what you can hear.
Every loudness value gets rounded to the nearest allowed level. Fewer bits, fewer levels, more rounding noise.
Pull the slider down to 2 or 3 bits and watch the gold curve flatten into an ugly staircase, chasing the real wave but never quite matching it. That gap between the two curves is the noise the SNR number is measuring.
Every sound is a chord of pure tones
Here's the idea that makes the rest of MP3 possible: any sound, no matter how complex, is just a sum of simple sine waves added together. A trumpet, a voice, a slammed door, all of it decomposes into pure tones at different frequencies and volumes, like a chord made of very many notes.
This isn't a metaphor, it's an exact mathematical fact called a Fourier series. For a square wave specifically, it looks like this:
Add the first term alone and you get a soft sine wave, nothing like a square. Add the third harmonic and the corners start to sharpen. Keep going...
Every additional pure tone bends the sum closer to the sharp-cornered target. Any waveform is just a chord of sine waves.
Hit play and watch each new pure tone bend the gold curve closer to the sharp-edged square wave. That's Fourier synthesis: build any waveform out of enough sine waves, in the right proportions. MP3 runs this process in reverse. It takes your song and decomposes it into its frequency components, exactly like this, but for tens of thousands of tiny time windows per second.
Why does this matter for compression? Because once a sound is a list of frequencies and volumes instead of a wiggly line, you can finally ask the question that saves the most space: which of these frequencies can I get rid of?
The trick your ears fall for
Stand next to someone shouting and a whisper two feet away disappears completely, even though the whisper is still physically reaching your ears. Your hearing didn't fail. It got overwhelmed. Loud sounds raise the threshold of what you can perceive nearby, and anything quieter than that threshold might as well not exist.
This effect is called psychoacoustic masking, and it's the single idea that separates MP3 from a plain compressor. It doesn't just shrink numbers, it deletes entire tones that a loud neighbor has already drowned out.
The masking effect isn't symmetric, either. A loud tone masks quieter tones above it in pitch much more effectively than tones below it. Real ears are worse at hearing a quiet high note next to a loud low one than the reverse.
Turn up the loud tone at the center. Quiet neighbors that fall under the threshold curve go silent, MP3 throws them away for free.
Turn up the masker in the middle. Watch the dashed threshold curve rise around it, steeper on the low side, wider on the high side, and every quiet bar that dips below that line goes gray. Those grayed-out tones get discarded entirely before the file is even compressed further. Nobody hears the difference, because nobody could have heard them anyway.
MP3's psychoacoustic model runs this exact comparison across roughly 24 frequency bands, dozens of times per second, throughout the whole song.
Putting the pipeline together
Now the whole thing reads as one sequence. Sample the wave fast enough to satisfy Nyquist. Break each short window into its frequency components with a Fourier-family transform. Run the masking model across those components and zero out anything hiding beneath a louder neighbor. Quantize what's left, spending more bits on frequencies your ears are sensitive to and fewer on ones they're not. Finally, compress the surviving numbers losslessly with an entropy coder like Huffman coding, the same general idea used in ZIP files.
Every step so far has been "throw away what you can't hear." The very last step is the only purely lossless one, squeezing the numbers that survived.
The short version
MP3 doesn't compress sound the way a ZIP file compresses text. It deletes sound, deliberately and mathematically, using four ideas: sample fast enough to satisfy Nyquist, round amplitudes with just enough bits to stay quiet, decompose the wave into pure tones with Fourier synthesis, and use a model of human hearing to erase any tone a louder one is already masking. What's left over is what actually reaches your ears, packed as tightly as the math allows.
That 36 megabytes didn't get hidden somewhere clever. It was information you were never going to perceive in the first place.
All visualizations are interactive React components running entirely in your browser, computing sampling, quantization, Fourier synthesis, and a simplified masking model directly from the formulas above. No audio libraries, no external data, just the math. The Fourier animation uses requestAnimationFrame to step through harmonics in real time.