Check if an application emits sound

2019-06-14 04:27发布

today I am here to ask you how you can "understand" if a given application is emitting sound. On windows 7 and 8 I use the following code (library CSCore Audio )

[...]
        AudioSessionManager2 sessionManager = GetDefaultAudioSessionManager2(DataFlow.Render);
        AudioSessionEnumerator sessionEnumerator = sessionManager.GetSessionEnumerator();

                AudioSessionControl2 sessionControl;
                foreach (AudioSessionControl session in sessionEnumerator)
                {
                    sessionControl = session.QueryInterface<AudioSessionControl2>();
                    if (sessionControl.Process.MainWindowTitle.StartsWith("my_test"))
                    {
                        sessione = sessionControl;
                        audio = session.QueryInterface<AudioMeterInformation>();
                        break;
                    }
                }

        control.Text = sessione.Process.MainWindowTitle + "[" + audio.PeakValue + "]";
    [...]

It works well, but not on Windows XP. Is there a way "universal" to do it? If there would be a way to do this in Java would be even better, so work on Linux (which for the moment I do not need, but maybe in the future)

1条回答
beautiful°
2楼-- · 2019-06-14 04:53

I am sorry, but Windows XP does not querying the audio peak of a process. You can also take a look at the Windows XP Audio Mixer. There is no peak displayed.

查看更多
登录 后发表回答