Get default output audio device with NAudio

心已入冬 提交于 2019-12-06 05:57:16

You are mixing two completely different audio APIs here. MMDeviceEnumerator is part of WASAPI, the new audio API introduced in WindowsVista, and WaveOut.DeviceCount uses the old Windows audio APIs.

To use WASAPI to get the default audio device, you use code like this:

var enumerator = new MMDeviceEnumerator();
enumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Console);

There are actually three different types of default audio output device, depending on the purpose (role):

    /// <summary>
    /// Games, system notification sounds, and voice commands.
    /// </summary>
    Console,

    /// <summary>
    /// Music, movies, narration, and live music recording
    /// </summary>
    Multimedia,

    /// <summary>
    /// Voice communications (talking to another person).
    /// </summary>
    Communications,
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!