You can use CSCore which allows you to get the peak of any applications and of the whole device. You can determine whether sound is getting played by checking that peak value. This is an example on how to get the peak of an application. And these are two examples how to get the peak of one particular device:
[TestMethod]
[TestCategory("CoreAudioAPI.Endpoint")]
public void CanGetAudioMeterInformationPeakValue()
{
using (var device = Utils.GetDefaultRenderDevice())
using (var meter = AudioMeterInformation.FromDevice(device))
{
Console.WriteLine(meter.PeakValue);
}
}
[TestMethod]
[TestCategory("CoreAudioAPI.Endpoint")]
public void CanGetAudioMeterInformationChannelsPeaks()
{
using (var device = Utils.GetDefaultRenderDevice())
using (var meter = AudioMeterInformation.FromDevice(device))
{
for (int i = 0; i < meter.MeteringChannelCount; i++)
{
Console.WriteLine(meter[i]);
}
}
}
Just check whether there is a peak bigger than zero or something like 0.05 (you may need to experiment with that). If the peak is bigger than a certain value, there is any application playing something.
Also take a look at this: http://cscore.codeplex.com/SourceControl/latest#CSCore.Test/CoreAudioAPI/EndpointTests.cs. To get get implementation of Utils.GetDefaultRendererDevice see take a look at this one: http://cscore.codeplex.com/SourceControl/latest#CSCore.Test/CoreAudioAPI/Utils.cs
The first example gets the average peak of all channel peaks and the second example gets the peaks of each channel of the output device.