This is an "external script" - see QLab Scripts and Macros
(* Make a soundcheck sequence *)
--
set theExplanation to "This script will create a Group Cue containing a sequence of soundcheck cues from the last Audio Cue currently selected in QLab.
The soundcheck will step through one output at a time via a sequence of default crossfades. Before running this script you should remove Channel 1 " & ¬
"from any Gangs in the Audio Cue and configure the cue to play at the desired levels out of all the outputs you wish to check, " & ¬
"as these levels will be used in the fades. The script will not adjust crosspoints."
--
(* This script is not designed to be run from within QLab!
v1.0: 18/09/09 Rich Walsh
v1.1: 18/09/09 Added protection against asking for only 1 output!
v1.2: 19/09/09 Fixed reset following on before final fade out complete; general tidy up
v1.3: 27/09/09 Added some reassuring messages, and put it all in a Group Cue
v1.4: 04/10/09 Found more efficient ways of getting existingNumbers & handling lists
v1.5: 12/10/09 Snow Leopard can't "get running", so rewrote a sequence
v1.6: 16/10/09 Now "tested" in Snow Leopard; general tidying
v1.7: 27/10/09 Stopped it resetting an existing cue number; yet more general tidying
v1.8: 11/01/10 Worked out less cumbersome way of moving into a group, fixing side issue in process; added tell front workspace for elegance;
wrapped text for better wiki experience; implemented dialogTitle for cross-script pillaging; new explanation format
v1.9: 31/01/10 Removed option to create resets as they will never be able to recreate the effect of the Reset All button
<<< Last tested with: QLab 2.2.6; Mac OS 10.5.8 & 10.6.2 >>> *)
-- ###FIXME### It would be great to find a way to deal with Gangs (they make it impossible to have just the first output up in the original Audio Cue)
-- ###FIXME### QLab and/or the "script runner" is, generally, increasingly unresponsive to scripts the more cues there are in a workspace
-- ###ADD### Better fade curves
-- Declarations
global dialogTitle
set dialogTitle to "Make a soundcheck sequence"
-- Preamble
display dialog theExplanation & return & return & "Are you sure you wish to proceed?" with title dialogTitle with icon 1 ¬
buttons {"Cancel", "OK"} default button "OK" cancel button "Cancel"
-- Check QLab is running
tell application "System Events"
set qLabIsRunning to count (every process whose name is "QLab")
end tell
if qLabIsRunning is 0 then
display dialog "QLab is not running." with title dialogTitle with icon 0 buttons {"OK"} default button "OK" giving up after 5
return
end if
tell application "QLab"
activate
-- Test for a workspace and a selection
set noSelection to false
try
set theSelection to (selected of front workspace as list)
set countSelection to count theSelection
if countSelection is 0 then
set noSelection to true
end if
on error
set noSelection to true
end try
if noSelection is true then
display dialog "There is no selection in QLab." with title dialogTitle with icon 0 buttons {"OK"} default button "OK" giving up after 5
return
end if
-- Find the last Audio Cue in the selection and check it has a valid target, or give up
tell front workspace
set badSelection to true
set hasTarget to ""
repeat with i from countSelection to 1 by -1
if q type of item i of theSelection is "Audio" then
set badSelection to false
set theAudioCue to item i of theSelection
try
set targetTest to (file target of theAudioCue) as string
if targetTest is "missing value" then
set hasTarget to "The last selected Audio Cue has lost its target."
end if
on error
set hasTarget to "The last selected Audio Cue does not have a valid target."
end try
exit repeat
end if
end repeat
if badSelection is true then
display dialog "QLab's selection does not contain an Audio Cue." with title dialogTitle with icon 0 buttons {"OK"} default button "OK" giving up after 5
return
end if
if hasTarget is not "" then
display dialog hasTarget with title dialogTitle with icon 0 buttons {"OK"} default button "OK" giving up after 5
return
end if
-- Prompt for how many outputs to test
set outputQuestion1 to button returned of (display dialog "How many outputs do you wish to check?" with title ¬
dialogTitle buttons {"16", "32", "Other"} default button "32")
if outputQuestion1 is "Other" then
set outputQuestion2 to ""
repeat until outputQuestion2 is not ""
set outputQuestion2 to text returned of (display dialog "Enter the number of outputs you wish to check (ie: a number between 2 & 48):" with title ¬
dialogTitle default answer "8" buttons {"Cancel", "OK"} default button "OK" cancel button "Cancel")
try
set howManyOutputs to outputQuestion2 as number
if howManyOutputs is less than 2 or howManyOutputs is greater than 48 then
set outputQuestion2 to ""
end if
on error
set outputQuestion2 to ""
end try
end repeat
else
set howManyOutputs to outputQuestion1 as number
end if
-- Prompt for length of crossfades
set lengthQuestion1 to button returned of (display dialog "Select a duration for the crossfades (in seconds):" with title ¬
dialogTitle buttons {"1", "3", "Other"} default button "1")
if lengthQuestion1 is "Other" then
set lengthQuestion2 to ""
repeat until lengthQuestion2 is not ""
set lengthQuestion2 to text returned of (display dialog "Enter the duration of the crossfades you require (in seconds):" with title ¬
dialogTitle default answer "5" buttons {"Cancel", "OK"} default button "OK" cancel button "Cancel")
try
set howLong to lengthQuestion2 as number
if howLong is less than 0 then
set lengthQuestion2 to ""
end if
on error
set lengthQuestion2 to ""
end try
end repeat
else
set howLong to lengthQuestion1 as number
end if
-- Prompt for whether there should be a fade in at the start
set fadeQuestion to button returned of (display dialog "Would you like the sequence to start by fading in?" with title ¬
dialogTitle buttons {"Cancel", "Yes", "No"} default button "No" cancel button "Cancel")
if fadeQuestion is "Yes" then
set fadeIn to true
else
set fadeIn to false
end if
-- The bit of the script that actually does the work starts here...
display dialog "One moment caller..." with title dialogTitle with icon 1 buttons {"OK"} default button "OK" giving up after 1
-- Get all output levels from the Audio Cue (except Master)
set allOutCheck to true
set originalCueLevels to {}
repeat with i from 1 to 48
set thisOutputLevel to theAudioCue getLevel row 0 column i
if thisOutputLevel is not -120 then
set allOutCheck to false
end if
copy thisOutputLevel to end of originalCueLevels
end repeat
-- Exit if there are no levels set in the Audio Cue
if allOutCheck is true then
display dialog "The last selected Audio Cue has all its individual output levels set to \"-INF\".
It makes no sense to proceed..." with title dialogTitle with icon 0 buttons {"OK"} default button "OK"
return
end if
-- Make a new Group Cue for the sequence: after the current selection, regardless of where the Audio Cue is
make type "Group"
set theGroupCue to last item of (selected as list)
set mode of theGroupCue to fire_first_enter_group
set q name of theGroupCue to "Start soundcheck"
-- Move the Audio Cue inside the Group Cue
set theAudioCueID to uniqueID of theAudioCue
set theAudioCueIsIn to the first cue whose (q type is "Group" and cues contains theAudioCue)
set theGroupCueID to uniqueID of theGroupCue
move (the first cue whose uniqueID is theAudioCueID) of theAudioCueIsIn to end of (the first cue whose uniqueID is theGroupCueID)
delay 1 -- The next command may be ignored otherwise
moveSelectionDown -- The Group Cue was the last selection, so we need to select a cue inside the group before making the fades
-- Set outputs 2-48 to -INF
repeat with i from 2 to 48
theAudioCue setLevel row 0 column i db -120
end repeat
-- Create fade in, if necessary
if fadeIn is true then
theAudioCue setLevel row 0 column 1 db -120
set continue mode of theAudioCue to auto_continue
make type "Fade"
set newCue to last item of (selected as list)
set cue target of newCue to theAudioCue
set duration of newCue to howLong
set newCueLevels to item 1 of originalCueLevels
newCue setLevel row 0 column 1 db newCueLevels
set q name of newCue to "Fade in output 1"
else
set continue mode of theAudioCue to do_not_continue
end if
-- Make fades
repeat with i from 2 to howManyOutputs
make type "Fade"
set newCue to last item of (selected as list)
set cue target of newCue to theAudioCue
set duration of newCue to howLong
set newCueLevels to item i of originalCueLevels
newCue setLevel row 0 column i db newCueLevels
newCue setLevel row 0 column (i - 1) db -120
set q name of newCue to "Move to output " & i as string
set notes of newCue to "You are listening to output " & (i - 1) as string
end repeat
-- Make final fade out
make type "Fade"
set newCue to last item of (selected as list)
set cue target of newCue to theAudioCue
set duration of newCue to howLong
newCue setLevel row 0 column howManyOutputs db -120
set stop target when done of newCue to true
set q name of newCue to "Stop soundcheck"
set notes of newCue to "You are listening to output " & howManyOutputs as string
end tell
activate
display dialog "Done." with title dialogTitle with icon 1 buttons {"OK"} default button "OK" giving up after 60
end tell
(* END: Make a soundcheck sequence *)