Examples Delphi

This article shows the format of a WAV file.
TWaveHeader = record
Marker1: Array[0..3] of Char;
BytesFollowing: LongInt;
Marker2: Array[0..3] of Char;
Marker3: Array[0..3] of Char;
Fixed1: LongInt;
FormatTag: Word;
Channels: Word;
SampleRate: LongInt;
BytesPerSecond: LongInt;
BytesPerSample: Word;
BitsPerSample: Word;
Marker4: Array[0..3] of Char;
DataBytes: LongInt;
end;
To create your own WAV:
DataBytes := Channels;
DataBytes := DataBytes * SampleRate;
DataBytes := DataBytes * Resolution;
DataBytes := DataBytes div 8;
DataBytes := DataBytes * Duration;
DataBytes := DataBytes div 1000;
WaveHeader.Marker1 := 'RIFF';
WaveHeader.BytesFollowing := DataBytes + 36;
WaveHeader.Marker2 := 'WAVE';
WaveHeader.Marker3 := 'fmt ';
WaveHeader.Fixed1 := 16;
WaveHeader.FormatTag := 1;
WaveHeader.SampleRate := SampleRate;
WaveHeader.Channels := Channels;
WaveHeader.BytesPerSecond := Channels;
WaveHeader.BytesPerSecond := WaveHeader.BytesPerSecond * SampleRate;
WaveHeader.BytesPerSecond := WaveHeader.BytesPerSecond * Resolution;
WaveHeader.BytesPerSecond := WaveHeader.BytesPerSecond div 8;
WaveHeader.BytesPerSample := Channels * Resolution div 8;
WaveHeader.BitsPerSample := Resolution;
WaveHeader.Marker4 := 'data';
WaveHeader.DataBytes := DataBytes;