Modify cue templates via Applescript

43 views
Skip to first unread message

Roly Botha

unread,
Nov 28, 2025, 4:07:27 PM (2 days ago) Nov 28
to QLab
Hello pals

Is anyone aware of a way to modify cue templates using AppleScript? Specifically looking to target the output patch of audio cue templates, as part of a larger script that does a handful of things. Can’t find anything in the dictionary or with a bit of UI element digging but as ever very willing to believe I’m missing something obvious!

Thanks!
--
Roly Botha (they/them)

website | Spotlight | theatre company

Though I sometimes send emails at unusual times, I never expect anyone to respond outside of their own working hours.

micpool

unread,
Nov 28, 2025, 8:43:45 PM (2 days ago) Nov 28
to QLab
There are no AppleScript hooks to templates. The UI script is probably something like :

an item of menu 1 of pop up button 1 of group 1 of splittergroup 1 of  first window whose title contains "settings" 

But that's only going to work once you have used UI scripting to get the correct tab in the correct template displayed  and to get a list of all the output patches available in the pop up menu.

I think the short answer is..... whatever you are trying to achieve, there is probably a better, simpler and more reliable way of doing it.

 As templates are only applied to cues when they are created, isn't it much easier to just have a 'make a cue script'  that sets the parameters of a new cue to a template contained in the variables of the script. e.g.


set thePatch to 3

tell application id "com.figure53.QLab.5" to tell front workspace

make type "audio" -- set audio cue template in settings to all parameters that are not modified by this script

set theCue to the last item of (selected as list)

set the audio output patch number of theCue to thePatch

end tell


You can expand the script to allow a choice of patch to be made from a list when the script is run, or to set the patch based on the value of some other parameter in the QLab workspace.

Ot you can include more parameters in the script and have multiple make an audio cue scripts on hotkeys which would simulate multiple templates e.g 

cmd-2 standard keyboard shortcue to make an audio cue from settings template
2 triggers a script to make an audio cue with parameters contained in that script (audio template 2)
⇧2 triggers another script to make an audio cue with parameters contained in that script (audio template 3)
⌃2 triggers another script to make an audio cue with parameters contained in that script (audio template 4)
⇧⌃2 triggers another script to make an audio cue with parameters contained in that script (audio template 5)
⌥2  triggers another script to make an audio cue with parameters contained in that script (audio template 6)
⇧⌥2  triggers another script to make an audio cue with parameters contained in that script (audio template 7)
⌃⌥2 triggers another script to make an audio cue with parameters contained in that script (audio template 8)
⇧⌃⌥2 triggers another script to make an audio cue with parameters contained in that script (audio template 9)

(Or put start cues for all those scripts in a cart)


You could also make as many template cues as you want as normal cues with a prefix to identify them e.g. T1, T2 etc.

You can then make scripts to make a new cue, copying any parameters you want from the template cue e.g

tell application id "com.figure53.QLab.5" to tell front workspace

--template cue 1

set theTempCue to cue "T1"

set theTemplate to properties of theTempCue

make type "audio" -- set audio cue template in settings to all parameters that are not modified by this script

set theCue to last item of (selected as list)

--delete any of the parameters you don't want to copy from the template cue by deleting lines of code below

set the audio output patch id of theCue to the audio output patch id of theTemplate

set the q name of theCue to ("Based on " & the q list name of theTemplate)

set the infinite loop of theCue to the infinite loop of theTemplate

--add any other parameters you want to copy from the template cue to the newly created cue here

end tell



Best

Mic

Paul

unread,
Nov 29, 2025, 11:59:52 AM (16 hours ago) Nov 29
to QLab
You can't access or modify templates using AppleScript.
Not really sure the question makes sense. If you are creating cues with a script, then you can set all the parameters in the script. Break it into two parts, one for your common "template"  bits and the second for the cue specific bits.  If you put this in a couple of handlers, the code can look quite clean.
Here is a example, which creates audio cues based on wav files in a user specified folder; its rather contrived but it should give you the idea (the majority  of this script is setup just to make a working script)

-- make audio cues from files with templates


tell application id "com.figure53.QLab.5" to tell front workspace

-- ask user for folder where audio files

set myfolder to POSIX path of (choose folder with prompt "Choose folder with audio files" default location (path to music folder))

-- get list of wav files in that folder (we need quoted form of to handle folder names with spaces)

set myAudioFiles to (every paragraph of (do shell script "ls " & (quoted form of myfolder) & "/*.wav")) as list

-- set the start cue number

set cueNum to 6


-- make audio cues for every wav file in the user specified folder

repeat with myfilepath in myAudioFiles

if myfilepath contains "gone" then -- contrived example


-- make cue using template 2 handler; cue specific parameters are file target, main level and cue number

set audioCue to my makeAudioTemplate2(myfilepath, -32, cueNum)


else

set audioCue to my makeAudioTemplate1(myfilepath, -28, cueNum)

end if

set cueNum to cueNum + 1

end repeat

end tell


on makeAudioTemplate1(fileTarget, mainlevel, cueNum)

-- for "template 1" we set the prefix to B, the audio patch to 2 and some levels

