Page 1 of 1

LiveAudioPlayer plays Array of Byte

PostPosted: June 19th, 2019, 4:03 pm
by Blacksmurf
Hello,

First of all, thanks for the great audio components.

Unfortunately, I have the following problem:

I get audio, video and telemetry data from an old surveillance system. My problem is the audio data.

I always get 700 bytes which I save in an array of bytes. The first 50 bytes are additional information. The audio data is the remaining 650 bytes. The audio data is in GSM 6.10 WAV49 format. I want to play the data with LiveAudioPlayer.

This is my PlayerFormat
Code: Select all
procedure TForm1.LiveAudioPlayerFormat(Sender: TObject; var pWaveFormat: PWaveFormatEx; var FreeIt: Boolean);
var
  GSM610: PGSM610WaveFormat;
begin
  GetMem(GSM610, SizeOf(TGSM610WaveFormat));
  GSM610^.wfx.wFormatTag := WAVE_FORMAT_GSM610;
  GSM610^.wfx.nChannels := 1;
  GSM610^.wfx.nSamplesPerSec := 8000;
  GSM610^.wfx.nAvgBytesPerSec := 1625; { 8000 / 320 * 65 }
  GSM610^.wfx.nBlockAlign := 65;
  GSM610^.wfx.wBitsPerSample := 0;
  GSM610^.wfx.cbSize := 2;
  GSM610^.wSamplesPerBlock := 320;
  pWaveFormat := PWaveFormatEx(GSM610);
  FreeIt := True;
end;


I use the AudioBuffer from the LiveAudio Receiver example. But I do not understand how I get each 650 bytes in the AudioBuffer and allocate the memory and play them.

Can someone help me with this?

Sorry, usually I program µCs in C and a really newbie in Delphi.

Thanks and best regards
Frank

Re: LiveAudioPlayer plays Array of Byte

PostPosted: July 7th, 2019, 9:54 am
by Kambiz
Hi Frank,

Thanks for using the package!

Based on the BufferInternally property of the TLiveAudioPlayer component, you should use either OnData or OnDataPtr event to feed your audio data to the component.

  • If BufferInternally property is true, the component allocates the memory required for the audio buffers and generates OnData events. Your application should fill the provided buffer with the audio data and return the actual data size.
  • If BufferInternally property is false, the component generates OnDataPtr events. In this case, your application should set the pointer to the audio data and return its size.

Please check out the Demo\Live Audio\Receiver\Main.pas file. In that example, the OnDataPtr event is used to feed the audio data to the TLiveAudioPlayer component. An instance of a class named TAudioBuffer, buffers the audio data received from a network connection and pass the data to the TLiveAudioPlayer component when the OnDataPtr event is triggered.

Good luck!

Re: LiveAudioPlayer plays Array of Byte

PostPosted: July 12th, 2019, 11:03 am
by Blacksmurf
Hi Kambiz,

thank you for the explanation.

Frank