By Tania Alwan
Export a song from almost any audio tool and you get the same question: MP3 or WAV? The usual answer is "WAV is better quality, MP3 is smaller", which is true but not very useful. This post explains what is actually inside each file, how MP3 makes audio so much smaller, and ends with a short Python script that shows exactly where the missing data goes.
What a WAV file really is
WAV is a container format from Microsoft and IBM, built on the RIFF structure. In practice, almost every WAV you meet holds uncompressed PCM audio: a long list of sample values, one per channel, taken at a fixed rate.
The size is pure arithmetic:
- Sample rate × bit depth × channels = bits per second
- CD-quality stereo: 44,100 × 16 × 2 = 1,411,200 bits per second, about 1,411 kbps
- That is roughly 10 MB per minute of stereo audio
Nothing is thrown away, so a WAV can be edited, processed and re-saved as many times as you like without losing anything to the format itself. (WAV can technically hold compressed codecs too, but that is rare.)
How MP3 gets so much smaller
MP3 (MPEG-1 Audio Layer III) is a lossy perceptual codec. It does not try to keep the waveform identical. It tries to keep what a listener is likely to hear and spends as few bits as possible on the rest. Roughly:
- Split the signal into frequency bands using a filterbank followed by an MDCT (modified discrete cosine transform), frame by frame
- Run a psychoacoustic model that estimates which components are masked, for example a quiet tone right next to a much louder one in frequency, or sounds just after a loud transient
- Quantise each band coarsely or finely depending on how much noise the model thinks you will not notice there
- Entropy-code the result with Huffman coding, and use a "bit reservoir" to lend bits from easy frames to difficult ones
At low bitrates, many encoders also apply a low-pass filter and simply drop the highest frequencies, because spending bits on content above 15 to 16 kHz would starve the range where most of the music lives.
The Python example
The script below builds a bright test signal (a 220 Hz tone with harmonics plus a little broadband noise), saves it as 16-bit WAV and as a deliberately low-bitrate MP3, then decodes the MP3 and compares the energy in three frequency bands. It uses soundfile, which can write MP3 when it is built on libsndfile 1.1 or newer.
import os import numpy as np import soundfile as sf sr = 44100 t = np.arange(sr * 5) / sr rng = np.random.default_rng(0) # A bright test signal: a few harmonics plus quiet broadband "air" (noise) y = sum(0.2 / k * np.sin(2 * np.pi * 220 * k * t) for k in range(1, 20)) y += 0.02 * rng.standard_normal(len(t)) y = (y / np.max(np.abs(y)) * 0.8).astype(np.float32) sf.write("test.wav", y, sr, subtype="PCM_16") sf.write("test.mp3", y, sr, format="MP3", compression_level=0.9) # low bitrate on purpose decoded, _ = sf.read("test.mp3", dtype="float32") n = min(len(y), len(decoded)) def band_energy_db(x, lo, hi): spec = np.abs(np.fft.rfft(x[:n])) ** 2 freqs = np.fft.rfftfreq(n, 1 / sr) return 10 * np.log10(spec[(freqs >= lo) & (freqs < hi)].sum() + 1e-12) for name in ("test.wav", "test.mp3"): kb = os.path.getsize(name) / 1024 print(f"{name}: {kb:.0f} KB, about {kb * 8 * 1.024 / 5:.0f} kbps") for lo, hi in [(0, 4000), (4000, 12000), (12000, 22050)]: loss = band_energy_db(y, lo, hi) - band_energy_db(decoded, lo, hi) print(f"{lo:>5}-{hi:<5} Hz: {round(loss, 1) + 0.0:5.1f} dB lower after MP3") Output (tested with soundfile 0.14.0, libsndfile 1.2.2 and numpy 2.5.4):
test.wav: 431 KB, about 706 kbps test.mp3: 24 KB, about 40 kbps 0-4000 Hz: 0.0 dB lower after MP3 4000-12000 Hz: 1.3 dB lower after MP3 12000-22050 Hz: 63.7 dB lower after MP3 The WAV is mono 16-bit, so 706 kbps is exactly half the CD stereo figure. The MP3 is about 18 times smaller. Below 4 kHz, where the fundamental and strongest harmonics sit, the energy is essentially untouched. The top band is almost completely gone: at this bitrate the encoder low-passed the signal. Try compression_level=0.0 (highest quality) and run it again; the top band survives far better, and the file gets bigger.
Energy per band is a blunt measure. It does not show pre-echo, smeared transients or the "swirly" artefacts on cymbals and breathy vocals that appear at low bitrates. For that, compare spectrograms or, better, listen on good headphones.
Things that bite people in real projects
- Generation loss: every decode and re-encode to MP3 adds new quantisation errors. Editing an MP3 and saving it as MP3 again, several times, audibly degrades it. Keep a WAV master and export MP3 last.
- Encoder delay and padding: MP3 adds a short silence at the start and pads the end of the last frame. Most modern decoders compensate, but loops and back-to-back tracks can still get tiny gaps or offsets.
- Upconverting does nothing: turning an MP3 into a WAV makes the file bigger, not better. The missing data does not come back.
- Processing magnifies artefacts: pitch shifting, heavy EQ, stem separation and voice models all work on the details a lossy codec has already blurred.
So, MP3 or WAV?
- WAV (or another lossless format such as FLAC) for recording, editing, mixing, stems, anything you will process further, and your archive
- MP3 (or AAC/Opus) for previews, sharing, podcasts and anywhere bandwidth or storage matters. At high bitrates such as 256 to 320 kbps, many listeners struggle to tell it from the source in blind comparisons
- MP3 patents have expired, so licensing is no longer a reason to avoid it
The same logic applies to AI audio tools. If you plan to keep editing a result, pick the lossless option when one is offered. The Voicestars pricing table, for example, includes an "Output quality (MP3 or WAV)" row, and that choice matters more for a vocal you will mix than for a quick preview.
Takeaways
- WAV usually means uncompressed PCM: big, exact and safe to edit.
- MP3 uses a psychoacoustic model to hide quantisation noise where it is least audible, and drops high frequencies at low bitrates, as the demo shows.
- Work in lossless, deliver in lossy, and never re-encode lossy to lossy if you can avoid it.
Disclosure: this article was written in partnership with Voicestars.
