-- Make Start and MIDI CC and PC cues to control sound desk
-- put this on a hot key trigger
-- the cue number prefix for group cues in control list (and target cue number of start cues)
set prefix to "Sc"
-- adjust these values to suit
set MIDIpatchNum to 1 -- the Qlab MIDI patch for output
set MIDIchannel to 2 -- MIDI channel the receiver is listening on
set controlNumber to 5 -- for CC MIDI cue, the control number needed by your sound desk
-- this is the name of the cue list where the midi cues will be created
-- if it doesn't exist it will be created
set midiCuelistName to "Desk Control"
tell application id "com.figure53.QLab.5" to tell front workspace
set nl to linefeed
set selCue to last item of (selected as list)
set myCuelist to current cue list
--display dialog (q display name of selCue) & nl & (q name of myCuelist) as string with title "Starting position"
set nextSceneNum to ""
set sceneNum to text returned of (display dialog "Enter the scene number" default answer nextSceneNum with title "MIDI scene recall of sound desk")
try
set recallCueNum to prefix & sceneNum
set targetCue to cue recallCueNum
on error
set myCuelist to current cue list
-- make midi cues as they don't exist
try
set midiCuelist to first cue list whose q name is midiCuelistName
set current cue list to midiCuelist
on error errMesg
set response to (display dialog "Cue list does not exist " & linefeed & errMesg as string with title midiCuelistName buttons {"Cancel", "Create Cuelist"} default button "Create Cuelist")
if button returned of response is "Create Cuelist" then
make type "cue list"
set midiCuelist to first cue list whose q name is "Cue List"
set q name of midiCuelist to midiCuelistName
set current cue list to midiCuelist
end if
end try
make type "group"
set groupCue to last item of (selected as list)
-- make midi cues
set midiPCcue to my makeMIDI(MIDIpatchNum, MIDIchannel)
set command of midiPCcue to program_change
set midiCCcue to my makeMIDI(MIDIpatchNum, MIDIchannel)
set command of midiCCcue to control_change
-- may need to modify this depending on the sound desk
set byte one of midiPCcue to sceneNum
set byte one of midiCCcue to controlNumber
set ControlValue to sceneNum -- may need to change depending on sound desk
set byte two of midiCCcue to ControlValue
-- move both midi cues into the group
move cue id (uniqueID of midiPCcue) of parent of midiPCcue to end of groupCue
move cue id (uniqueID of midiCCcue) of parent of midiCCcue to end of groupCue
-- set the cue number of the group cue - this will be the target of the Start cue
set q number of groupCue to recallCueNum
set q name of groupCue to "recall scene " & sceneNum
collapse midiCuelist
-- revert back to the cue list we were working in
set current cue list to myCuelist
end try
make type "Start"
set startcue to last item of (selected as list)
set cue target of startcue to cue recallCueNum --midiGroupCue
-- move the start cue to after the currently selected cue [script must be on hotkey]
move cue id (uniqueID of startcue) of parent of startcue to after selCue
set selected to startcue
end tell
on makeMIDI(MIDIpatchNum, MIDIchannel)
--
tell application id "com.figure53.QLab.5" to tell front workspace
make type "MIDI"
set midiCue to last item of (selected as list)
-- MIDI cue parameters
set midi patch number of midiCue to MIDIpatchNum
set channel of midiCue to MIDIchannel
-- MIDI types can be Voice (note, CC, Prog Change etc), MSC (MIDI Show Control) or SysEx (System Exclusive)
set message type of midiCue to voice
return midiCue
end tell
end makeMIDI