Page 1 of 1

copy data from buffer to memo

PostPosted: March 19th, 2009, 9:10 pm
by Ali_Reza_Nazari
hi
i want to copy data from buffer to memo i this procedure :

procedure TForm1.LiveAudioRecorder1Data(Sender: TObject;
const Buffer: Pointer; BufferSize: Cardinal; var FreeIt: Boolean);
begin
end;

can i do it?
convert buffer to data like 127,120,140,12,...... in to a memo?

Re: copy data from buffer to memo

PostPosted: March 20th, 2009, 12:00 am
by Kambiz
Although that is not a good idea but here is an example.

Code: Select all
function BytesToString(B: PByte; Count: Cardinal): String;
var
  I: Integer;
begin
  Result := '';
  for I := 1 to Count do
  begin
    if Result <> '' then Result := Result + ',';
    Result := Result + IntToStr(B^);
    Inc(B);
  end;
end;

procedure TForm1.LiveAudioRecorder1Data(Sender: TObject;
  const Buffer: Pointer; BufferSize: Cardinal; var FreeIt: Boolean);
begin
  Memo1.Lines.Add(BytesToString(PByte(Buffer), BufferSize);
end;

Re: copy data from buffer to memo

PostPosted: March 21st, 2009, 8:46 pm
by Ali_Reza_Nazari
OK
hi.
tanks
that is good for me, because
i dont know
(P+1)* IN CPP equal ????? IN DELPHI?
and now i know

I am find another simple code
Code: Select all
procedure This(Buffer: Pointer; var Len: Integer);
var
mystr: string;
begin
SetLength(mystr, Len);
Move(Buffer^, mystr[1], Len);
end;

--------------------------------

and for reverse action? how can i do?

-------------------------------
i want to write a chat program, i make a text chat, now for video chat i must first send and recieve sound from sockets and then send/recieve pictures(vodeo)
AND now, i want to compress OR analyze sound for less traffic for audio data. in minimum 8bit8000 pcm, i must send 800 Byte pers second and it is not good, i must send at maximum 1 or 2 KB per second, i think if i divide data to half, and delete other half, in replase with (127) in dest, may be can to do less traffic

my friend tell me that i must use VCLZIP to compress data,

please help me to write this program
thanks