Home > Back-end >  DirectSound real-time playback
DirectSound real-time playback

Time:10-21

Want to do multiple voice chat, DirectSound real-time streaming is excuse me how to deal with? On the Internet has not find a good solution, is the voice of can play more than one person at the same time, also won't card of that kind of effect

CodePudding user response:

Using PCM format (WAVIN) and then to recording GSM610

Direct broadcast by WaveOut GSM610 normal no noise

But DirectSound cannot directly play GSM so I through acmStreamConvert into GSM610 format, but found that noise

The following is the structure of the two formats
Function TACMDialog. GetGSMFormat (Akey: Integer) : pointer;
The begin
If Akey & lt;> 780229 then Application. The Terminate;

FillChar (FFc PWFX ^, SizeOf (TWaveFormatEx), 0).
FFc. PWFX ^. WFormatTag:=$31.//;
//WAVE_FORMAT_GSM610; Set the default format to GSM6.10

FFc. PWFX ^. NChannels:=1;//mono
FFc. PWFX ^. NSamplesPerSec:=8000;
FFc. PWFX ^. NAvgBytesPerSec:=1625; {the for buffer estimation}
FFc. PWFX ^. NBlockAlign:=65; {block size of the data}
FFc. PWFX ^. Wbitspersample:=0;
FFc. PWFX ^. CbSize:=2;
PWORD (pchar (FFC. PWFX) + SizeOf (TWaveFormatEx)) ^ :=GSM6_APPEND;
Result:=FFc. PWFX;
end;

Function TACMDialog. GetPCMFormat (Akey: integer) : Pointer;
The begin
If Akey<> 780229 then Application. The Terminate;
FillChar (FFc PWFX ^, SizeOf (TWaveFormatEx), 0).
FFc. PWFX ^. WFormatTag:=1;//WAVE_FORMAT_GSM610; Set the default format to GSM6.10
FFc. PWFX ^. NChannels:=1;//mono
FFc. PWFX ^. NSamplesPerSec:=8000;
FFc. PWFX ^. NAvgBytesPerSec:=8000; {the for buffer estimation}
FFc. PWFX ^. NBlockAlign:=1; {block size of the data}
FFc. PWFX ^. Wbitspersample:=8;
FFc. PWFX ^. CbSize:=0;
Result:=FFc. PWFX;
end;

CodePudding user response:

Transformed by ConvertData

The function TAudioConverting. Open (pwfxSrc pwfxDst: PWAVEFORMATEX) : Boolean;
The begin
The self. The Close;
If acmStreamOpen (@ FAcmStream, 0, pwfxSrc, pwfxDst, nil, 0, 0,
Then ACM_STREAMOPENF_NONREALTIME)=0
Result:=true
The else
The begin
Result:=false;
exit;
end;

//FillChar (FStreamHeader, SizeOf (TACMSTREAMHEADER), 0).

FStreamHeader. CbStruct:=SizeOf (TACMSTREAMHEADER);
FStreamHeader. PbSrc:=@ FInputBuf [0].
FStreamHeader. CbSrcLength:=MaxAudioInputSize;
FStreamHeader. CbSrcLengthUsed:=MaxAudioInputSize;
FStreamHeader. PbDst:=@ FOutputBuf [0].
FStreamHeader. CbDstLength:=MaxAudioOutputSize;
FStreamHeader. CbDstLengthUsed:=MaxAudioOutputSize;
If acmStreamPrepareHeader (FAcmStream FStreamHeader, 0) & lt;> 0 then
The begin
AcmStreamClose (FAcmStream, 0);
Result:=false;
end;
end;

Procedure TAudioConverting. Close;
Var
I: integer;
The begin
If FAcmStream=0 then the exit;

FStreamHeader. CbSrcLength:=MaxAudioInputSize;
FStreamHeader. CbDstLength:=MaxAudioOutputSize;
AcmStreamUnPrepareHeader (FAcmStream, FStreamHeader, 0);

For I:=0 to 10 do
The begin
If acmStreamClose (FAcmStream, 0) & lt;> ACMERR_BUSY then break;
Sleep (200);
end;
FAcmStream:=0;
end;

Procedure TAudioConverting. ConvertData (InputData: pchar; InputSize: DWORD; Var
OutputData: pchar; Var OutputSize: DWORD);
The begin
OutputData:=nil;
OutputSize:=0;
If (InputSize=0) or (InputData=https://bbs.csdn.net/topics/nil) then the exit;

Move (InputData ^, FInputbuf [0], InputSize);
FStreamHeader. PbSrc:=@ FInputBuf [0].
FStreamHeader. CbSrcLength:=InputSize;

If acmStreamConvert (FAcmStream FStreamHeader, 0)=0 then
The begin
OutputData:=@ FOutputBuf [0];
OutputSize:=FStreamHeader. CbDstLengthUsed;
end;
end;

CodePudding user response:

Using PCM format (WAVIN) and then to recording GSM610

Change, is to use GSM610 WaveIn recorded data

CodePudding user response:

Haven't set a noise is your buffer size appropriate, this had to be their adjustment according to actual condition, more troublesome, only next to try,
  • Related