I need to analize a wave file to get the exact silence time before the tone signal.
I saw that changing the BufferCount and BufferLength the result time also change.
Witch is the rigth way to get this time?
Thanks in advance
Jorge
function WaveOffsetToMS(const pWaveFormat: PWaveFormatEx; Offset: DWORD): DWORD;
var
NumOfSamples: DWORD;
begin
with pWaveFormat^ do
begin
if nBlockAlign > 1 then
Offset := nBlockAlign * (Offset div nBlockAlign);
if (wBitsPerSample > 0) and (nSamplesPerSec > 0) then
begin
NumOfSamples := Trunc(Offset * (wBitsPerSample / 8));
Result := Trunc(1000 * (NumOfSamples / nSamplesPerSec));
end
else
Result := Trunc(1000 * (Offset / nAvgBytesPerSec));
end;
end;
var
Wave: TWaveFile;
BytesRead: Integer;
Buffer: array[0..1023] of Byte;
begin
Wave := TWaveFile.Create('C:\Sample.wav', fmOpenRead or fmShareDenyWrite);
try
Wave.BeginRead;
try
BytesRead := Wave.Read(Buffer, SizeOf(Buffer));
while BytesRead > 0 do
begin
// process the buffer
BytesRead := Wave.Read(Buffer, SizeOf(Buffer));
end;
finally
Wave.EndRead;
end;
finally
Wave.Free;
end;
end;
Return to DELPHI AREA Projects
Users browsing this forum: No registered users and 3 guests