我是初学者,用语音蒸 我尝试构建一个语音聊天应用程序我得出结论:
发送机制(伪代码):
private void but_Click(object sender, EventArgs e)
{
if (sourceList.SelectedItems.Count == 0) return;
int deviceNumber = sourceList.SelectedItems[0].Index;
NAudio.Wave.WaveIn sourceStream = new NAudio.Wave.WaveIn();
sourceStream.DeviceNumber = deviceNumber;
sourceStream.WaveFormat = new NAudio.Wave.WaveFormat(44100, NAudio.Wave.WaveIn.GetCapabilities(deviceNumber).Channels);
sourceStream.DataAvailable += new EventHandler<NAudio.Wave.WaveInEventArgs>(sourceStream_DataAvailable);
sourceStream.StartRecording();
}
private void sourceStream_DataAvailable(object sender, NAudio.Wave.WaveInEventArgs e)
{
if (sourceStream== null) return;
send_UPD(e.Buffer, e.BytesRecorded);//sending data UPD
}
我认为发送成功,接收器将恢复字节数
发送机制(伪代码):
NAudio.Wave.DirectSoundOut waveOut = new NAudio.Wave.DirectSoundOut();
NAudio.Wave.WaveInProvider waveIn = new NAudio.Wave.WaveInProvider(/*my recived array of byte*/);
waveOut.Init(waveIn);
waveOut.Play();
我的问题
以上是真的,我可以用接收器中的字节数组做什么(我该怎么玩)???
答案 0 :(得分:1)
接收方应使用BufferedWaveProvider
,这样您就可以将音频数据排队,以便在到达时进行播放。