So yesterday, I mentioned that a WAV file is just a wrapper around raw PCM data. Well, that’s not entirely accurate (it’s not inaccurate either, but…)
A WAV file is in fact a RIFF file, that contains waveform (discrete PCM audio samples) content. RIFF (Resource Interchange File Format) is the file format that Microsoft historically has used to encode much of its multimedia content (WAV, AVI, etc). The RIFF format describes “chunks” of data, which can be strung together to make a single multimedia title.
Windows provides APIs for manipulating RIFF files, they’re the “mmio” family of APIs exported from winmm.dll. There are APIs for opening, reading and writing to RIFF files, and for parsing the various chunks of data in the file (each chunk can in turn contain multiple chunks).
A WAV file is a RIFF file that contains two chunks. The first chunk is named “fmt”, and the other is named “data”.
The “fmt” chunk contains a WAVEFORMAT which describes the format of the data contained in the “data” chunk.
The “data” chunk contains the PCM data for the audio sample.
There’s actually a partial example of parsing a RIFF file on MSDN, which shows how to navigate through a RIFF file.
If you’re not interested in using the mmio APIs to write (or parse) RIFF files, then I discovered this page at Stanford that describes the format of a WAVE file as a flat file.