Apple Script to create MIDI cue with pre wait

43 views
Skip to first unread message

Thomas Wacker

unread,
Feb 27, 2026, 9:54:29 AM (4 days ago) Feb 27
to QLab
Hi all,
I need your help with the following scenario :
I want to trigger light cues via MSC at certain point of an audio cue.
Momentarily I proceed like this : 
- In the time + loops window of the audio cue place the playhead at the desired spot
- Create a MIDI cue
- enter the pre wait time = time elapsed of audio cue for the new MIDI cue manually.
If I need a lot of those cues, that´s a little tedious...
What I would like to do :
- In the time + loops section of the audio cue place the playhead at the desired spot
- trigger AppleScript via hot key to do the rest.
Audio and MIDI cues will end up in timeline-group cue at the end. 
thanks a lot
Thomas
I want to trigger light cues via MSC at certain events in a running audio cue.
Momentarily I proceed like this :
In the inspector window of the audio cue (waveform display) place the playhead at the position of the required MSC cue / create MIDI cue / set cue properties to MSC and MIDI patch 1 / enter pre wait time of time elapsed of audio cue.
Doing all of this manually when there are multiple such MIDI cues to create is a little tedious and time consuming….
Can you help me out with an apple script to do this job ?
I want to trigger light cues via MSC at certain events in a running audio cue.
Momentarily I proceed like this :
In the inspector window of the audio cue (waveform display) place the playhead at the position of the required MSC cue / create MIDI cue / set cue properties to MSC and MIDI patch 1 / enter pre wait time of time elapsed of audio cue.
Doing all of this manually when there are multiple such MIDI cues to create is a little tedious and time consuming….
Can you help me out with an apple script to do this job ?I want to trigger light cues via MSC at certain events in a running audio cue.
Momentarily I proceed like this :
In the inspector window of the audio cue (waveform display) place the playhead at the position of the required MSC cue / create MIDI cue / set cue properties to MSC and MIDI patch 1 / enter pre wait time of time elapsed of audio cue.
Doing all of this manually when there are multiple such MIDI cues to create is a little tedious and time consuming….
Can you help me out with an apple script to do this job ?

micpool

unread,
Feb 27, 2026, 2:21:21 PM (4 days ago) Feb 27
to QLab

--make a MIDI cue with a prewait based on the cursor position.

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

set theCue to last item of (selected as list)

set theOffset to pre wait of theCue

set theTime to (action elapsed of theCue) + theOffset

make type "midi" --assumes MSC cue is set up in cue template

set theMidiCue to last item of (selected as list)

set the pre wait of theMidiCue to theTime

set the selected to theCue

end tell



This will place cues in the cue list in the reverse order they are made, so a useful second script is one that places the selected cues in a group and sorts them according to pre wait time.

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

set theCues to (selected as list)

set thearray to {} as list

repeat with eachcue in theCues

set end of thearray to {idid:uniqueID of eachcue, prewait:pre wait of eachcue}

end repeat

end tell

qsort(thearray, 1, ((number of items of thearray)))


set thecounter to 1

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

make type "group"

set theGroup to last item of (selected as list)

set the q name of theGroup to (q list name of first cue of theGroup & "  with MSC cues")

repeat ((number of items of thearray)) times

set thesortcue to (first cue of theGroup whose uniqueID is (idid of item thecounter of thearray))

move thesortcue to end of theGroup

set thecounter to thecounter + 1

end repeat

set the q name of theGroup to (q name of first cue of theGroup & "with MSC cues")

end tell




on qsort(array, l, r)

set i to l

set j to r

set v to item ((l + r) div 2) of array -- pivot

repeat while (j > i)

repeat while (prewait of item i of array < prewait of v)

set i to i + 1

end repeat

repeat while (prewait of item j of array > prewait of v)

set j to j - 1

end repeat

if (not i > j) then

tell array to set {item i, item j} to {item j, item i} -- swap

set i to i + 1

set j to j - 1

end if

end repeat

if (l < j) then qsort(array, l, j)

if (r > i) then qsort(array, i, r)

end qsort



Screen recording attached


Screen Recording 2026-02-27 at 19.18.08-HD 1080p.mov

Thomas Wacker

unread,
Feb 27, 2026, 6:24:10 PM (4 days ago) Feb 27
to QLab
Thanks Mic, never ever would I have sorted this one out ! 
Reply all
Reply to author
Forward
0 new messages