WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: cssyphus on December 05, 2021, 12:30:17 PM

Title: Detect audio output
Post by: cssyphus on December 05, 2021, 12:30:17 PM
Not an urgent need, but it would be nice to add this into a small app I use...

Is it poss to detect if there is any audio output currently happening on the system? All I need is a boolean Yes/No...

Windows has the "Volume Mixer" (with multiple ways to open it*) that displays a real-time volume meter... is there any way to tap into that (or any other Windows service that could be used) just to see if audio is currently playing on the system?

Any thoughts/ideas where to look?  I've searched this tech support forum and the KnowledgeDB, but didn't find anything. Maybe someone has an idea how this might be done?

* Right-clicking on the speaker icon in the SysTray, also can be launched from command line [ C:\Windows\System32\SndVol.exe ]
Title: Re: Detect audio output
Post by: td on December 05, 2021, 03:15:41 PM
Not sure that there is a method that doesn't involve some low level programming. Perhaps try a Web search using your search engine of choice.
Title: Re: Detect audio output
Post by: td on December 06, 2021, 08:07:57 AM
The WIL PlayMedia function does support querying specific device types' status. However, you would need to know the type of sound device you are targeting and not all devices support status commands. It would be more or less a trial and error process that may lead to frustration without satisfaction.
Title: Re: Detect audio output
Post by: cssyphus on December 06, 2021, 09:23:12 AM
Ah haaa... something to try. Thanks very much, Tony. I appreciate the info, and the feedback / expectation-management also. I'll give this a try, understanding that it may or may not work, and will advise my findings.
Title: Re: Detect audio output
Post by: cssyphus on December 18, 2021, 11:23:06 AM
For future curious, Rob Latour of Ottawa Canada indulged a recent request to modify his freeware app, SetVol, to report on the presence/absence of sound within a (user-provided) sampling period. If sound is discovered it reports back immediately, otherwise it waits out the sampling-period (default 5sec) before reporting "Sound not detected".

Example:

setvol listen 0.5 > issound.txt

SetVol's original raison-d'etre was to allow command-line control over audio output. I've been using it with WinBatch for years, works great.

Ye can finde it here:

https://www.rlatour.com/setvol/