WAVE Sound File Information
M. Gallant 1/9/97
The following is a brief description of the WAVE RIFF File Format used
for sound files on PCs. The information might be useful for examining wave sound
file headers which have problems. The image below shows a binary
dump (using the MS-DOS debug utility) of part of a wave file
(the Windows 3.1 Chord.wav system-event file) with annotation. Each sample of the
sound in the data section is one byte long and the zero of sound level is at the
"mid-point" of the byte, i.e. level 080h for unsigned 8 bit data. Notice that the total
length of the wave sound-file header is 44 (decimal) bytes for this file. However,
wave headers can be longer with more chunks (like "fact" etc.). A simple comparison
of
Win3.1 and Win95 wave files demonstrates this. Below,the file size of Chord.wav as reported in DOS is 24,982 bytes. The "bytes remaining in file" below is 618Eh
or 24,974 which is offset 8 bytes from the start of file.
|
Internet Reference Documentation |
|
Creative Labs
provides documentation and examples for programming their SB16/32 series
of sound cards. One of their examples (dmaw.exe) written in C describes the .wav header as
shown below. This demo program fails to read wave files with slightly more detailed
(but still valid according to the wav spec) headers!
struct WAVEHDR{
char format[4]; // RIFF
unsigned long f_len; // filelength
char wave_fmt[8]; // WAVEfmt_
unsigned long fmt_len; // format lenght
unsigned short fmt_tag; // format Tag
unsigned short channel; // Mono/Stereo
unsigned long samples_per_sec;
unsigned long avg_bytes_per_sec;
unsigned short blk_align;
unsigned short bits_per_sample;
char data[4]; // data
unsigned long data_len; // data size
} wavehdr;
Go Home ET