naudio / NAudio

Audio and MIDI library for .NET
MIT License
5.58k stars 1.1k forks source link

Detecting sound, MasterPeakValue and Windows default input #1188

Open rserodioalbuquerque opened 1 month ago

rserodioalbuquerque commented 1 month ago

Hi Everyone,

I'm writing some pieces of code to detect whether or not there is sound from a microphone device. I came up with a basic working solution that consists of

  1. WaveInEvent.StartRecording()
  2. Sampling the data and simply checking for device.AudioMeterInformation.MasterPeakValue

I found people reporting issues around MasterPeakValue being 0 unless they open "Recording Devices",

But after some testing I found that MasterPeakValue is reported correctly for any device, but it needs to be selected in Windows input manager as DEFAULT, otherwise it's 0.

capture

Is this a bug or should I be using a different approach for my use case? I don't want to be constrained by the default windows input.

Thanks in advance