-- this is just a contrieved example - adjust as needed

set audioPatchNum to 1

set prefix to "B"

set template1levels to {0, 0, -18, -21}

return my makeAudio(fileTarget, mainlevel, cueNum, prefix, audioPatchNum, template1levels)

end makeAudioTemplate1


on makeAudioTemplate2(fileTarget, mainlevel, cueNum)

return my makeAudio(fileTarget, mainlevel, cueNum, "C", 2, {-6, -18, 0, -6})

end makeAudioTemplate2


on makeAudio(fileTarget, mainlevel, cueNum, prefix, patchnum, mylevels)

tell application id "com.figure53.QLab.5" to tell front workspace

make type "audio"

set audioCue to last item of (selected as list)

-- template parameters

set audio output patch number of audioCue to 2

-- set some leves for columns 1 to ..

set ch to 1

repeat with mylevel in mylevels

audioCue setLevel row 0 column ch db mylevel

set ch to ch + 1

end repeat

-- cue specific parameters

set file target of audioCue to fileTarget

audioCue setLevel row 0 column 0 db mainlevel

set q number of audioCue to prefix & cueNum

-- we leave the cue name to be the default name

set notes of audioCue to "created by script " & ((current date) as string)

return audioCue

end tell

end makeAudio

Roly Botha

unread,
Nov 29, 2025, 1:13:12 PM (15 hours ago) Nov 29
to ql...@googlegroups.com
Thanks Mic and Paul for such detailed replies!

For context (apologies for not being clear about this at the start!) the big script I’ve been playing with is to change audio patch output of all cues in all q lists based on a "choose from" list of all active outputs. Hopping between working from home, rehearsal room, and my music studio has been annoying me recently - three different interfaces, each with different cue output effects and device routing due to the setup of each room (not to mention eventual show outputs, fx, and device routing).

I’ve largely been very happy with cmd+a > select only audio cues > select the patch from there, but scripting it felt (a bit) more convenient and (much) more interesting.

The more I got into it, the bigger the script got as I also wanted it to handle the target patch of "dip & restore master output" cues I have on shortcuts, plus the patch of any new audio cues created.

Mic, the idea of a targetable template cue on a shortcut is super useful! Thank you. The only limitation for me in this specific context is that it wouldn’t affect any cues dragged into the workspace.

After some more tinkering today, I’ve ended up with the below which is working okay for me and indeed modifies the cue template based on some fairly clunky UI scripting. It’s definitely the most complex script I’ve written but seems to not be making anything fall over for now. Haven’t deeply stress tested it so there may be glaring issues that are obvious to more skilled scripters than me! Also very aware there may be some clever efficiency/elegance stuff to be done that I’m not aware of - would be great to learn there if are obviously simpler ways of doing any of this… other than… clicking.


tell application id "com.figure53.QLab.5" to tell front workspace

-- **declarations**

set currentTIDs to AppleScript's text item delimiters -- store current TIDs

set AppleScript's text item delimiters to "; " -- sets new TIDs

set theindex to 1

set patchList to {} -- create an empty list, this will become our patch selection list later

set exitFlag to false -- the trigger to end our output patch name generation loop

set workspaceName to q number -- for UI Scripting cue template. stores workspace name as a variable

set settingsWindow to (workspaceName & " — Settings") -- for UI scripting. stores the name of front workspace's settings window

set theOffset to 3 -- for UI scripting. lets us ignore the first three elements of the "Audio Output Patch" pop-up menu, which aren't useful

if (count (cues whose q type is "Audio")) is 0 then

make type "audio"

set patcher to last item of (selected as list)

else

set patcher to first cue whose q type is "Audio"

end if

-- **generate list of active audio output patches**

repeat until (exitFlag is true)

set audio output patch number of patcher to theindex

set patchName to audio output patch name of patcher

if audio output patch number of patcher is not theindex then -- if you've run out of audio patches, the repeat ends

set exitFlag to true

else

copy (text items of patchName) to end of patchList -- adds each audio patch name to our list

set theindex to theindex + 1

end if

end repeat

-- **display a "choose from list" pop-up with the items of our audio output patch list**

set chosenPatch to choose from list patchList with prompt ("Which audio patch would you like to use?" & return & return & "This will affect ALL AUDIO CUES in the current workspace!" & return) default items (first text item of patchList)

if chosenPatch is false then

return -- if user hits cancel, end the script here

else

set audioCues to ((cues whose q type is "audio") as list) -- define every audio cue in the workspace

end if

-- **set audio output patch of every audio cue in workspace to user's selection**

repeat with eachCue in audioCues

set audio output patch name of eachCue to chosenPatch

end repeat

-- **set target patch of workspace master level fades to user's selection. Delete this section if you don't want master output level adjustment cues**

if (count (cues whose q number is "resmas")) is 0 then

make type "fade"

set resMas to last item of (selected as list)

set target mode of resMas to target mode patch

set q number of resMas to "resmas"

set q name of resMas to "Restore Master Level @ 0dB"

setLevel of resMas row 0 column 0 db 0

end if

if (count (cues whose q number is "dipmas")) is 0 then

make type "fade"

set dipMas to last item of (selected as list)

