I want to get the default output audio device (i.e. my speakers) using NAudio, to get the master sound volume as in this question.
I am trying to use MMDeviceEnumerator.GetDevice()
, but the id it takes is a string, not the device number. Here's the code I've written so far:
var enumerator = new MMDeviceEnumerator();
for (int i = 0; i < WaveOut.DeviceCount; i++)
{
var cap = WaveOut.GetCapabilities(i);
Console.WriteLine("{0}: {1}", i, cap.ProductName);
var device = enumerator.GetDevice(???);
}
Console.WriteLine();
Console.ReadLine();
I've tried passing the various Guids from the capabilities, as well as the device id in string format, to GetDevice()
but none of them work.
How do I get the default device?