为何如此简单问题没人答呢?
唉...
论坛越好,思考的人越少
窃取别人劳动成果的人越多了...
procedure TForm1.CaptureStreamEvent(Sender: TObject);
var
voice_buf: array[0..1023] of char;
fa_ci, fa_yu, voice_streamsize, i, j: integer;
voicestream: Tmemorystream;
novoice: char;
nosend: boolean;
begin
voicestream := Tmemorystream.Create;
voicestream.Clear;
voicestream.Position := 0;
voicestream.CopyFrom(capture, capture.filledSize);
voicestream.Position := 0;
nosend := false;
for j := 1 to voicestream.size div 2do
//静音检测
begin
novoice := chr($00);
voicestream.ReadBuffer(novoice, 1);
if (novoice <= chr($81)) and (novOice >= chr($7F)) then
nosend := true
else
begin
nosend := false;
break;
end;
end;
if nosend = true then
begin
voicestream.Clear;
voicestream.Free;
exit;
end;
voicestream.Position := 0;
voice_streamsize := voicestream.Size;
//发送语音
voice_buf := #0;
fa_ci := voice_streamsize div 1024;
fa_yu := voice_streamsize mod 1024;
for i := 1 to fa_cido
begin
voicestream.ReadBuffer(voice_buf, 1024);
SVoiceSocket.Send(@voice_buf, 1024);
end;
if fa_yu > 0 then
begin
voicestream.ReadBuffer(voice_buf, fa_yu);
SVoiceSocket.Send(@voice_buf, fa_yu);
end;
voicestream.Clear;
voicestream.Free;
end;