Skip to content

Commit 581535b

Browse files
committed
Added a rushed new SQ midi cue script
1 parent 44f09b9 commit 581535b

File tree

1 file changed

+156
-0
lines changed

1 file changed

+156
-0
lines changed
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
-- @description Create SQ Midi control cue
2+
-- @author Ben Smith
3+
-- @link bensmithsound.uk
4+
-- @version 1.0
5+
-- @testedmacos 10.14.6
6+
-- @testedqlab 4.6.10
7+
-- @about Create an SQ Midi control cue
8+
-- @separateprocess TRUE
9+
10+
-- @changelog
11+
-- v1.0 + init
12+
13+
14+
-- USER DEFINED VARIABLES -----------------
15+
16+
try -- if global variables are given when this script is called by another, use those variables
17+
cueTitle
18+
on error
19+
set cueTitle to "SQ5"
20+
end try
21+
22+
try
23+
cuePatch
24+
on error
25+
set cuePatch to "1"
26+
end try
27+
28+
try
29+
askForValue
30+
on error
31+
set askForValue to "Cue Number"
32+
end try
33+
34+
try
35+
cueColor
36+
on error
37+
set cueColor to "green"
38+
end try
39+
40+
---------- END OF USER DEFINED VARIABLES --
41+
42+
43+
-- VARIABLES FROM QLAB NOTES --------------
44+
45+
------------------ END OF QLAB VARIABLES --
46+
47+
48+
property util : script "Applescript Utilities"
49+
50+
51+
---- RUN SCRIPT ---------------------------
52+
53+
tell application id "com.figure53.Qlab.4" to tell front workspace
54+
55+
-- save current position
56+
try
57+
set currentPosition to last item of (selected as list)
58+
end try
59+
set currentCueList to current cue list
60+
61+
-- Get context
62+
display dialog "Please provide " & askForValue with title cueTitle default answer ""
63+
set sceneNumber to (text returned of result) as integer
64+
65+
display dialog "Please provide cue name" with title "cueTitle" default answer ""
66+
set sceneName to (text returned of result)
67+
68+
-- Construct midi message
69+
set bankNumHex to my calculateBank(sceneNumber)
70+
set sceneNumHex to my calculateScene(sceneNumber)
71+
72+
set bankMessage to "B0 00 " & bankNumHex
73+
set sceneMessage to " C0 " & sceneNumHex
74+
75+
-- Create cue list if necessary, or switch to it
76+
try
77+
set cueList to first cue list whose q name is (cueTitle & " control")
78+
on error
79+
make type "cue list"
80+
set cueList to first cue list whose q name is "Cue list"
81+
set q name of cueList to (cueTitle & " control")
82+
set q color of cueList to cueColor
83+
collapse cueList
84+
end try
85+
86+
set current cue list to cueList
87+
88+
-- Create cue
89+
make type "Midi"
90+
set midiCue to last item of (selected as list)
91+
set message type of midiCue to sysex
92+
set patch of midiCue to cuePatch
93+
94+
-- Set cue
95+
set sysex message of midiCue to bankMessage & sceneMessage
96+
set q name of midiCue to cueTitle & ": Scene " & sceneNumber & " - " & sceneName
97+
set q color of midiCue to cueColor
98+
99+
-- put start cue in original cue list
100+
set current cue list to currentCueList
101+
try
102+
set selected to currentPosition
103+
end try
104+
105+
make type "Start"
106+
set startCue to last item of (selected as list)
107+
set cue target of startCue to midiCue
108+
set q name of startCue to cueTitle & ": Scene " & sceneNumber & " - " & sceneName
109+
set q color of startCue to cueColor
110+
if q type of (parent of startCue) is not "cue list" then
111+
set q color of (parent of startCue) to cueColor
112+
end if
113+
114+
end tell
115+
116+
117+
-- FUNCTIONS ------------------------------
118+
119+
on calculateBank(num)
120+
set bank to integer
121+
if num is less than 129 then
122+
set bank to "00"
123+
end if
124+
if num is greater than 128 and num is less than 257 then
125+
set bank to "01"
126+
end if
127+
if num is greater than 256 and num is less than 385 then
128+
set bank to "02"
129+
end if
130+
if num is greater than 384 and num is less than 501 then
131+
set bank to "03"
132+
end if
133+
134+
135+
set bankNumHex to bank
136+
end calculateBank
137+
138+
on calculateScene(num)
139+
set scene to integer
140+
if num is less than 129 then
141+
set scene to num - 1
142+
end if
143+
if num is greater than 128 and num is less than 257 then
144+
set scene to (num - 129)
145+
end if
146+
if num is greater than 256 and num is less than 385 then
147+
set scene to (num - 257)
148+
end if
149+
if num is greater than 384 and num is less than 501 then
150+
set scene to (num - 385)
151+
end if
152+
153+
set sceneHex to do shell script "perl -e 'printf(\"%02X\", " & scene & ")'"
154+
155+
set sceneNumHex to sceneHex
156+
end calculateScene

0 commit comments

Comments
 (0)