presentations/audiocodecs/slides/04-2-wavformat.md

2 KiB

WAV/RIFF Header Format
FileTypeBlocID
4 bytes


FileSize
4 bytes


FileFormatID
4 bytes


FormatBlocID
4 bytes


BlocSize
4 bytes


AudioFormat
2 bytes
NbrChannels
2 bytes
Frequence
4 bytes


BytePerSec
4 bytes


BytePerBloc
2 bytes
BitsPerSample
2 bytes
WAV Data Chunk Format
DataBlocID
4 bytes


DataSize
4 bytes


SampledData
2-3 bytes typically


Note: So easy in fact that I can just show you the entire format.

[Master RIFF chunk]
   FileTypeBlocID  (4 bytes) : Identifier « RIFF »  (0x52, 0x49, 0x46, 0x46)
   FileSize        (4 bytes) : Overall file size minus 8 bytes
   FileFormatID    (4 bytes) : Format = « WAVE »  (0x57, 0x41, 0x56, 0x45)

[Chunk describing the data format]
   FormatBlocID    (4 bytes) : Identifier « fmt␣ »  (0x66, 0x6D, 0x74, 0x20)
   BlocSize        (4 bytes) : Chunk size minus 8 bytes, which is 16 bytes here  (0x10)
   AudioFormat     (2 bytes) : Audio format (1: PCM integer, 3: IEEE 754 float)
   NbrChannels     (2 bytes) : Number of channels
   Frequence       (4 bytes) : Sample rate (in hertz)
   BytePerSec      (4 bytes) : Number of bytes to read per second (Frequence * BytePerBloc).
   BytePerBloc     (2 bytes) : Number of bytes per block (NbrChannels * BitsPerSample / 8).
   BitsPerSample   (2 bytes) : Number of bits per sample

[Chunk containing the sampled data]
   DataBlocID      (4 bytes) : Identifier « data »  (0x64, 0x61, 0x74, 0x61)
   DataSize        (4 bytes) : SampledData size
   SampledData

[comment]: # (!!!)