见TAUDIO的生成描述:
RecStream:=TFileStream.Create(FileName,fmCreate);
temp:='RIFF';RecStream.write(temp[1],length(temp));
temp:=#0#0#0#0;RecStream.write(temp[1],length(temp));
{ File size: to be updated }
temp:='WAVE';RecStream.write(temp[1],length(temp));
temp:='fmt ';RecStream.write(temp[1],length(temp));
temp:=#$10#0#0#0;RecStream.write(temp[1],length(temp));
{ Fixed }
temp:=#1#0;RecStream.write(temp[1],length(temp));
{ PCM format }
if FChannels=Mono then
temp:=#1#0
else
temp:=#2#0;
RecStream.write(temp[1],length(temp));
RecStream.write(FSPS,2);
temp:=#0#0;RecStream.write(temp[1],length(temp));
{ SampleRate is given is dWord }
{$IFDEF WIN32}
with pWaveFmt^do
begin
{$else
}
with pWaveFmt^.wfdo
begin
{$ENDIF}
RecStream.write(nAvgBytesPerSec,4);
RecStream.write(nBlockAlign,2);
end;
RecStream.write(pWaveFmt^.wBitsPerSample,2);
temp:='data';RecStream.write(temp[1],length(temp));
temp:=#0#0#0#0;RecStream.write(temp[1],length(temp));
{ Data size: to be updated }
if (LP<>nil) then
begin
LP.Position:=0;
if (RP<>nil) and (RP.Size=LP.Size) then
begin
RP.Position:=0;
GetMem(T1,1000);
T2:=T1;
if FBPS=_8 then
begin
for i:=1 to LP.Sizedo
begin
LP.Read(T2^,1);inc(T2,1);
RP.Read(T2^,1);
inc(T2,1);
if (i mod 500)=0 then
begin
RecStream.Write(T1^,1000);
T2:=T1;
end;
end;
i:=LP.Size mod 500;
if i>0 then
begin
RecStream.Write(T1^,i*2);
end;
end else
begin
for i:=1 to (LP.Size div 2)do
begin
LP.Read(T2^,2);inc(T2,2);
RP.Read(T2^,2);
inc(T2,2);
if (i mod 250)=0 then
begin
RecStream.Write(T1^,1000);
T2:=T1;
end;
end;
i:=(LP.Size div 2) mod 250;
if i>0 then
begin
RecStream.Write(T1^,i*2);
end;
end;
FreeMem(T1,1000);
end else
RecStream.CopyFrom(LP,LP.Size);
{
if (LP<>nil) then
begin
LP.Position:=0;
if (RP<>nil) and (RP.Size=LP.Size) then
begin
RP.Position:=0;
if FBPS=_8 then
begin
for i:=1 to LP.Sizedo
begin
RecStream.CopyFrom(LP,1);
RecStream.CopyFrom(RP,1);
end;
end else
begin
for i:=1 to (LP.Size div 2)do
begin
RecStream.CopyFrom(LP,2);
RecStream.CopyFrom(RP,2);
end;
end;
end else
RecStream.CopyFrom(LP,LP.Size);
}
i:=RecStream.Size-8;
{ size of file }
RecStream.Position:=4;
RecStream.write(i,4);
i:=i-$24;
{ size of data }
RecStream.Position:=40;
RecStream.write(i,4);
RecStream.Free;