1

我对NAudio图书馆非常陌生,并且开发了音频类型的文件我有疑问,我们如何从混音器的每个通道获取音频输入,使用 USB 音频接口连接到 PC(支持 ASIO),所以这个混音器支持 8 通道音频输入。

应用的思路是这样的

  • 当用户按下通道 1 按钮时,它将获得通道 1 输入以捕获该特定通道上扬声器的声音

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

所以我只是想知道我应该使用哪个库类,有没有针对这种场景的源代码示例或最佳实践(我正在使用 C# 进行开发)

谢谢你

4

1 回答 1

1

尝试使用此代码:

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


}

}

结果如下:

在此处输入图像描述

于 2016-11-12T08:12:15.910 回答