Author Topic: Detect audio output  (Read 300 times)

cssyphus

  • Jr. Member
  • **
  • Posts: 74
  • Let's go Brandon
Detect audio output
« 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 ]
Is this a pandemic... or an IQ test? newz.icu

td

  • Tech Support
  • *****
  • Posts: 4064
    • WinBatch
Re: Detect audio output
« Reply #1 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.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

td

  • Tech Support
  • *****
  • Posts: 4064
    • WinBatch
Re: Detect audio output
« Reply #2 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.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

cssyphus

  • Jr. Member
  • **
  • Posts: 74
  • Let's go Brandon
Re: Detect audio output
« Reply #3 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.
Is this a pandemic... or an IQ test? newz.icu

cssyphus

  • Jr. Member
  • **
  • Posts: 74
  • Let's go Brandon
Re: Detect audio output
« Reply #4 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:

Code: [Select]
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/
Is this a pandemic... or an IQ test? newz.icu