The samples start at byte 1,024, straight after the header, and run to the end of the file. The format has no field for their number or their length:
BICSF’s macro for the size of the sound is sfbsize, the size of the file minus the size of the header (sfheader.7), and FFmpeg reads packets from byte
1,024 on.
Frames
A frame is one sample of every channel, so a frame is sf_chans × the bytes of a sample. The number of frames is the size of the file minus 1,024, divided by that, rounded
down; bytes that do not make a whole frame at the end of the file are not part of the sound (the viewer flags them). The duration is the number of frames divided by sf_srate.
How each packing mode stores a sample
sf_packmode | Bytes a sample | Value |
|---|---|---|
0x00001 | 1 | signed 8-bit integer |
0x00002 | 2 | signed 16-bit integer |
0x00003 | 3 | signed 24-bit integer (FFmpeg only) |
0x00004 | 4 | 32-bit IEEE float |
0x00008 | 8 | 64-bit IEEE float (FFmpeg only) |
0x10001 | 1 | A-law code, as in G.711 |
0x20001 | 1 | µ-law code, as in G.711 |
0x40004 | 4 | signed 32-bit integer |
The bytes of a sample are in the byte order of the magic number. The mapping of each mode to a sample type is FFmpeg’s
(ircam.c); libsndfile’s reader knows the modes 2, 4, 0x10001, 0x20001 and 0x40004 and gives them the same types.
What the viewer does with them
It plays every packing mode in the table. The waveform’s bytes map exactly to the file: clicking a sample selects its bytes, and the peak and RMS levels cover the whole sound.
Sources: BICSF sfheader.7 (sfbsize), IRCAM sfheader.h (the packing modes), FFmpeg ircam.c and ircamdec.c (the sample types of the modes), libsndfile ircam.c.