我的应用程序使用麦克风在机器之间进行通话。当两个人说话时,我遇到了一个问题,有一个不断的嘶嘶声'声音嘈杂。需要帮助
{
waveOutDevice = new DirectSoundOut();
wavFormat = new WaveFormat(sampleRates, numberChannels);
// Create two buffers to represent left & right output
waveProvider[0] = new BufferedWaveProvider(wavFormat);
waveProvider[1] = new BufferedWaveProvider(wavFormat);
waveProvider[0].BufferDuration = new TimeSpan(0, 0, 0, 0, 100);
waveProvider[1].BufferDuration = new TimeSpan(0, 0, 0, 0, 100);
waveProvider[0].DiscardOnBufferOverflow = true;
waveProvider[1].DiscardOnBufferOverflow = true;
IEnumerable<IWaveProvider> providers = from w in waveProvider select w;
// channels of a stereo setup.
outputWaveProvider = new MultiplexingWaveProvider(providers,2);
outputWaveProvider.ConnectInputToOutput(0, 0);
outputWaveProvider.ConnectInputToOutput(1, 1);
waveOutDevice.Init(outputWaveProvider);
waveOutDevice.Play();
waveInStream = new WaveIn();
waveInStream.WaveFormat = wavFormat;
waveInStream.DataAvailable += new EventHandler<WaveInEventArgs>(waveInStream_DataAvailable);
waveInStream.StartRecording();
waveInStream.RecordingStopped += new EventHandler<StoppedEventArgs>(this.OnRecordingStopped);
}
void waveInStream_DataAvailable(object sender, WaveInEventArgs e)
{
writer.WriteData(e.Buffer, 0, e.BytesRecorded);
writer.Flush();
}
public void OnRecordingStopped(object sender, StoppedEventArgs e)
{
if (this.writer != null)
{
waveInStream.StopRecording();
writer.Close();
writer = null;
}
}
如果我尝试给出高BufferDuration,则噪声几乎为零,但滞后增加。请帮忙
答案 0 :(得分:0)
缓冲区持续时间不应影响延迟,应保留较高的值。通过更改输出设备的延迟来减少延迟。