主题:关于wav格式
在VFP下怎么知道XX.wav有多长时间?
懂VB的帮我看看,谢谢
type
TWavHeader=record
FieldLabel:array[0..3] of Char; //"RIFF"
FieldLen:DWORD; //从08H开始到文件末尾字节数
WaveID:array[0..3] of Char; //"WAVE" 57 41 56 45
FmtID:array[0..3] of Char; //"fmt " 66 6D 74 20
FmtLen:DWORD; //A_LAW 12 00 00 00 PCM 10 00 00 00
wFormatTag: Word; // format type A_LAW 06 00 PCM 01 00
nChannels: Word; // 声道数 01 00
nSamplesPerSec: DWORD; // sample rate 采样率 40 1F 00 00
nAvgBytesPerSec: DWORD; // AvgBytesPerSec是每秒钟的字节数,应该这样计算:AvgBytesPerSec = BlockAlign * SamplesPerSec;
nBlockAlign: Word; // BlockAlign是每个样本的字节数,应该这样计算:BlockAlign = Channel * BitsPerSample / 8;
wBitsPerSample: Word; //采样BITS数 08 00
DataID:array[0..3] of Char; //"data" 64 61 74 61
DataLen:DWORD; // 采样数据总字节数
end;
//取WAV文件格式
function GetWavHeader(FHandle:Integer;var WHeader:TWavHeader):Boolean;
implementation
function GetWavHeader(FHandle:Integer;var WHeader:TWavHeader):Boolean;
begin
Result:=False;
if FHandle<0 then Exit;
FileSeek(FHandle,0,0);
FileRead(FHandle,WHeader,SizeOf(TWavHeader));
if WHeader.WaveID<>'WAVE' then Exit;
if WHeader.FieldLabel<>'RIFF' then Exit;
if WHeader.DataID<>'data' then Exit;
Result:=True;
end;
'时间长度:'+ IntToStr(WavHeader.DataLen div WavHeader.nAvgBytesPerSec)+'秒' );
懂VB的帮我看看,谢谢
type
TWavHeader=record
FieldLabel:array[0..3] of Char; //"RIFF"
FieldLen:DWORD; //从08H开始到文件末尾字节数
WaveID:array[0..3] of Char; //"WAVE" 57 41 56 45
FmtID:array[0..3] of Char; //"fmt " 66 6D 74 20
FmtLen:DWORD; //A_LAW 12 00 00 00 PCM 10 00 00 00
wFormatTag: Word; // format type A_LAW 06 00 PCM 01 00
nChannels: Word; // 声道数 01 00
nSamplesPerSec: DWORD; // sample rate 采样率 40 1F 00 00
nAvgBytesPerSec: DWORD; // AvgBytesPerSec是每秒钟的字节数,应该这样计算:AvgBytesPerSec = BlockAlign * SamplesPerSec;
nBlockAlign: Word; // BlockAlign是每个样本的字节数,应该这样计算:BlockAlign = Channel * BitsPerSample / 8;
wBitsPerSample: Word; //采样BITS数 08 00
DataID:array[0..3] of Char; //"data" 64 61 74 61
DataLen:DWORD; // 采样数据总字节数
end;
//取WAV文件格式
function GetWavHeader(FHandle:Integer;var WHeader:TWavHeader):Boolean;
implementation
function GetWavHeader(FHandle:Integer;var WHeader:TWavHeader):Boolean;
begin
Result:=False;
if FHandle<0 then Exit;
FileSeek(FHandle,0,0);
FileRead(FHandle,WHeader,SizeOf(TWavHeader));
if WHeader.WaveID<>'WAVE' then Exit;
if WHeader.FieldLabel<>'RIFF' then Exit;
if WHeader.DataID<>'data' then Exit;
Result:=True;
end;
'时间长度:'+ IntToStr(WavHeader.DataLen div WavHeader.nAvgBytesPerSec)+'秒' );