Audio Output Trigger?

Is there a way for KM to sense audio output? Or a clever workaround with additional tools?

Use case: workstation has amplified speakers that auto-sleep after 30 mins without audio output. They wake up slowly, and sometimes have to be power cycled to wake up. Easy solution is play a sound every 25 minutes or so, but that intereferes with work.

Ideally, I'd like to have KM run a clock from last audio output, and play a sound after 25 minutes of silence. Any audio output would reset the countdown.

This all depends on sensing the audio output and using it as a trigger for the countdown. Audio Output Changed senses the audio output device, but AFAIK doesn't know whether there is audio playing or not.

Suggestions?

If you play a second of silence (ie, an audio file with essentially minimal/no actually noise in it), is that enough to "wake them up"? If so, doing that every 25 minutes should be of limited interference.

You can often find silent audio tracks as ring tones.

Thanks for the suggestion. Unfortunately, it takes a fairly loud sound to register with the speakers.

I take it that at this time, there is no way to use Mac audio output as a KM trigger? Is there perhaps an audio app that can perceive audio output and could pass a message via Applescript?

Grasping at straws here.

You could use AppleScript with a Keyboard Maestro Timed Trigger to periodically play one of the built-in sounds. This example is playing the Empty Trash sound, but a file path to a different sound file could be used.

image

The code:

do shell script "afplay '/System/Library/Components/CoreAudio.component/Contents/SharedSupport/SystemSounds/dock/drag to trash.aif'"

There are apps that display the sound level, so presumably it is possible to get that information, but I don't know of any obvious way to do it or any specific tool that might work.

Maybe just have your Mac pretend to be a grandfather clock and play chimes every quarter of an hour.

Thanks; that was my plan, I just wanted to see if there was a way to "listen" for Audio Output so it could trigger a countdown.

An audio engineer pal gave me a solution. A 10hz wav file that will wake up the speakers, but it's below the range of human hearing. I'm going to give that a try. Thanks for the suggestions.

1 Like

Hey @anamorph ,

did the solution with the 10hz work for you?

Thanks for a quick massage.

Mathias

Sorta The 10hz keeps the speakers awake, and it's inaudible, but I'm still looking for a playback method that doesn't create an audible click when it activates.

were you able to "listen" for audio output?

I want to use that as a trigger. Basically want to bring app to front that produces a sound.

Thanks in anticipation

Never found it, sorry.

I've achieved exactly what you are trying to do! (I first did it about ten years ago!) But I had to get a program called Audio Hijack. I'm attaching a screenshot of the important part of Audio Hijack, so you can get an idea of how to do it. Look in the dialog box below. Do you see the checkbox that says "start new file after 2 seconds of silence?" And do you see the silence decibel threshold meter? These are the things you need to set up. And then you have to set up a KM macro that triggers whenever a new file occurs in the folder where these audio files go. That's right! This works as an actual KM trigger, there's no polling required! I don't remember what the latency was between sound detection and trigger, but it wasn't very long. (Maybe about 1 second?) P.S. Audio Hijack lets you pick which program you want to use as your sound source. I'm not sure if that's a specific app for you, or if it's macOS in general. You may have to figure that out yourself.

1 Like

Thanks for this. I have Audio Hijack, but I've only scratched the surface. I'll give this a try.