LiveAudioPlayer plays Array of Byte

Please post bug reports, feature requests, or any question regarding the DELPHI AREA projects here.

LiveAudioPlayer plays Array of Byte

Postby Blacksmurf » June 19th, 2019, 4:03 pm

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
Blacksmurf
Member
Member
 
Posts: 2
Joined: June 19th, 2019, 3:12 pm

Re: LiveAudioPlayer plays Array of Byte

Postby Kambiz » July 7th, 2019, 9:54 am

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

Re: LiveAudioPlayer plays Array of Byte

Postby Blacksmurf » July 12th, 2019, 11:03 am

Hi Kambiz,

thank you for the explanation.

Frank
Blacksmurf
Member
Member
 
Posts: 2
Joined: June 19th, 2019, 3:12 pm


Return to DELPHI AREA Projects

Who is online

Users browsing this forum: No registered users and 0 guests

cron