Question

Using WASAPI, I could control system volume. I wonder, I can control the specific application's volume level programmatically. (of course, this is after windows7 only) is it possible?

Was it helpful?

Solution

You can control application (session) volume, just like standard Volume Mixer does it. Read up on this in Session Volume Controls where it is explained pretty detailed:

WASAPI clients can individually control the volume level of each audio session. [...]

To support this behavior, WASAPI implements the ISimpleAudioVolume interface. When the user moves the application slider, the application calls the ISimpleAudioVolume::SetMasterVolume method to adjust the session volume level accordingly. Sndvol monitors volume changes made through this method and reflects the changes in the volume sliders that it displays.

To discover running sessions, you can use IAudioSessionEnumerator interface. Have a look at this code snippet/application implementing the discovery: AudioSessionVolumeNotification.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top