简体   繁体   中英

Reading the value of the volume in the windows mixer

I am creating a program for me and my friends to use. I want to make a program that will take control over the Windows Audio Mixer. I am using C#

I already have and idea on how to control the volume. But I would like some tips on controlling each application's individual volume level inside the mixer.

The main question is (a bit interesting) : How can I read the value of the volume inside each application's individual meter? In other words, I want to read/get the value of the green and grey bar inside the volume bar/meter of the application. I have included a picture that shows what I mean The Windows Audio Mixer

Each item in the audio mixer (Sndvol) is a single audio session. Here's a great read from MSDN about how the sessions work in the background.

With that out of the way, you'll need to subscribe to audio session events to be notified of the following events:

  • The master volume level or muting state of the session submix has changed.
  • The volume level of one or more channels of the session submix has changed.
  • The session has been disconnected.
  • The activity state of the session has changed to active, inactive, or expired.
  • The session has been assigned a new grouping parameter.
  • A user-interface property of the session (icon or display name) has changed.

Directly copied from here .

Core Audio APIs are part of the Windows SDK, so you need to use P/Invoke to actually call that code. I think there are some .NET wrappers for the Core Audio APIs, and it should be easy to find them with a simple search.

Edit: Here's a good start for what you're trying to do. It includes code for managing the session sound. I didn't give it a thorough look, so I'm not sure if it has the session events implemented.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM