【问题标题】:NAudio streaming voice chat c#NAudio流式语音聊天c#
【发布时间】:2023-03-22 13:13:01
【问题描述】:

我是语音流的初学者
我尝试构建一个语音聊天应用程序我得出结论:

  • 我应该在套接字中使用 UPD 作为 ProtocolType
  • 我应该使用 NAudio 流媒体

发送机制(伪代码):

    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();

我的问题
以上是否属实,我可以用接收器中的字节数组做什么(我该如何播放)???

【问题讨论】:

    标签: c# streaming chat voice naudio


    【解决方案1】:

    接收者应使用BufferedWaveProvider,它允许您在音频数据到达时排队播放。

    【讨论】:

      猜你喜欢
      • 2014-02-23
      • 2014-11-03
      • 2010-12-04
      • 2012-07-29
      • 1970-01-01
      • 1970-01-01
      • 2015-02-12
      • 2018-11-09
      • 2019-06-29
      相关资源
      最近更新 更多