PCM Drop logoPCM Drop

PCM vs WAV: What's Actually Different?

·7 min read

"Should I use PCM or WAV?" is a slightly confused question, and the confusion is understandable. A typical WAV file is PCM audio. The samples inside a standard WAV file are byte-for-byte the same as the samples in a raw .pcm file recorded with the same settings. What WAV adds is a short header at the start that describes those samples. That header is the reason a WAV file opens with a double-click and a .pcm file does not.

This article looks at what is in that header, when you would want audio without one, and how to convert in both directions.

PCM Is an Encoding, WAV Is a Container

PCM (pulse-code modulation) describes how sound is turned into numbers: measure the waveform at regular intervals and store each measurement as an integer or float. It says nothing about how those numbers are stored in a file.

WAV is a file format. It is a RIFF container defined by Microsoft and IBM in 1991 that can hold several kinds of audio data. In practice, the overwhelming majority of WAV files contain uncompressed PCM. WAV files can also hold other encodings, such as µ-law, A-law and ADPCM, but those are uncommon outside telephony and old games.

So the honest comparison is "raw PCM samples" against "the same PCM samples plus a description". The audio quality is identical. Neither is better-sounding than the other.

What Is Inside a WAV Header

A minimal WAV file starts with a 44-byte header. Every number in it is stored little-endian:

BytesFieldExample (16 kHz, 16-bit, mono)
0–3"RIFF" markerRIFF
4–7File size minus 8depends on length
8–11"WAVE" markerWAVE
12–15"fmt " chunk markerfmt
16–19fmt chunk size16
20–21Audio format (1 = integer PCM, 3 = float)1
22–23Number of channels1
24–27Sample rate16000
28–31Byte rate (rate × channels × bytes per sample)32000
32–33Block align (channels × bytes per sample)2
34–35Bits per sample16
36–39"data" chunk markerdata
40–43Size of the audio data in bytesdepends on length

After byte 43 comes the audio, laid out exactly as it would be in a raw PCM file. The header holds the same three facts you have to type in by hand when you open a .pcm file: sample rate, bit depth and channel count. That is the whole difference.

One caveat: 44 bytes is the minimum, not a guarantee. Many WAV files have extra chunks, such as LIST (metadata), bext (broadcast information) or fact. Files with more than two channels or more than 16 bits often use the longer WAVE_FORMAT_EXTENSIBLE layout. Well-written software finds the audio by looking for the "data" chunk rather than assuming it starts at byte 44.

Why Anyone Uses Headerless PCM

If a header costs only 44 bytes and makes files easy to open, why do raw .pcm files exist at all? There are several good reasons:

  • Streaming has no natural end. A WAV header has to state the total data size, and you do not know that until the recording stops. Devices that write audio continuously, such as voice assistants, intercoms and data loggers, find it simpler to write bare samples.
  • Embedded firmware is kept small. On a microcontroller reading an I²S microphone, copying the DMA buffer straight to flash or a socket is the simplest possible code.
  • Many APIs produce raw samples. Android's AudioRecord, the Web Audio API's AudioWorklet, most speech-to-text streaming endpoints and many telephony platforms all produce or accept headerless PCM, because the format is agreed out of band.
  • Concatenating files is trivial. Raw PCM files with the same settings can be joined with cat a.pcm b.pcm > ab.pcm. Joining WAV files that way leaves a header in the middle of the audio, which is heard as a click.

The price is that the format information lives somewhere else, in documentation, a config file or someone's memory. Once that is lost, you have to work the settings out by ear. Our guide to fixing raw audio that sounds wrong covers how.

Converting Raw PCM to WAV

Adding a header is lossless. The samples are not touched. Any of these methods works:

In the browser: open the file in the PCM Drop player, find the settings that sound right, choose WAV as the output format and download. Nothing is uploaded.

With FFmpeg, tell it how to read the input and it writes the header for you:

ffmpeg -f s16le -ar 16000 -ac 1 -i input.pcm output.wav

With SoX:

sox -t raw -r 16000 -e signed -b 16 -c 1 input.pcm output.wav

In Python, the standard library's wave module writes a correct header:

import wave

with open("input.pcm", "rb") as f:
    samples = f.read()

with wave.open("output.wav", "wb") as w:
    w.setnchannels(1)
    w.setsampwidth(2)       # bytes per sample: 2 = 16-bit
    w.setframerate(16000)
    w.writeframes(samples)

Converting WAV Back to Raw PCM

Going the other way is usually just as simple. If you know the file has a plain 44-byte header, you can drop it with tail -c +45 input.wav > output.pcm. That only works on minimal WAV files, though, so FFmpeg is the safer choice because it finds the data chunk properly:

ffmpeg -i input.wav -f s16le -acodec pcm_s16le output.pcm

Add -ar 16000 -ac 1 if the system you are feeding also needs a particular sample rate or channel count. This is common with speech recognition APIs, which often expect 16 kHz mono.

Which One Should You Keep?

For anything a person will open later, keep WAV. The header costs nothing and saves the next person from guessing. WAV does have one structural limit: its size fields are 32-bit, so a single file cannot exceed 4 GB. That is about 6 hours 45 minutes of 44.1 kHz 16-bit stereo. For longer recordings, use RF64 or Wave64, which most professional tools support.

Use raw PCM where it is the natural format of the pipeline: device firmware, streaming protocols, API payloads and intermediate files that only your own code reads. When you do, store the settings next to the audio, even as a one-line text file. If you need to share a raw capture with someone, convert it to WAV first.

Summary

PCM and WAV are not competing formats. PCM is the audio itself, and WAV is PCM with a label attached. Converting between them is lossless in both directions, and the only information involved is the sample rate, bit depth and channel count. If you have a raw file and know those three values, it takes a few seconds to turn it into a WAV that opens anywhere.