How to get 16-bit data from the PCM file

Please discuss general Delphi programming topics here.

How to get 16-bit data from the PCM file

Postby mtp » February 11th, 2009, 2:03 am

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;
mtp
Member
Member
 
Posts: 2
Joined: November 30th, 2008, 4:41 pm

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

Postby Kambiz » February 11th, 2009, 5:09 am

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.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2424
Joined: March 7th, 2003, 7:10 pm

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

Postby mtp » February 11th, 2009, 7:20 am

Thanks a lot for your reply. Thanks a gain for the great jobs! =D>
mtp
Member
Member
 
Posts: 2
Joined: November 30th, 2008, 4:41 pm


Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron