I'm trying to capture the sound of MIC (DataFlow.Capture), but AudioMeterInformation.PeakValues only works if sound properties is open (control mmsys.cpl sounds)
Working example
But when i close sound properties..
My code
private void calculateChannels(Object source, ElapsedEventArgs e)
{
dev = devEnum.GetDefaultAudioEndpoint(DataFlow.Capture, Role.Multimedia);
try
{
double currentLeftChannel = 100 - (dev.AudioMeterInformation.PeakValues[0] * 100);
double currentRightChannel = 100 - (dev.AudioMeterInformation.PeakValues[1] * 100);
// this function just "smooth" the progress bar
this.leftChannel = round(this.leftChannel, currentLeftChannel);
this.rightChannel = round(this.rightChannel, currentRightChannel);
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}
I'm used (-100) on the result because my progress bar is inverted (black colors are actually the progress)
DataFlow.Render is working fine, even without properties open.
How can I fix this?