I had one hell of a time finding a clear document on how to write the header
I had one hell of a time finding a clear document on how to write the header
of a basic PCM wav file.  This is what i've found out mostly by reading docs
and a little by exploratory surgery.  If ever you find any of this to be 
incorrect, please let me know via email at tannoy@wep.net.


Basic structure of a simple PCM wav header.
struct{
charRiffTag[4]; // 'RIFF'
int32_tFileLength;
charFormatTag[8];// 'WAVEfmt '
int32_tFormatLength;// 16
int16_tDataFormat;
int16_tNumChannels;
int32_tSampleRate;
int32_tBytesPerSecond;
int16_tBlockAlignment;
int16_tSampleDepth;
charDataTag[3];// 'data'
int32_tDataLength;
} WavHeader;

FileLength:
The length of the rest of the file from this point;  It comes out to
being DataLength(bytes) + 32(rest of header).

DataFormat:
The format of the sample data; PCM audio is registered as 1 for this
paramater. You can pretty much just take it as granted unless you
are using weirdo sampleing.

NumChannels:
1 or 2; Obviously mono or stereo.  There can be more than 2
channels, but i cant see where that would be applied.

SampleRate:
Number of samples per second;

BytesPerSecond:
Number of bytes processed in one second; This is usefull for
buffersize estimation.
SampleRate * (SampleDepth / 8) * NumChannels;

BlockAlignment:
Number of bytes that must be read (or multiple of this) to correctly
write the sample data to the device.
(SampleDepth / 8) * NumChannels;

SampleDepth:
Number of bits per sample; Generally will be 8 or 16.

DataLength:
The length of the sampledata in bytes.
RecordTime(seconds) * (SampleDepth / 8) *
SampleRate * NumChannels