Windows 8.1 WPF application mixerSetControlDetails returns MMSYSERR_ERROR
Edit
After modifying the NAudio source code and doing a little debugging, I found that the function mixerSetControlDetails
called when setting the property Value
returns MMSYSERR_ERROR
.
Is there a way to get more information about why mixerSetControlDetails
it failed?
I am also open to other ways to accomplish the same in C #.
Original
I have some code that calculates the energy in a voice and sets the microphone boost level according to this calculated value using NAudio. I have no problem reading audio samples, but when I try to adjust the microphone gain, the program gets stuck.
I have checked the problem on Windows 7, 8 and 8.1. The problem only occurs on Windows 8.1. Interestingly, when I run the program in a Windows 8.1 virtual machine, it works as expected. Could this be a permission issue?
Here is the code to set the boost value
foreach (MixerControl mixerControl in MixerLine.Controls)
{
if (mixerControl.ControlType == MixerControlType.Volume)
{
UnsignedMixerControl volumeControl = (UnsignedMixerControl)mixerControl;
volumeControl.Value = (uint) value;
}
}
If MixerLine is created in advance using this code.
MixerLine = new MixerLine((IntPtr) deviceID, 0, MixerFlags.WaveIn);
source to share
The function seems to mixerSetControlDetails
return MMSYSERR_ERROR
randomly (at least I couldn't find a pattern). It actually sets a new value, just ignores the exception, or if it doesn't set a try, set the value again. The stuck behavior was about my program not related to this error.
source to share