1

I need to check if an app is making a certain sound. This app only produces a single specific sound, so a solution that simply checks if there's any sound whatsoever from the app will also work.

I don't need to find out which app makes a sound or anything like that. I know the app that should produce a sound and I know what sound it's going to be, I simply need to detect the exact time this sound is played.

The only solution I know of is to listen to the audio output for the whole OS and then detect my specific sound with some audio recognition software, but it won't work properly if there's music or a movie playing on the background, so it's not an option.

I need a solution to do it via WinAPI methods. The language isn't very important here - I can use C#, javascript, Python or another language. I just need to find out a general approach on how to extract sound produced by a specific application in Windows 7.

Victor Marchuk
  • 13,045
  • 12
  • 43
  • 67
  • 1
    I assume the downvote is because the question is vague and you have not provided any evidence you have done much to find an answer. Many of the answers here take a lot of time and people that help want you to spend some of your time trying to get answers. – Sam Hobbs Mar 01 '17 at 13:03
  • Maybe with the Windows Speech Recognition engine? https://msdn.microsoft.com/en-us/library/jj127860.aspx with your sound (wav) as an input grammar: https://msdn.microsoft.com/en-us/library/jj127911.aspx – Simon Mourier Mar 02 '17 at 08:02
  • I guess that the check is only when the app is actually "singing" (using _the present continuous tense_ has a real meaning), and not let's say if the app played the sound or is able to play a sound (these 2 situations don't make too much sense). So if at a point in time, a sound is heard on the speakers, you'd like to identify the app (process ID, window) that produces it (this would be useful when having multiple web browsers with multiple tabs open, and in one of them some flash content automatically starts playing). – CristiFati Mar 02 '17 at 15:27
  • @CristiFati Well, actually, I know the app that should produce a sound and I know what sound it's going to be, I simply need to detect the exact time this sound is played. – Victor Marchuk Mar 06 '17 at 09:40

2 Answers2

0

The general approach here is to trace calls from a given process to OS to play audio. These calls are more commonly known as "system calls".

This will show only direct attempts by a process to produce sound.

The only hardest part here is to identify all the system calls, that play sound in windows.

This question has some answers on how to trace system calls on Windows

Community
  • 1
  • 1
Tair
  • 3,779
  • 2
  • 20
  • 33
0

Have you looked at SO answer on similar topic with a bunch of useful .Net wrappers for IAudioSessionManager2 and related API: Controlling Application's Volume: By Process-ID

I think that general approach of

  1. Finding IAudioSession by process name
  2. Subscribing to its events via IAudioSessionEvents
  3. Listening to the OnStateChanged event

should do it for you.

And don't forget that you should pump Windows messages which might require some explicit code in non-UI applications. In UI applications this is what Application.Run does internally anyway.

Community
  • 1
  • 1
SergGr
  • 23,570
  • 2
  • 30
  • 51