我是NAudio
库的新手以及开发音频类型的文件我有疑问我们如何从混音器的每个通道获取音频输入使用USB音频接口连接到PC(支持ASIO),所以这款调音台支持8声道音频输入。
应用的想法是这样的
当用户按下通道1按钮时,它将获得通道1输入以捕获该特定通道上的扬声器的声音
当用户按下频道2按钮时,它将从频道2获取语音(作为单独的频道)
所以我只想知道我应该使用哪个库类,是否有任何源代码示例或最佳实践用于此类场景(我使用C#开发)
谢谢
答案 0 :(得分: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);
}
}
}
}
结果如下: