I'm trying to write a little background program that stops music playing Winamp when another program plays sounds. The part about the accessing Winamp through Java is already solved now I need a way to detect which program plays the currently played sound (probably I want to allow some programs to play their sound without stopping my music). Although I'm doing this in Java (+ the winapi) everything in any language would help.
[edit] as I just got the first downvote on my first question here is some more detail: I already figured out how to use the winapi (but I don't know it) and capture things like volume levels and stuff. What still makes trouble is the mentioned detection of the origin of a sound that is played and aslo which program plays sounds. Is there anything in the winapi that could help me to do this?[/edit]
As Deanna mentioned, you can enumerate audio playback sessions just like Volume Mixer application (started from system tray icon) does and obtain per-session meters indicating session status.
You can find a C++ application that does it in this answer: Peak meters for individual programs on Windows 7. The meters are per-session and an audio-enabled application might have one or more sessions in it, but eventually as long as you enumerate them, you can figure out if there is any active playback there.
I believe the Windows Core Audio API in Vista+ allows you to get the VU levels for each application (After all, the mixer shows it). This should allow you to turn down one application when another is playing, etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With