我很早就下载了ACM语音控件,,,装在D7上面,,用来开发语音聊天,,,,可是我发现,,在调试程序的时候,,,有时候会出现噪声,,,吱吱吱的,,非常刺耳,,,,,不知道大家遇到这种情况没有,,,
谁有好办法可以解决啊,,,,,,另,,我已经解决了关于ACM语音控件延时的问题了,现在就差这个刺耳的噪音问题还没有解决,因为它不是总是噪音,,,而是有时候有噪声,有时候又没有噪声,很奇怪的
下面是我的部分关键代码////////////////////////////////////////////
////////发送部分/////////////////////
//////////////////////////////////////////公共变量
type
tWAVEFORMATEX = record
wFormatTag: Word; { format type }
nChannels: Word; { number of channels (i.e. mono, stereo, etc.) }
nSamplesPerSec: DWORD; { sample rate }
nAvgBytesPerSec: DWORD; { for buffer estimation }
nBlockAlign: Word; { block size of data }
wBitsPerSample: Word; { number of bits per sample of mono data }
cbSize: Word; { the count in bytes of the size of }
xBytes: Word;
end;var
buf: array[0..65535] of byte;
bufsize: Integer = 0;
tmpformat: tWAVEFORMATEX;
窗口创建时给结构赋值
tmpformat.wFormatTag := 49;
tmpformat.nChannels := 1;
tmpformat.nSamplesPerSec := 8000;
tmpformat.nAvgBytesPerSec := 1625;
tmpformat.nBlockAlign := 65;
tmpformat.wBitsPerSample := 0;
tmpformat.cbSize := 2;
tmpformat.xBytes := 320;
ACMWaveIn1.Open(@tmpformat);
发送部分
procedure TForm1.ACMWaveIn1Data(data: Pointer; size: Integer);
begin
copymemory(pchar(@buf) + bufsize, data, size);
inc(bufsize, size);
if bufsize > 0 then begin
ClientSocket1.Socket.SendBuf(buf, bufsize);
bufsize := 0;
end;////////////////////////////////////////////
////////下面是接收部分/////////////////////
//////////////////////////////////////////{窗口初始化时跟上面一样的}
ACMWaveOut1.Open(@tmpformat); //把采集到的经过压缩后的语音取出来
{收到数据时}
procedure TForm1.ServerSocket1ClientRead(Sender: TObject;
Socket: TCustomWinSocket);
var
buf: array of byte;
count: integer;
begin
try
count := Socket.ReceiveLength;
if count <> 0 then begin
setlength(buf, count); //建buf[count]数组.为了后面装音频数据
Socket.ReceiveBuf(buf[0], count);
Label1.Caption := inttostr(sizeof(buf));
ACMWaveOut1.PlayBack(buf, count);
end;
finally
end;
end;能收到声音,,,但是有时候有噪音,,,有时候又没有,,实在是搞不懂,,,有哪位大哥能帮帮小弟啊!!!!!
谁有好办法可以解决啊,,,,,,另,,我已经解决了关于ACM语音控件延时的问题了,现在就差这个刺耳的噪音问题还没有解决,因为它不是总是噪音,,,而是有时候有噪声,有时候又没有噪声,很奇怪的
下面是我的部分关键代码////////////////////////////////////////////
////////发送部分/////////////////////
//////////////////////////////////////////公共变量
type
tWAVEFORMATEX = record
wFormatTag: Word; { format type }
nChannels: Word; { number of channels (i.e. mono, stereo, etc.) }
nSamplesPerSec: DWORD; { sample rate }
nAvgBytesPerSec: DWORD; { for buffer estimation }
nBlockAlign: Word; { block size of data }
wBitsPerSample: Word; { number of bits per sample of mono data }
cbSize: Word; { the count in bytes of the size of }
xBytes: Word;
end;var
buf: array[0..65535] of byte;
bufsize: Integer = 0;
tmpformat: tWAVEFORMATEX;
窗口创建时给结构赋值
tmpformat.wFormatTag := 49;
tmpformat.nChannels := 1;
tmpformat.nSamplesPerSec := 8000;
tmpformat.nAvgBytesPerSec := 1625;
tmpformat.nBlockAlign := 65;
tmpformat.wBitsPerSample := 0;
tmpformat.cbSize := 2;
tmpformat.xBytes := 320;
ACMWaveIn1.Open(@tmpformat);
发送部分
procedure TForm1.ACMWaveIn1Data(data: Pointer; size: Integer);
begin
copymemory(pchar(@buf) + bufsize, data, size);
inc(bufsize, size);
if bufsize > 0 then begin
ClientSocket1.Socket.SendBuf(buf, bufsize);
bufsize := 0;
end;////////////////////////////////////////////
////////下面是接收部分/////////////////////
//////////////////////////////////////////{窗口初始化时跟上面一样的}
ACMWaveOut1.Open(@tmpformat); //把采集到的经过压缩后的语音取出来
{收到数据时}
procedure TForm1.ServerSocket1ClientRead(Sender: TObject;
Socket: TCustomWinSocket);
var
buf: array of byte;
count: integer;
begin
try
count := Socket.ReceiveLength;
if count <> 0 then begin
setlength(buf, count); //建buf[count]数组.为了后面装音频数据
Socket.ReceiveBuf(buf[0], count);
Label1.Caption := inttostr(sizeof(buf));
ACMWaveOut1.PlayBack(buf, count);
end;
finally
end;
end;能收到声音,,,但是有时候有噪音,,,有时候又没有,,实在是搞不懂,,,有哪位大哥能帮帮小弟啊!!!!!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货