|
|
RIFF (Resource Interchange File Format) is basically the audio[^2] equivalent of a PNG - split your file into "chunks"[^1] that have a name, and give them a tiny header, and a data blob.
|
|
|
|
|
|
We're concerned with wave (`.wav`) files here, so for those you'll see:
|
|
|
|
|
|
- The file header of `RIFF` introducing a [`RIFF`](/chunks/RIFF) chunk
|
|
|
- The `WAVE` sub-chunk immediately after indicating this is a wave file
|
|
|
- A `fmt ` (note the space) chunk indication how the data is stored
|
|
|
- A `data` chunk with the actual sample data
|
|
|
|
|
|
Since I made this to deal with markers in BWF (Broadcast Wave Format) files, there's two others:
|
|
|
|
|
|
- After `WAVE` is `bext` (**b**roadcast **ext**ensions)
|
|
|
- After `data` is `cue ` and then a `LIST` of `adtl` chunks.
|
|
|
|
|
|
Each chunk, broadly, follows the pattern of a 4-byte (ASCII) chunk name / ID, followed by a 4 byte length (little-endian), not counting the header. Because of this, you can easily build an index of chunks in the file by reading the 4-byte ID, the 4-byte length, skipping that length, and repeating the process, storing the read ID with the byte offset it was at.
|
|
|
|
|
|
[^1]: I'm not kidding, both the PNG and (R)IFF spec call the individual, named data segments, "chunks."
|
|
|
|
|
|
[^2]: Video too I guess, since AVI files are based on RIFF. |
|
|
\ No newline at end of file |