A raw file does not say how many channels it has. The explorer’s Channels option takes any of 1 to 8, 10, 12, 16, 24 or 32, and the Layout option says how they share the bytes. The channels are shown in the order of the file, as channel 1, 2 and so on; nothing in a headerless file says which is left, right or centre. (WAVE’s own channel masks, which do, are on the WAV pages.)
Three layouts
Take two channels, L and R, of four samples each (L0 to L3, R0 to R3):
| Layout | Order of the samples in the file | Used by |
|---|---|---|
| Interleaved | L0 R0 L1 R1 L2 R2 L3 R3 | WAVE, AIFF, AU, CD audio, nearly every raw file; ffmpeg -f s16le |
| Planar | L0 L1 L2 L3 R0 R1 R2 R3 | decoders that keep each channel in an array (the p sample formats of FFmpeg, such as s16p and fltp) and some programs’ dumps of memory |
| Blocked (runs of 2 samples) | L0 L1 R0 R1 L2 L3 R2 R3 | runs of a fixed size in bytes: DSD in DSF files, in runs of the header’s block size per channel |
Reading the wrong channel count shows in both the length and the pitch: a stereo file read as mono has twice as many frames, so it lasts twice as long and sounds an octave lower (and when the two channels differ, with a rough, doubled edge on the waveform from the other channel’s samples); a mono file read as stereo lasts half as long and sounds an octave higher. Interleaved data read as planar, or the reverse, mixes the channels’ samples wrongly: the waveform is rough where the channels differ, and the spectrogram smears. Try the three layouts and keep the one whose waveform is smoothest; the identification page says how.
Frames and what is left over
With C channels of b bits a frame is C × b bits. The number of frames in N bytes is the whole number of times that fits; the rest is shown as “Bytes left over”. In the planar layout the channels are runs of equal length, so the frames are what fits in every run; in the blocked layout every full round of a run from each channel counts, and an incomplete last round is left over. A file whose size is not a multiple of the frame size is the commonest sign of a wrong guess (or of a header or trailer that has not been skipped).
| Bytes | Reading | Frames | Left over |
|---|---|---|---|
| 4,003 | 16-bit stereo | 1,000 | 3 |
| 1,000 | IMA ADPCM, mono, 256-byte blocks (505 samples a block) | 1,515 (3 blocks) | 232 |
Skip and Length
Raw audio is often a container’s data with the header still on the front. Skip says how many bytes at the start are not samples; Length says how many bytes to read from
there, so a trailer after the data is left out. Both appear in the tree as
Skipped bytes and Bytes not read. Some common header sizes: a canonical WAVE file
has a 44-byte header (12 for RIFF, 24 for the fmt chunk of a PCM file, 8 for
the data chunk header), and a Sun AU file’s header is at least 24 bytes (its data offset says
where the samples start). If the file starts with a header the explorer knows (RIFF, FORM,
.snd, caff, fLaC, OggS, an ID3 tag and a few others) it says so and links to
the format’s own pages: open the file by that format instead. Skipping a header
that is not a whole number of frames long shifts every sample by a fraction of a
frame: channels swap places and, for 16-bit data, odd skips swap the bytes of every sample.
Interleaving of packed samples
With samples narrower than a byte, interleaving is by sample, not by byte: in 4-bit stereo the high nibble of a byte is the left sample and the low nibble the right (big-endian) or the reverse (little-endian). Blocked and planar runs, by contrast, are whole bytes.