7

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]

OneWithAHat
  • 81
  • 1
  • 3
  • This question may be a *big* overgeneralized and vague but I don't think that it deserves a downvote. I don't have an answer for you, having never dabbled in the sound APIs but you may want to look into DirectSound on MSDN. – Nik Bougalis Feb 07 '13 at 21:48
  • Why is "i want a list of all programs currently playing sound" overgeneralized? And as far as the feature list of DirectSound goes it is used to play sound or ad effects to them. There is nothing about reading volumes. – OneWithAHat Feb 07 '13 at 21:54
  • Oops - I meant a *bit* not a *big*. – Nik Bougalis Feb 07 '13 at 21:55

2 Answers2

4

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.

Community
  • 1
  • 1
Roman R.
  • 68,205
  • 6
  • 94
  • 158
3

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.

Deanna
  • 23,876
  • 7
  • 71
  • 156