2016-09-30 107 views
0

我很新的NAudio图书馆和音频输入通道,并制定音频文件的类型我有疑问,我们如何从调音台使用USB音频接口的每个通道获取音频输入连接到PC(支持ASIO),所以这个混频器支持音频输入8通道。获取从搅拌机n音讯C#

申请的构思是这样

  • 当在信道1按钮用户按下它会得到的信道1级的输入捕获说话人的声音在那个特定的信道

  • 当用户按通道2按钮它将从通道2获得语音(作为单独通道)

所以我只是想知道这库班我应该使用,有没有源代码示例或为这种情况的最佳实践(我使用C#开发)

谢谢

回答

0

尝试使用此代码:

using System; 
using System.Windows.Forms; 
using NAudio.Wave; 

namespace NaudioAsioTest 
{ 
    public partial class Form1 : Form 
    { 
     public Form1() 
     { 
      InitializeComponent(); 
      InitialiseAsioControls(); 
     } 

    private void InitialiseAsioControls() 
    { 
     // Just fill the comboBox AsioDriver with available driver names 
     var asioDriverNames = AsioOut.GetDriverNames(); 
     foreach (string driverName in asioDriverNames) 
     { 
      comboBoxAsioDriver.Items.Add(driverName); 
     } 
     //comboBoxAsioDriver.SelectedIndex = 0; 
    } 
    public string SelectedDeviceName { get { return (string)comboBoxAsioDriver.SelectedItem; } } 

    private void OnButtonControlPanelClick(object sender, EventArgs args) 
    { 
     try 
     { 
      using (var asio = new AsioOut(SelectedDeviceName)) 
      { 
       asio.ShowControlPanel(); 
      } 
     } 
     catch (Exception e) 
     { 
      MessageBox.Show(e.Message); 
     } 
    } 

    private void comboBoxAsioDriver_SelectedIndexChanged(object sender, EventArgs e) 
    { 
     try 
     { 
      using (var asio = new AsioOut(SelectedDeviceName)) 
      { 
       //asio.ShowControlPanel(); 
       int nrOfChannelOUTDevices = asio.DriverOutputChannelCount; 
       int nrOfChannelINDevices = asio.DriverInputChannelCount; 
       listBoxInputs.Items.Clear(); 
       listBoxOutputs.Items.Clear(); 
       for (int i = 0; i < nrOfChannelOUTDevices; i++) 
       { 
        string name = asio.AsioInputChannelName(i); 
        listBoxInputs.Items.Add(name); 
       } 

       for (int i = 0; i < nrOfChannelINDevices; i++) 
       { 
        string name = asio.AsioOutputChannelName(i); 
        listBoxOutputs.Items.Add(name); 
       } 
      } 
     } 
     catch (Exception ex) 
     { 
      MessageBox.Show(ex.Message); 
     } 
    } 


} 

}

结果如下:

enter image description here