set target mode of dipMas to target mode patch

set q number of dipMas to "dipmas"

set q name of dipMas to "Dip Master Level @ -20dB"

setLevel of dipMas row 0 column 0 db -20

end if

set patch target id of (cues whose q number is "resmas" or q number is "dipmas") to audio output patch id of patcher

-- **prompt user to change audio cue template**

display dialog "Want to change the audio cue template?" buttons {"Nah", "Yeah"} default button "Yeah" cancel button "Nah"

if button returned of result = "cancel" then

return

else

set patchNum to audio output patch number of patcher

tell application "System Events" to tell process "QLab"

click menu item "Cue Templates" of menu "Templates" of menu item "Templates" of menu "Workspace Settings" of menu item "Workspace Settings" of menu "File" of menu bar item "File" of menu bar 1 of application process "QLab" of application "System Events"

click button 3 of group 1 of splitter group 1 of window settingsWindow of application process "QLab" of application "System Events"

click UI element "Audio" of row 2 of outline 1 of scroll area 1 of splitter group 1 of window settingsWindow of application process "QLab" of application "System Events"

click pop up button 1 of group 1 of splitter group 1 of window settingsWindow of application process "QLab" of application "System Events"

click menu item (patchNum + theOffset) of menu 1 of pop up button 1 of group 1 of splitter group 1 of window settingsWindow of application process "QLab" of application "System Events"

end tell

end if

close window settingsWindow of application "QLab"

end tell





Thanks!
--
Roly Botha (they/them)

website | Spotlight | theatre company

Though I sometimes send emails at unusual times, I never expect anyone to respond outside of their own working hours.
-- 
Contact support anytime: sup...@figure53.com
User Group Code of Conduct: https://qlab.app/code-of-conduct/
 
Instagram: https://www.instagram.com/Figure53
TikTok: https://www.tiktok.com/@QLab.app
Bluesky: https://bsky.app/profile/qlab.app
--- 
You received this message because you are subscribed to the Google Groups "QLab" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qlab+uns...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/qlab/bb09592c-105b-4e7a-b629-d1181e68795cn%40googlegroups.com.

Paul

unread,
Nov 29, 2025, 2:38:26 PM (14 hours ago) Nov 29
to QLab
You shouldn't need a script to do that at all. Assuming all your audio cues are using Patch 1 then if you go into Settings - Audio, you will have a top down menu of all the audio interfaces. Select the one you want and you're done.  (not related to cue Templates)

micpool

unread,
Nov 29, 2025, 2:51:26 PM (14 hours ago) Nov 29
to QLab
Hi Roly

I think most sound designers work on projects in a variety of different spaces, most typically working on cue lists in a hotel room on headphones generally in stereo,  in between tech rehearsals in the theatre space with a rig of up to 64 loudspeaker groups.

I have to say though that I have never addressed this by reassigning the patch of individual audio cues.  Generally, because you want the same balance regardless of whether you are working on a full multichannel theatre set up, a 5.1 studio set up or stereo headphones, I think the best place to address this change of environments is in the Patch Routing page in settings audio.

In the theatre I would  set the Audio device to DVS or whatever and generally set the matrix 1 to 1 which is the default.

When I want to work on the mix in a 5.1 studio  I might change the Audio device to an analogue audio interface and matrix to give as close an approximation of the spatial mix and relative levels of the theatre loudspeaker systems.

If the UK tour of a show ends and the show is rehearsed for a foreign tour with a different cast in a room with just a pair of Geneleca, I would change the patch to the 2 channel interface e.g a RME Babyface  and matrix to stereo using reference SPL meter readings taken in the theatre on tour. When the tour leaves the rehearsal room and arrives at the first venue, the audio device would be changed to the tour interfaces and the matrix set one to one again.

So, I am always just using a single patch and changing the device and matrix settings according to the environment I am editing the show in. The cues never change. Even if I start bulding the show in stereo, I still have all the cue outputs set up for the speakers I will use in the theatre, and I guess the relative levels in the Patch Routing matrix.

In QLab 4 QLab would remember all the settings for any interface that had been connected to the workspace. In QLab 5 you need to export  the audio output settings for each device from the File menu, and import when you change environments for listening/editing/rehearsal/performances  etc 

In the attached screen recording the QLab workspace is patched  1 to 1 using DVS as for the theatre.

I then assume I am working on laptop speakers in the hotel and import the set up I have previously exported appropriate for stereo working. This incliudes putting an Apple Matrix Reverb into my Reverb Channels which in DVS would route to the internal effects in the console, but are simulated for stereo environments using Apple's core audio FX. (You could also use Eqs as well to simulate small speakers etc.)

At the weekend, I rework some cues in a 5.1 studio so I import the audio outputs for that to simulate the theatre set up. And finally return to the theatre and change back to DVS without the core audio reverb 

This also means you can have a show set up for a big theatre  rig, and play the same cue lists in a variety of theatres, with onmly minor level tweaks required to the actual cues, because all the adjustments are set up universally in the Patch Routing.

Mic
 
OUtput Patch-HD 1080p.mov
Reply all
Reply to author
Forward
0 new messages