1

Can NAudio be used for setting the volume level of a specific application? { Over Windows 7 }

I've found this thread, referring to the issue, suggesting to self-implement the required solution over WASAPI, but I'd prefer a simpler solution, optimally - using NAudio wrappers for this, if there are such.

I have also found this WASAPI-based solution, which (for me, over 32-bit Windows 7 Professional) does not enumerate all audio-playing applications, and is hence - not applicable.

What I'm actually trying to accomplish: I'm using a commercial application playing a long sequence of audio files, of various qualities and audio-levels. I'd like to apply AGC (Automatic Gain Control, i.e. volume-level normalization) to that application, to at least "blur" (if not eliminate altogether) the difference in volume-level between played tracks.

As a 1st phase, I could assume that this application is the only one producing audio on system, and handle only Windows' main audio-path samples, but I do not know how to accomplish that either. Can NAudio interfere with the audio-path, modifying audio-samples (i.e. amplifying them) before they reach the speakers jack?

Please note that simply changing Windows main volume gauge won't do the trick, as it won't be reflected in the amplitude of the samples captured by NAudio/WASAPI Loopback.

NAudio would be the preferred approach, but is NOT a must.

Community
  • 1
  • 1
Bliss
  • 416
  • 1
  • 5
  • 18
  • Do you measure loudness capturing it back? Why can't you normalize it just before sending to output device? This makes much more sense taking into consideration "trying to accomplish" section. – Roman R. Jan 06 '14 at 23:27
  • How can I normalize audio *non-produced by me* (but rather by an external, off-the-shelf application) before it is being sent to the output device? – Bliss Jan 07 '14 at 16:48
  • There was no mention that the application is not yours, actually. Even though might me assumed, it's important detail. Feeding to real or virtual audio output device seems to be inevitable then. – Roman R. Jan 07 '14 at 17:11
  • The previous phrase was "I'm **using** an application playing a long sequence...". I've re-phrased it, for this misunderstanding not to re-occur. Anyway, thanks for the good will to assist. – Bliss Jan 07 '14 at 17:40
  • To control an applications volume... take a look at this: http://stackoverflow.com/questions/21200825/getting-individual-windows-application-current-volume-output-level-as-visualized?lq=1 – Florian Apr 05 '14 at 21:26

1 Answers1

3

NAudio does have wrappers for many parts of the Windows Core Audio API, but does not include the [IAudioSessionEnumerator][1] that Roman mentions in the answer you linked to. It seems this part of the API was introduced with Windows 7.

So I'm afraid NAudio can't help you here, and you'd need to port Roman's code to C#, which would require you to create interop wrappers for IAudioSessionEnumerator and related interfaces such as IAudioSessionManager and IAudioSessionControl.

Community
  • 1
  • 1
Mark Heath
  • 45,254
  • 26
  • 128
  • 188
  • Thanks Mark for your answer. Actually, I already tried the snippet Roman suggests [on his answer](http://stackoverflow.com/a/17387658/7532), but it does not work (for me, over a 32-bit Windows 7 Professional), as it does not enumerate all audio-playing applications on system. – Bliss Jan 03 '14 at 09:40
  • Mark, I'd appreciate it if you take a look at the new "**What I'm actually trying to accomplish**" paragraph, added to the question. – Bliss Jan 05 '14 at 08:57