How to get list of available devices using Silk.NET.OpenAL? #573
-
I want to detect microphone and speakers connected to my windows running dotnet5, I went through this example but it uses default connected device, I want to enumerate though list of devices and play the audio if any examples are available please suggest or any API documentation for getting list of available connected devices? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Ah apologies, I had an answer written for this the day you opened this but apparently never hit send. You'll have to use ALContext and its enumaration extensions (which are not guaranteed to be available as they are extensions!) These are in the Silk.NET.OpenAL.Extensions.Enumeration package. Using this package, you can get a string list containing all available device specifiers. It'll look something like this: using var alc = ALContext.GetApi();
string deviceSpecifier = "";
if (alc.IsExtensionPresent(null, "ALC_ENUMERATION_EXT"))
{
using var enumeration = alc.GetExtension<Enumeration>();
foreach (var device in enumeration.GetStringList(null, GetEnumerationContextStringList.DeviceSpecifiers))
{
Console.WriteLine($"Got device \"{device}\"");
deviceSpecifier = device;
}
}
var device = alc.OpenDevice(deviceSpecifier);
// ... |
Beta Was this translation helpful? Give feedback.
Ah apologies, I had an answer written for this the day you opened this but apparently never hit send.
You'll have to use ALContext and its enumaration extensions (which are not guaranteed to be available as they are extensions!)
These are in the Silk.NET.OpenAL.Extensions.Enumeration package. Using this package, you can get a string list containing all available device specifiers. It'll look something like this: