C
C#2y ago
nut

Can someone please help me understand this StackOverflow answer?

I'm working with NAudio and am trying to get the full device name of a wavein device, but the device name is cut off at 32 characters. DirectSound lets me get the full name of the OUTPUT devices, but it doesnt even map properly. This stackoverflow post has the answer but im not smart enough to understand it https://stackoverflow.com/questions/1449162/get-the-full-name-of-a-wavein-device
Stack Overflow
Get the full name of a waveIn device
I have been using waveInGetDevCaps to get the name of waveIn devices, but the WAVEINCAPS structure only supports 31 characters plus a null, meaning that on my computer, the device names I get back ...
8 Replies
nut
nutOP2y ago
or does anyone have a better way i can get the full name of wave devices (both in and out)? all i have is their device number their guids just dont match up right why has nobody worked with sound in c# since 2012? every post i find is from 2012, completely outdated and full of dead links, and assumes i already have a masters in comp sci using enumerators doesnt work if you change the default audio device, the enumerator order stays the same but the wavein doesnt
nut
nutOP2y ago
nut
nutOP2y ago
no its the other way around; wavein changes i could look for the wavein device with a matching name but then comes this issue
nut
nutOP2y ago
nut
nutOP2y ago
two devices can have the same name
nut
nutOP2y ago
device 0 and device 3 have the same name
nut
nutOP2y ago
and changing the default device messes up the mapping
nut
nutOP2y ago
i think i figured out how the mapping works?
//fix mapping
var outputDevices = enumerator.EnumerateAudioEndPoints(DataFlow.Render, DeviceState.Active).ToList();
var defaultOutputDevice = enumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Console);
int defaultOutputIndex = outputDevices.FindIndex(delegate (MMDevice dev)
{
return dev.ID == defaultOutputDevice.ID;
});
outputDevices.RemoveAt(defaultOutputIndex);
outputDevices.Insert(0, defaultOutputDevice);
//fix mapping
var outputDevices = enumerator.EnumerateAudioEndPoints(DataFlow.Render, DeviceState.Active).ToList();
var defaultOutputDevice = enumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Console);
int defaultOutputIndex = outputDevices.FindIndex(delegate (MMDevice dev)
{
return dev.ID == defaultOutputDevice.ID;
});
outputDevices.RemoveAt(defaultOutputIndex);
outputDevices.Insert(0, defaultOutputDevice);
same for input devices solved
Want results from more Discord servers?
Add your server