救命了,关于语音传输的问题(200分)

  • 主题发起人 主题发起人 monkeyking1983
  • 开始时间 开始时间
M

monkeyking1983

Unregistered / Unconfirmed
GUEST, unregistred user!
我用TACMWaveOut 和 TACMWaveIn来采集和播放语音,
代码如下,可是接收并播放出来的都是有节奏的 咚咚 声
有谁知道这是为什么呀,在线等待,分数不够可以再加。


unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, IdUDPClient, IdBaseComponent, IdComponent,
IdUDPBase, IdUDPServer, ACMWaveOut, ACMWaveIn, ACMDialog, IdSocketHandle;

type
TForm1 = class(TForm)
ACMDialog1: TACMDialog;
ACMWaveIn1: TACMWaveIn;
ACMWaveOut1: TACMWaveOut;
Button1: TButton;
IdUDPServer1: TIdUDPServer;
IdUDPClient1: TIdUDPClient;
IP: TLabeledEdit;
LocalPort: TLabeledEdit;
RemotePort: TLabeledEdit;
procedure Button1Click(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
format: pointer;
begin

IdUDPServer1.DefaultPort := StrToInt(RemotePort.Text);
IdUDPClient1.Port := StrToInt(RemotePort.Text);
IdUDPClient1.Host := IP.Text;
IdUdpClient1.Active := True;
IdUdpServer1.Active := True;

format := ACMDialog1.OpenDialog;
ACMWaveIn1.Open(format);
ACMWaveOut1.Open(format);
end;


procedure TForm1.ACMWaveIn1Data(data: Pointer;
size: Integer);
begin

IdUDPClient1.SendBuffer(Data^, size);
//如果不发送,直接播放出来,一切正常。
//ACMWaveOut1.PlayBack(data, size);
end;


procedure TForm1.IdUDPServer1UDPRead(Sender: TObject;
AData: TStream;
ABinding: TIdSocketHandle);
var
Buffer: array of byte;
begin

SetLength(Buffer, AData.Size);
AData.ReadBuffer(Buffer[0], AData.Size);
ACMWaveOut1.PlayBack(@Buffer, AData.size);
end;


end.
 
我估计是你录和放的比特率没调一致吧
 
楼上的,我代码贴出来了,你可以看看。
我是使用同一个Format来Open的,应该是一样的吧,而以我直接播放就没有问题。
 
问题已经解决了。可是没有人能拿到分数。
 
后退
顶部