简体   繁体   English

从调音台NAudio C#获取音频输入通道

[英]Get audio input channel from mixer NAudio C#

I am very New to NAudio Library and as well as develop audio type of file I have question that how do we get audio input from each channel of Mixer use USB Audio Interface connect to PC (Support ASIO), So this mixer support 8 Channel of Audio Input. 我是NAudio Library的NAudio ,并且正在开发音频类型的文件,我想知道如何从Mixer的每个通道获取音频输入,如何使用USB音频接口连接到PC(支持ASIO),因此此Mixer支持8通道的音频输入。

The idea of application is like this 应用的想法是这样的

  • when user press on channel 1 button it will get channel 1 input to capture the voice of speaker on that particular channel 当用户按下通道1的按钮时,它将获得通道1的输入以捕获该特定通道上扬声器的声音

  • when user press channel 2 button it will get voice from channel 2 (as separate Channel) 当用户按下通道2按钮时,它将从通道2获得声音(作为单独的通道)

So I just wondering which library class I should use and is there any source code example or best practice for this kind of scenario (I am using C# to Develop) 所以我只是想知道应该使用哪个库类,并且在这种情况下是否有任何源代码示例或最佳实践(我正在使用C#进行开发)

Thank You 谢谢

Try to use this code: 尝试使用以下代码:

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


}

} }

The result is the following: 结果如下:

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM