E
earthworm
Unregistered / Unconfirmed
GUEST, unregistred user!
用indy udp和acm做的
就是不出声,本来可以用indy的demo的,可我用的是Delphi 7,没有udpsock,真郁闷[]
IP填的是172.0.0.1,自己和自己讲话
可愣是啥声音都没有啊啊啊啊[!][!][!]
哪位大侠帮我看一下哪有问题吧
谢啦[]
unit Unit1;
interface
uses
Windows, SysUtils, Classes, Controls, Forms,
ACMWaveOut,mmsystem, ACMWaveIn, ACMDialog, StdCtrls,
Graphics, ExtCtrls, ComCtrls, Sockets, IdBaseComponent,
IdComponent, IdUDPBase, IdUDPServer,IdSocketHandle, IdUDPClient;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
IdUDPClient1: TIdUDPClient;
IdUDPServer1: TIdUDPServer;
ACMDialog1: TACMDialog;
ACMWaveOut1: TACMWaveOut;
ACMWaveIn1: TACMWaveIn;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure ACMWaveIn1Data(data: Pointer;
size: Integer);
procedure IdUDPServer1UDPRead(Sender: TObject;
AData: TStream;
ABinding: TIdSocketHandle);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var formatointer;
begin
format:=ACMDialog1.OpenDialog;
if format=nil then
exit;
IdUDPServer1.Active:=true;
idudpclient1.Active:=true;
ACMWaveOut1.Open(format);
ACMWaveIn1.Open(format);
Button1.Enabled:=false;
Button2.Enabled:=true;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
ACMWaveIn1.Close;
ACMWaveOut1.Close;
IdUDPServer1.Active:=false;
idudpclient1.Active:=false;
Button1.Enabled:=true;
Button2.Enabled:=false;
end;
procedure TForm1.ACMWaveIn1Data(data: Pointer;
size: Integer);
var
mdata:array[1..400] of char;
k:integer;
begin
for k:=1 to sizedo
mdata[k]:=pchar(dword(data)+dword(k-1))^;
Idudpclient1.SendBuffer('172.0.0.1',5623,mdata,size);
end;
procedure TForm1.IdUDPServer1UDPRead(Sender: TObject;
AData: TStream;
ABinding: TIdSocketHandle);
var
DataStringStream: TStringStream;
begin
DataStringStream := TStringStream.Create('');
try
DataStringStream.CopyFrom(AData, AData.Size);
ACMWaveOut1.PlayBack(AData,AData.Size);
finally
DataStringStream.Free;
end;
end;
end.
就是不出声,本来可以用indy的demo的,可我用的是Delphi 7,没有udpsock,真郁闷[]
IP填的是172.0.0.1,自己和自己讲话
可愣是啥声音都没有啊啊啊啊[!][!][!]
哪位大侠帮我看一下哪有问题吧
谢啦[]
unit Unit1;
interface
uses
Windows, SysUtils, Classes, Controls, Forms,
ACMWaveOut,mmsystem, ACMWaveIn, ACMDialog, StdCtrls,
Graphics, ExtCtrls, ComCtrls, Sockets, IdBaseComponent,
IdComponent, IdUDPBase, IdUDPServer,IdSocketHandle, IdUDPClient;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
IdUDPClient1: TIdUDPClient;
IdUDPServer1: TIdUDPServer;
ACMDialog1: TACMDialog;
ACMWaveOut1: TACMWaveOut;
ACMWaveIn1: TACMWaveIn;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure ACMWaveIn1Data(data: Pointer;
size: Integer);
procedure IdUDPServer1UDPRead(Sender: TObject;
AData: TStream;
ABinding: TIdSocketHandle);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var formatointer;
begin
format:=ACMDialog1.OpenDialog;
if format=nil then
exit;
IdUDPServer1.Active:=true;
idudpclient1.Active:=true;
ACMWaveOut1.Open(format);
ACMWaveIn1.Open(format);
Button1.Enabled:=false;
Button2.Enabled:=true;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
ACMWaveIn1.Close;
ACMWaveOut1.Close;
IdUDPServer1.Active:=false;
idudpclient1.Active:=false;
Button1.Enabled:=true;
Button2.Enabled:=false;
end;
procedure TForm1.ACMWaveIn1Data(data: Pointer;
size: Integer);
var
mdata:array[1..400] of char;
k:integer;
begin
for k:=1 to sizedo
mdata[k]:=pchar(dword(data)+dword(k-1))^;
Idudpclient1.SendBuffer('172.0.0.1',5623,mdata,size);
end;
procedure TForm1.IdUDPServer1UDPRead(Sender: TObject;
AData: TStream;
ABinding: TIdSocketHandle);
var
DataStringStream: TStringStream;
begin
DataStringStream := TStringStream.Create('');
try
DataStringStream.CopyFrom(AData, AData.Size);
ACMWaveOut1.PlayBack(AData,AData.Size);
finally
DataStringStream.Free;
end;
end;
end.