Ktoś może podpowiedzieć jak zapisać najprostszy WAV monofoniczny w którym byłby jakiś prosty dźwięk np. 440Hz
Znalazłem opis jak zapisać prosty plik WAV
http://www.topherlee.com/software/pcm-tut-wavformat.html
The header of a WAV (RIFF) file is 44 bytes long and has the following format:
Positions Sample Value Description
1 - 4 "RIFF" Marks the file as a riff file. Characters are each 1 byte long.
5 - 8 File size (integer) Size of the overall file - 8 bytes, in bytes (32-bit integer). Typically, you'd fill this in after creation.
9 -12 "WAVE" File Type Header. For our purposes, it always equals "WAVE".
13-16 "fmt " Format chunk marker. Includes trailing null
17-20 16 Length of format data as listed above
21-22 1 Type of format (1 is PCM) - 2 byte integer
23-24 2 Number of Channels - 2 byte integer
25-28 44100 Sample Rate - 32 byte integer. Common values are 44100 (CD), 48000 (DAT). Sample Rate = Number of Samples per second, or Hertz.
29-32 176400 (Sample Rate * BitsPerSample * Channels) / 8.
33-34 4 (BitsPerSample * Channels) / 8.1 - 8 bit mono2 - 8 bit stereo/16 bit mono4 - 16 bit stereo
35-36 16 Bits per sample
37-40 "data" "data" chunk header. Marks the beginning of the data section.
41-44 File size (data) Size of the data section.
Sample values are given above for a 16-bit stereo source.
I moj kawałę kodu który powinien zapisac plik WAV tylko niczym nie mozna go otworzyć :(
procedure TForm68.Button1Click(Sender: TObject);
const
FILE_SIZE = 1024*64;
var
s: ansistring;
buf: TMemoryStream;
i: Integer;
w: Word;
si:SmallInt;
begin
buf:= TMemoryStream.Create;
s := 'RIFF';
buf.Write(s[1],4);
i := FILE_SIZE-8;
buf.Write(i,4);
s := 'WAVE';
buf.Write(s[1],4);
s := 'fmt'#0;
buf.Write(s[1],4);
i := 16;
buf.Write(i,4);
w := 1;
buf.Write(w,2);
w := 2;
buf.Write(w,2);
i := 44100;
buf.Write(i,4);
i := 176400;
buf.Write(i,4);
w := 4;
buf.Write(w,2);
w := 16;
buf.Write(w,2);
s := 'data';
buf.Write(s[1],4);
i := FILE_SIZE-44;
buf.Write(i,4);
while buf.Size <= FILE_SIZE do
begin
si := Random(32000)-16000; //random data !!!
buf.Write(si,2);
end;
buf.SaveToFile('1.wav');
buf.Free;
end;