type
  TFok=procedure;stdcall;
  TSoundClient=Class(Tobject)
   private
      FAcmOut:TAcmOut;
      FUdp:TNMUdp;
//      FLocalPort:Integer;
      procedure Init;
      procedure OnDataReceived(Sender: TComponent; NumberBytes: Integer; FromIP: string; Port: integer);
   public
     constructor Create;
     Destructor Destroy;override;
 end;
 function OpenVoice(aproc:TFok):boolean;StdCall;
 function CloseVoice:boolean;Stdcall;var
  Soundclient:TSoundClient;
implementation{ TSoundClient }constructor TSoundClient.Create;
begin
  FAcmOut:=TAcmOut.Create(nil);
  FUdp:=TNmUdp.Create(nil);
  FUdp.LocalPort:=10000;
  FUdp.OnDataReceived:=OnDataReceived;
  inherited;
end;destructor TSoundClient.Destroy;
begin
  FAcmOut.free;
  FUdp.free;
  inherited;
end;procedure TSoundClient.Init;
var
  tmpFormat:tAcmWaveFormat;
begin
  with tmpformat do
  begin
    Format.wFormatTag:=6;
    format.nChannels:=1;
    format.nSamplesPerSec:=8000;
    format.nAvgBytesPerSec:=8000;
    format.nBlockAlign:=1;
    format.wBitsPerSample:=8;
    format.cbSize:=0;
  end;
  FAcmout.Open(tmpFormat);
end;procedure TSoundClient.OnDataReceived(Sender: TComponent;
  NumberBytes: Integer; FromIP: string; Port: integer);
var
buff:array[0..2048] of char;
begin
  FUdp.ReadBuffer(buff,numberbytes);
  if Facmout.Active then
    Facmout.Play(buff,2048);
end;function OpenVoice(aproc:TFok):boolean;
begin
  Result:=true;
  try
   if assigned(aproc)then
      TFok(aproc);
{    if Soundclient=nil then
      soundClient:=TSoundClient.Create;
    SoundClient.Init;
}
  except
  Result:=false;
  end;
end;
function closeVoice:boolean;
begin
  if SoundClient<>nil then
  FreeAndNil(SoundClient);//.Free;
  Result:=true;
end;
exports Openvoice,Closevoice;
end.