LiveAudio and codecs

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

LiveAudio and codecs

Postby zuzu » November 10th, 2007, 1:26 am

First of all, thank you for waveaudio components.

Can you point me few steps to use correctlly windows installed ACM codecs between LiveAudioRecorder/Player and UDP. I plan to use GSM610 for example.

Just to test, I put one audioredirector and liveaudioplayer on a form, set both to NON_PCM and write on both OnFormat event :

Code: Select all
procedure TForm1.playFormat(Sender: TObject;
  out pWaveFormat: PWaveFormatEx; var FreeIt: Boolean);
begin
  GetMem(pWaveFormat, SizeOf(TWaveFormatEx)); // allocate memory
  FreeIt := True; // let the component release the allocated memory

  pWaveFormat^.wFormatTag  :=49; // GSM structure
  pWaveFormat^.nChannels   :=1;
  pWaveFormat^.nSamplesPerSec  :=8000;
  pWaveFormat^.nAvgBytesPerSec :=1625;
  pWaveFormat^.nBlockAlign := 65;
  pWaveFormat^.wBitsPerSample:=0;
  pWaveFormat^.cbSize :=2;
end;


Application activates both components in OnCreate event.
When starts, rise EWaveAudioSysError with 'Specific format is not supported...' and after few secconds I can hear what I just live insert on mic input, but no processed at all, like pure PCM.

Sorry for english, is not native.
Thanks in advance,
zuzu
Member
Member
 
Posts: 2
Joined: November 6th, 2007, 9:54 pm

Postby Kambiz » November 10th, 2007, 12:39 pm

Here is the right code:

Code: Select all
const
  WAVE_FORMAT_GSM610 = $0031;

type
  PGSM610WaveFormat = ^TGSM610WaveFormat;
  TGSM610WaveFormat = record
    wfx: TWaveFormatEx;
    wSamplesPerBlock: Word;
  end;

procedure TForm1.playFormat(Sender: TObject;
  out 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;


Did you find what was your mistake? You were not allocated and initialized the last 2 extra bytes.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm

Postby zuzu » November 10th, 2007, 2:55 pm

:lol: works ! Thank you very much Kambiz.

In fact I already tried to setup SamplesPerBlock (missing) property but couldn't find it as member, as I wrong declared.

One more question : I decreased buff length and increase number of them just to have as small as possible processing delay. Since I need to choose between codecs to test audio quality against network channel, how can I properly setup those parameters dynamic ?

For example in GSM610 8KHz, works great with 32 headers and 128 bytes length and even smaller, about 100mS.

Can I implement some relationship between codec params and required buff ?
zuzu
Member
Member
 
Posts: 2
Joined: November 6th, 2007, 9:54 pm

Postby Kambiz » November 10th, 2007, 2:58 pm

I have no idea! :(
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm


Return to DELPHI AREA Products

Who is online

Users browsing this forum: No registered users and 2 guests

cron