I am calculating RMS from WasapiLoopbackCapture and when using 5.1 speakers, it gives me RMS values between 0 and 2, (with headphones, it gives RMS up to 130). How can I get only audio data from two channels?
I tried to set number of channels to 2:
MMDevice captureDevice = MMDeviceEnumerator.DefaultAudioEndpoint(DataFlow.Render, Role.Console);
WaveFormat deviceFormat = captureDevice.DeviceFormat;
_capture = new WasapiLoopbackCapture(100, new WaveFormat(deviceFormat.SampleRate, deviceFormat.BitsPerSample, deviceFormat.Channels <= 2 ? deviceFormat.Channels : 2));
which works for only for headphones, with speakers it crashes. Then I have this:
_capture.Initialize();
_soundInSource = new SoundInSource(_capture) { FillWithZeros = false };
_stream = _soundInSource.WaveFormat.SampleRate == 44100
? new SingleBlockNotificationStream(_soundInSource.ToStereo().ToSampleSource())
: new SingleBlockNotificationStream(_soundInSource.ChangeSampleRate(44100).ToStereo().ToSampleSource());
_soundInSource.DataAvailable += OnSoundDataAvailable;
_capture.Start();
but nor that .ToStereo() helps with 6 channels.
Can you please help me? Btw. when I set number of outputs to 2 in Realtek, it works ok too. Thank you.