waveaudio Buffer Structure

Please discuss general Delphi programming topics here.

waveaudio Buffer Structure

Postby ajt » February 18th, 2010, 4:39 pm

For a TWaveAudioDataReadyEvent with BufferCount := 2 and PCMFormat := Stereo16bit44100Hz how are the samples arranged in the buffer(i.e. channel position and MSB/LSB)? Sorry for such a basic question but I cannot find this in the Readme.htm file and am getting identical sample values for Left and Right when I try to de-interleave the buffer. Thanks

Al
ajt
Active Member
Active Member
 
Posts: 5
Joined: February 18th, 2010, 4:34 pm

Re: waveaudio Buffer Structure

Postby Kambiz » February 18th, 2010, 9:10 pm

Why should I describe anatomy of wave formats in the readme file of the wave audio package? :0

Each sample in a 16bit Stereo PCM format consists of two 16bit signed integer representing sample value for each of left and right channels. If you Google for PCM format, you will find enough resources.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2421
Joined: March 7th, 2003, 7:10 pm

Re: waveaudio Buffer Structure

Postby ajt » February 18th, 2010, 11:23 pm

Sorry for the seemingly dumb question.

Since PCM is an audio format (not a storage format) and WAV files (for example) store data a certain way, I did assume that the data was stored as in the data chunk in a WAV file. My deinterleave code wasn't working so I began to look for specific definitions in the code and readme.htm so I could fix it. The Help doesn't really say the data is stored in "PCM Format" only referring to it as wave data which is a broad term and doesn't define how application buffers will be filled in any case.

The following definition of the DataReady event still leaves questions even if I assume the data is structured as a WAV file data chunk in the buffer.
In the event, the pointer to the buffer is typeless so is buffersize in bytes, words or samples? I assume it is bytes and the deinterleave code walks through the buffer in signed words. Also, in the TLiveAudioRecorder there is a property called BufferCount defined only as "Determines the number of data buffers". What exactly is this property (I have set it to 2 for stereo but thats only a guess)?

TWaveAudioDataReadyEvent = procedure(Sender: TObject; const Buffer: Pointer; BufferSize: DWORD; var FreeIt: Boolean) of object;
This event is used for wave audio events that informs the caller about the recorded wave audio data. The wave data stored in buffer specified by the Buffer parameter, and the size of the actual data in the buffer is specified by the BufferSize parameter. If the FreeIt parameter set to True, the component will release the memory allocated for the buffer, otherwise your application must release it.
ajt
Active Member
Active Member
 
Posts: 5
Joined: February 18th, 2010, 4:34 pm

Re: waveaudio Buffer Structure

Postby Kambiz » February 19th, 2010, 5:51 am

The buffer contains audio data, but the type depends on the chosen format. So base on the wave format, each sample can have any data format, and even the buffer can be compressed.

Consider BufferCount as the number of cached buffers.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2421
Joined: March 7th, 2003, 7:10 pm


Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron