set userDownTime to 0.1 -- Time for previous audio to fade in
-- Declarations
set notFirstCue to false
-- Main routine
tell application id "com.figure53.qlab.3" to tell front workspace
set selectedCues to selected as list
repeat with eachCue in selectedCues
if q type of eachCue is "audio" then -- Any other selected cues will be ignored; the sequence will end up after them
-- Make a fade out cue (not for the first cue)
if notFirstCue then
make type "Fade" -- Cue numbers and names not altered from QLab defaults
set fadeOutCue to last item of (selected as list)
set cue target of fadeOutCue to previousCue
set duration of fadeOutCue to userDownTime
fadeOutCue setLevel row 0 column 0 db -120
set stop target when done of fadeOutCue to true
set the q number of fadeOutCue to ""
end if
-- Make a Group Cue (have to do this here to get round QLab's auto-grouping of selections ≥ 2 cues)
make type "Group" -- Cue numbers not altered from QLab defaults
set groupCue to last item of (selected as list)
set mode of groupCue to fire_all
set q name of groupCue to q list name of eachCue & " [STOP previous] "
set theqnumber to the q number of eachCue
set the q number of eachCue to ""
set the q number of groupCue to theqnumber
-- Move cues into right place
move cue id (uniqueID of eachCue) of parent of eachCue to end of groupCue
if notFirstCue then move cue id (uniqueID of fadeOutCue) of parent of fadeOutCue to end of groupCue
-- Setup variables for next pass
set previousCue to eachCue
set notFirstCue to true
end if
end repeat
end tell