C# NAudio 如何force/hardcode 音频设备(声卡)?

C# NAudio How to force/hardcode audio device (soundcard)?

我试图将音频设备强行插入 NAudio 播放器,但一直无法解决。目前,我继承的代码使用组合框 select 设备并使用它,但我想将其硬编码。

从下面注释行中的代码中,您可以看到我已经尝试过的内容,但它们都显示错误,所以我不知何故无法正确处理。

谁能帮我解决这个问题?

我想要的结果是 'force' NAudio 使用 "Speakers (High Definition Audio Device)" 音频设备而不是 select 从组合框中输入它。

谢谢

NAudio.CoreAudioApi.MMDeviceEnumerator enumerator = new NAudio.CoreAudioApi.MMDeviceEnumerator();
var devices = enumerator.EnumerateAudioEndPoints(NAudio.CoreAudioApi.DataFlow.All, NAudio.CoreAudioApi.DeviceState.Active);
Globals.NewDevice = devices.ToString();
comboBox1.Items.AddRange(devices.ToArray());



if (comboBox1.SelectedItem != null)
    {
    var device = (NAudio.CoreAudioApi.MMDevice)comboBox1.SelectedItem;
    //var device = (NAudio.CoreAudioApi.MMDevice.Equals.("Speakers (High Definition Audio Device)"); 
    //var device = (NAudio.CoreAudioApi.MMDevice)."Speakers (High Definition Audio Device)";
    //var device = (NAudio.CoreAudioApi.MMDevice)"Speakers (High Definition Audio Device)";
    //var device = NAudio.CoreAudioApi.MMDevice."Speakers (High Definition Audio Device)";
    //var device = (NAudio.CoreAudioApi.MMDevice.ReferenceEquals."Speakers (High Definition Audio Device)");
}

事实证明我可以这样做:

comboBox1.Text = "Speakers (High Definition Audio Device)";

感谢投反对票...