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.
Channel order of 4 to 8 channels
The bytes cannot say which channel is which. FFmpeg gives a raw input of N channels a default layout
(checked on FFmpeg 8 with ffmpeg -f s16le -ac N -i …, which names the layout it chose), and every one of them lists
its channels in the order of the bits of the WAVE channel mask (the bit values are those of the SPEAKER_* constants in the
Windows ksmedia.h header, as copied by the mingw-w64 and Wine projects: FL 0x1, FR 0x2, FC 0x4, LFE 0x8, BL 0x10, BR 0x20,
BC 0x100, SL 0x200, SR 0x400; all seven layouts below were checked against them and each lists its channels in rising bit order):
| Channels | FFmpeg’s default layout | Order in each frame |
|---|---|---|
| 3 | 2.1 | FL FR LFE |
| 4 | 4.0 | FL FR FC BC (the quad layout, FL FR BL BR, has to be asked for) |
| 5 | 5.0 | FL FR FC BL BR |
| 6 | 5.1 | FL FR FC LFE BL BR (5.1(side) has SL SR in the last two places) |
| 7 | 6.1 | FL FR FC LFE BC SL SR |
| 8 | 7.1 | FL FR FC LFE BL BR SL SR |
FL front left, FR front right, FC front centre, LFE low-frequency effects, BL and BR back left and right, SL and SR side left and right, BC back centre. Other sources order them differently: AC-3, AAC and DTS decoders often deliver the centre first, and the DVD and Blu-ray LPCM payloads are re-ordered as described under LPCM. The explorer shows FFmpeg’s default order in its Channels row as a reference and never reorders anything: a file in another order shows its channels in file order. SoX and Audacity were not available to check how they name or order the channels of a raw import.
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.