When it became increasingly clear that running in-person workshops would not be possible for the foreseeable future, the XDI team, which I am a part of, started to work on online versions of our Adobe XD workshops for beginners and advanced users. The resulting workshops are a nice mix of tutorial-style explanation parts and hands-on exercises in XD. One small but crucial element to the whole experience is music. Music is playing while people are waiting for the workshop sessions to start, but also throughout the sessions when everyone is busy designing and prototyping with the software.
After my first online workshop, a little detail surfaced: In the workshop, I started and stopped the music with the default play button on the Touch Bar of my Macbook Pro. This resulted in the Music App (the software formerly known as iTunes) starting playback at full volume and stopping abruptly, however. Wouldn’t it be much nicer to be able to fade the music in and out? At least this would make for a much smoother experience for the participants. I surfed the World Wide Web for a solution and indeed found one that would work without the need for an audio mixer.
With the help of Automator, we can smoothly fade music in and out and even control this behavior via a keyboard shortcut or the Touch Bar (if you happen to have one). Here is how it works:
Step 1: Set up an Automator Workflow
First, open Automator and create a new “Quick Action”.

Configure the workflow so that it doesn’t receive any input, select an appropriate icon, and pick a color. This will also be the color of the button in the Touch Bar, so pick a bright color that will help you find the button more easily when you are sweating like hell in the workshop.

Now, find “Run Apple Script” in the list of actions and double-click the action so that it appears in the window on the right.

Copy and paste the following code into the textarea, which I found in an answer on StackExchange:
set current_application to (path to frontmost application as Unicode text)
tell application "System Events"
if process "Music" exists then
tell application "Music"
set current_volume to the sound volume
set del to 3 / current_volume
if (player state is playing) then
repeat
repeat with i from current_volume to 0 by -1
set the sound volume to i
delay del
end repeat
pause
set the sound volume to current_volume
exit repeat
end repeat
else
set the sound volume to 0
play
repeat with j from 0 to current_volume by 1
set the sound volume to j
delay del
end repeat
end if
end tell
tell application current_application
activate
end tell
end if
end tell
Save your Quick Action under a recognizable name like “Fade-In-Out-Music”. I am sure you will find an even better name than this. 😉
Now, open Music app – notice that the Music app has to be running for this whole workflow to work! – and then try if the Automator script works by hitting the play button. In Automator, that is.
The music should now fade in and out within 3 seconds. If you want to change the speed, you can change the number in line 6 (set del to 3 / current_volume
) in the code snippet above.
Step 2: Define a Touch Bar Action
The last step is to configure the Touch Bar so that you can quickly fade your music in and out.
Choose Apple menu 🍏 > System Preferences, click Keyboard, then select Keyboard, and click Customize Control Strip. Look for the Quick Actions button and drag it into one of the spots in the control strip. You could, for example, replace Siri.


Click Done
to save your settings.
Perfect! Now, once you touch the Quick Actions button, you can hit the new green button to fade your music in and out. Note that you might have to confirm once that Automator should be allowed to control the Music app.
In case you don’t have a Touch Bar, you can also define a shortcut in System Preferences > Keyboard > Shortcuts > Services:

And that’s it. You are now able to fade music in and out like a pro in your workshops or other online sessions. Do you know of any other nice tricks for doing live demos or online workshops? Let me know.
-
This is the 52nd post of my 100 days of writing series. You can find a list of all posts here.
~