Page 1 of 1

How to get 16-bit data from the PCM file

PostPosted: February 11th, 2009, 2:03 am
by mtp
Hi,

I have downloaded the Wave Audio component for using in the speech processing. However, I am trying to directly exact 16-bit data stream from the PCM file format but I cannot do that. As Kambiz replied on the question "How get the exact silence time" about the stream object that shown only the example of 8-bit audio data accessing (buffer is defined as Byte). Could any one kindly suggest me how to deal with 16-bit data? Which part of the following code should be changed? I am truly appreciative for the helping.

//-------- Example of 8-bit audio data accessing -----------------
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;

Re: How to get 16-bit data from the PCM file

PostPosted: February 11th, 2009, 5:09 am
by Kambiz
In 8-bit PCM, each sample is a value between 0 and 255, which value of 127 means no signal (silnece).
But in 16-bit PCM, samples are of type SmallInt (two bytes signed integer) and zero means no signal.

Re: How to get 16-bit data from the PCM file

PostPosted: February 11th, 2009, 7:20 am
by mtp
Thanks a lot for your reply. Thanks a gain for the great jobs! =D>