Y
yerly
Unregistered / Unconfirmed
GUEST, unregistred user!
我使用了delphix2000中的TDXsound控件。代码如下,可是保存出来的文件不是正确wav文件,请高手赐教!
procedure TForm1.btn_RecordClick(Sender: TObject);
begin
if Capture = nil then
Capture := TSoundCaptureStream.Create(DXSound1.Driver);
Capture.SetPCMFormat(8000, 8, 1);
Capture.OnFilledBuffer := onFilled;
Capture.Start;
end;
procedure TForm1.onFilled(Sender: TObject);
var
sm:TMemoryStream;
begin
if Capture <> nil then
begin
sm :=TMemoryStream.Create;
try
Capture.Position := 0;
sm.CopyFrom(Capture,Capture.BufferLength);
sm.SaveToFile('1.wav');
Capture.Position := 0;
finally
sm.Free;
end;
end;
end;
procedure TForm1.btn_RecordClick(Sender: TObject);
begin
if Capture = nil then
Capture := TSoundCaptureStream.Create(DXSound1.Driver);
Capture.SetPCMFormat(8000, 8, 1);
Capture.OnFilledBuffer := onFilled;
Capture.Start;
end;
procedure TForm1.onFilled(Sender: TObject);
var
sm:TMemoryStream;
begin
if Capture <> nil then
begin
sm :=TMemoryStream.Create;
try
Capture.Position := 0;
sm.CopyFrom(Capture,Capture.BufferLength);
sm.SaveToFile('1.wav');
Capture.Position := 0;
finally
sm.Free;
end;
end;
end;