我在wav录音时,有时会录不到音,产生一个~temp的临时文件,请问产生这个问题的原因
及解决方法。录音文件原码
unit RecordWave;interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, MPlayer;type
TWavHeader = record //定义一个Wav文件头格式
rId : longint;
rLen : longint;
wId : longint;
fId : longint;
fLen : longint;
wFormatTag : word;
nChannels : word;
nSamplesPerSec : longint;
nAvgBytesPerSec : longint;
nBlockAlign : word;
wBitsPerSample : word;
dId : longint;
wSampleLength : longint;
end;
Function CreateWave(channels : word; resolution : word; rate : longint; fn : string):boolean ;//自定义写一个Wav文件头过程implementation
function CreateWave( channels : word; { 1(单声)或者2(立体声) }
            resolution : word; { 8或者16,代表8位或16位声音 }
            rate : longint; { 声音频率,如11025,22050, 44100}
            fn : string { 对应的文件名称 } ):boolean ;
var
      wf : file of TWavHeader;
      wh : TWavHeader;
begin
      wh.rId := $46464952;
      wh.rLen := 36;
      wh.wId := $45564157;
      wh.fId := $20746d66;
      wh.fLen := 16;
      wh.wFormatTag := 1;
      wh.nChannels := channels;
      wh.nSamplesPerSec := rate;
      wh.nAvgBytesPerSec := channels*rate*(resolution div 8);
      wh.nBlockAlign := channels*(resolution div 8);
      wh.wBitsPerSample := resolution;
      wh.dId := $61746164;
      wh.wSampleLength := 0;
try
      assignfile(wf,fn); {打开对应文件 }
      rewrite(wf); {移动指针到文件头}
      write(wf,wh); {写进文件头 }
      closefile(wf); {关闭文件 }
      result:=true ;
except
      result:=false ;
      closefile(wf);
end ;end;
end.