Qlab 5 Script - Please help

121 views
Skip to first unread message

Mike Stephens

unread,
Feb 12, 2025, 5:24:47 PMFeb 12
to QLab
Hi Qlab Friends.

Hoping someone could help me with a script for an upcoming uni project. Im looking at being able to have a script which when triggered makes a Program change type midi cue and places it into a custom named group. It should also ask for the program change number. Channel will be 16 to fire our digico. 

I really appreciate any guidance and support in advance for this new-be 

Yours, Mike.

Paul

unread,
Feb 13, 2025, 6:41:06 AMFeb 13
to QLab
Hi Mike
When trying to solve a programming problem like this the best approach is to break it down into steps, research the code needed to implement each step, until you have worked the individual bits, then write a prototype and get it to work, then write the actual production code, having learned the best way from the prototype. (often I will find more efficient ways of coding something).  Then you need to test it with various inputs and add error checking / catching, to stop your program crashing out if the user enters a silly value.

So for this project the steps would be make a MIDI cue of 'Program Change', set the various parameters of that cue (MIDI channel, Qlab MIDI patch to use, program change number etc) and then move the MIDI cue into a group cue. It helps with this if you understand something of how the data (MIDI here) is structured.

Anyway here is a complete script, with no error checking, to your problem. But please don't use this as is as I'm sure your uni would want you to work this out yourself!  It is worth check out the Qlab AppleScript dictionary which is very helpful on the commands if not the syntax examples.  https://qlab.app/docs/v5/scripting/applescript-dictionary-v5/
It is also helpful to write / test scripts in the Script Editor app as it offers more helpful error messages.

-- make  MIDI Program Change cue in Group

set ProgNum to text returned of (display dialog "Enter Program Change  num" default answer "" with title "Generate  MIDI PC cue")


-- see https://qlab.app/docs/v5/scripting/applescript-dictionary-v5/#midi-cue

set MIDIchannel to 16 -- the channell the receiving MIDI device is listening on

set MIDIpatchNum to 2 -- the Qlab MIDI patch setting

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

make type "Group"

set groupCue to last item of (selected as list)

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 1

-- 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

-- MIDI command can be note on/off, control_change, program_change, 

set command of midiCue to program_change

set byte one of midiCue to ProgNum

-- set the cue number to something relevant

set q number of midiCue to "MPC" & ProgNum

-- move the MIDI cue into the Group cue

move cue id (uniqueID of midiCue) of parent of midiCue to end of groupCue

set q name of groupCue to "MIDI Program Change " & ProgNum

end tell

Rich Walsh

unread,
Feb 13, 2025, 6:57:57 AMFeb 13
to ql...@googlegroups.com
I had something for this: https://wiki.allthatyouhear.com/doku.php#go_ahead_make_midi. You need to change all the "qlab.4” to “qlab.5” for it to run in QLab 5.

My preferred approach for recalling scenes, etc, on outboard is to create a separate cue list and pre-populate it with all possible cues needed – MIDI or OSC – with a custom numbering scheme, eg: 901 for scene 1, etc. Then you just enter a Start Cue when you need to fire one of those. This means you don’t have to think about the structure of the cue when you want it, just the number. It also makes it easy to fix when you’ve forgotten about a MIDI offset…

By the way, my memory of DiGiCo is that they don’t use program change but rather control changes on CC16-CC19, so CC16 @ 1 will recall scene 1. Has that changed?

Rich

--
Contact support anytime: sup...@figure53.com
User Group Code of Conduct: https://qlab.app/code-of-conduct/
 
Instagram: https://www.instagram.com/Figure53
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/3225b2c0-ed61-4cdd-9175-09872adb172dn%40googlegroups.com.

Mike Stephens

unread,
Feb 13, 2025, 7:22:35 AMFeb 13
to QLab
Thanks for this! Great support.

 Is the reason to set declarations outside the group to make the script run faster, or for ease of making changes to the Script settings. As parameters are reference at the top. I initially gave this a go and did the below. Got so far but couldn't make it go inside a group. Also I didn't have anything outside the tell as you have. Ill defiantly move forward with yours but would value any advice / notes of silliness before I try and move forward with more:

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

-- Confirm Edit Mode Active
if not (edit mode) then
display dialog "QLab is in Show Mode. This script requires user to be in Edit Mode." buttons {"OK"} default button "OK"
return -- Stop the script
end if

-- Ask for custom cue name via dialog box
display dialog "Enter the name for your Console cue:" default answer "Scene 1"
set customCueName to text returned of result

-- Ask for custom Program Change number via dialog box
display dialog "Enter the Program Change number (0-127):" default answer "22"
set customProgramChange to text returned of result
set customProgramChange to (customProgramChange as integer) -- Convert the input to an integer

-- Create a new MIDI cue
set MidiCue to make type "MIDI"
delay 0.1 -- Allow QLab time to process the cue creation

-- Ensure we reference the correct cue
set MidiCue to last item of (selected as list)
delay 0.1 -- Small delay for stability

-- Set cue properties
set command of MidiCue to program_change -- Sets it to Program Change
delay 0.1 -- Small delay for stability

-- Set the MIDI channel (0-indexed, so 15 = channel 16)
set channel of MidiCue to 15

-- Set the Program Change number (22 in this case)
set byte one of MidiCue to customProgramChange -- Set the custom Program Change number

-- Set the MIDI output device (patch)
set midi patch number of MidiCue to 1 -- Replace with Device Number. 0 = Unpatached

-- Set the name of the new cue
set q name of MidiCue to "Digico Console Cue - (C" & customProgramChange & ")"
-- Move MIDI Cue into Group Cue move MidiCue to end of newGroup


Thanks! Mike

Reply all
Reply to author
Forward
0 new messages