Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --CLOSE INSPECTOR BEFORE RUNNING FOR UP TO 10 TIMES SPEED INCREASE
- --Script to generate utility cues, 128 cues per controller to translate MIDI cc values to OSC to set slider levels, and cues to feedback current level of sliders of selected cue in dB to MIDI controller as a cc value.
- --set MIDI Patch 8 to MIDI controller device
- -- set script cue template with 'run in separate process' UNCHECKED
- --set Network Cue template to MIDI ch of controller in triggers
- --set Script Cue template to MIDI ch of controller in triggers
- --user adjustable variables
- set encoders to true --(boolean) true if controller has motorized fader or is rotary encoder, false for dumb fader or knob.
- set allatonce to true -- if true any encoder switch will update levels on all encoders. If false a switch will only updte it's own encoder (only used for encoders)
- set theminimum to -60 --minimum audio level as set in settings/audio
- set themaximum to 10 --maximum audio level as set in settings/audio
- set theMIDIcc to 1 -- MIDI cc of first MIDI cc controller
- set theMIDInote to 0 --MIDI note to read levels of selected cue for takeover or note sent when first MIDI encoder touched (0 for Behringer X-Touch compatibility out of box)
- set theMIDIch to 11 -- Midi Channel to send feedback to encoders (only needed for encoders) (11 for Behringer X touch compatibility out of box)
- set numberOfControllers to 9 -- number of consecutive controllers
- set listOfSliders to {1, 2, 3, 4, 5, 6, 7, 8, 0} -- list of sliders controlled by midi controllers. Master is 0. Number of items in list must match number of controllers.
- ---do not change anything below this line-----
- --error check routines for variables above
- if (count of items of listOfSliders) is not equal to numberOfControllers then
- display dialog "Slider list does not match number of controllers"
- return
- end if
- --calculate the step value
- set thestep to (themaximum - theminimum) / 127 --step value for slider in dB in QLab, per increase of 1 in MIDI cc value.
- --make text formatted list of sliders for use in script sources below
- set formattedlist to "{"
- repeat with x from 1 to numberOfControllers
- set formattedlist to formattedlist & item x of listOfSliders
- if x is not numberOfControllers then set formattedlist to formattedlist & ","
- end repeat
- set formattedlist to formattedlist & "}"
- set thelistofsliders to formattedlist
- --make text for preflight check dialog display
- set thechecklist to ""
- if encoders is true then
- set thechecklist to thechecklist & "GENERATING CUES FOR ENCODERS" & return & return & "MIDI ch to send to encoders is: " & theMIDIch & return & return
- if allatonce is false then
- set thechecklist to thechecklist & "An encoder's switch only updates its own encoder" & return & return
- else
- set thechecklist to thechecklist & "All encoders updated with any encoder switch" & return & return
- end if
- else
- set thechecklist to thechecklist & "GENERATING CUES FOR POTS" & return & return
- end if
- set thechecklist to thechecklist & "Minimum audio level as set in settings audio is: " & theminimum & return & return & "Maximum audio level as set in settings audio is: " & themaximum & return & return & numberOfControllers & " controllers starting with cc" & theMIDIcc & return & "Controlling sliders: " & thelistofsliders & return & return
- if encoders is false then set thechecklist to thechecklist & "MIDI note to take over levels: " & theMIDInote & return & return
- -- main program
- tell application id "com.figure53.QLab.5" to tell front workspace
- --check user actually wants to generate a list and present the preflight check list
- --display dialog "QLab will Generate cues to convert MIDI cc messages to OSC" & return & return & "Are you sure you want to do this?" & return & return & "Delete all cues created previously by this script before running" & return & return & "Some settings cannot be managed through scripting!" & return & return & "In settings:" & return & "Set MIDI Patch 8 to MIDI controller device" & return & return & "Set script cue template with 'run in separate process' UNCHECKED" & return & return & "Set Network Cue template Triggers tab to MIDI ch of controller" & return & return & "CUE GENERATOR WILL RUN UP TO 10 TIMES FASTER IF INSPECTOR IS CLOSED" & return & return & thechecklist with icon "warning"
- --make memo cues to store variables
- --Make Memo cue to store data from preflight check list in notes field
- make type "Memo"
- set theselected to last item of (selected as list)
- set the q number of theselected to "SUM"
- set the notes of theselected to thechecklist
- set the q name of theselected to thechecklist
- --Make Memo cue to store minimum audio level for use in calculations in notes field
- make type "Memo"
- set theselected to last item of (selected as list)
- set the q number of theselected to "MIN"
- set the notes of theselected to theminimum
- set q name of theselected to theminimum
- --Make Memo cue to store step level for use in calculations, in notes field
- make type "Memo"
- set theselected to last item of (selected as list)
- set the q number of theselected to "STEP"
- set the notes of theselected to thestep
- set the q name of theselected to thestep
- --make a MIDI cue to feedback current level of a slider to MIDI controller
- make type "MIDI" --set up cue template to set patch etc.
- set theselected to last item of (selected as list)
- set the midi patch id of theselected to 1
- set the q number of theselected to "MOP"
- set the message type of theselected to voice
- set the command of theselected to control_change
- set the channel of theselected to theMIDIch
- --Create Take cue to store current slider level and script to prepare level takeover
- if encoders is false then
- make type "Script"
- set theselected to last item of (selected as list)
- set the q number of theselected to "TAKE"
- set the q name of theselected to "Prepare level takeover"
- set the midi trigger of theselected to enabled
- set the midi command of theselected to note_on
- set the midi byte one of theselected to theMIDInote
- set the midi byte two string of theselected to ">0"
- set the script source of theselected to "set thelistofsliders to " & thelistofsliders & return & "tell application id \"com.figure53.QLab.5\" to tell front workspace" & return & "try" & return & "set theselected to last item of (selected as list)" & return & "set the armed of cue \"Pick\" to false" & return & "set the armed of cue \"SetS\" to false" & return & "repeat with aSlider from 1 to " & numberOfControllers & return & "set thelevel to getLevel theselected row 0 column (item aSlider of thelistOfSliders)" & return & "set thelevel to round ((thelevel - (notes of cue \"MIN\")) / (notes of cue \"STEP\"))" & return & "set thecue to \"Pcc\" & (aSlider as string) & \"_\" & (thelevel as string)" & return & "delay 0.1" & return & "set the armed of cue thecue to true" & return & "end repeat" & return & "end try" & return & "end tell"
- end if
- --make a group cue to enclose all the group cues relating level setting of a MIDI controller
- make type "Group"
- set theselected to last item of (selected as list)
- set the mode of theselected to start_first
- set the q name of theselected to "set slider cues"
- set the q number of theselected to "SetS"
- --make a group cue to enclose all the group cues relating to level matching of a current slider position to MIDI controller value for take over
- if encoders is false then
- make type "Group"
- set theselected to last item of (selected as list)
- set the mode of theselected to fire_first_go_to_next_cue
- set the q name of theselected to "Pickup level Mechanism"
- set the q number of theselected to "Pick"
- end if
- if encoders is true and allatonce is true then
- --make a script that sends all the current slider levels in use, all at once, to the MIDI controllers
- make type "SCRIPT"
- set theselected to last item of (selected as list)
- set the q name of theselected to "Feedback all levels to MIDI controller"
- set the q number of theselected to "AAO"
- set the script source of theselected to "set thesliderslist to " & thelistofsliders & return & "set numberofsliders to " & numberOfControllers & return & "set theCC to " & theMIDIcc & return & "tell application id \"com.figure53.QLab.5\" to tell front workspace" & return & "try" & return & "set theselected to last item of (selected as list)" & return & "repeat with aSlider from 1 to numberofsliders" & return & "set thelevel to getLevel theselected row 0 column (item aSlider of thesliderslist)" & return & "set thelevel to round ((thelevel - (notes of cue \"MIN\")) / (notes of cue \"STEP\"))" & return & "set byte one of cue \"MOP\" to theCC - 1 + aSlider" & return & "set byte two of cue \"MOP\" to thelevel" & return & "start cue \"MOP\"" & return & "end repeat" & return & "end try" & return & "end tell"
- --make a start cue for each encoder switch to start the group cue that feeds back all slider levels to the controller.
- repeat with astartcue from 1 to numberOfControllers
- make type "start"
- set theselected to last item of (selected as list)
- set the cue target of theselected to cue "AAO"
- set the q name of theselected to "Triggered by encoder switch MIDI note " & theMIDInote - 1 + astartcue
- set the q number of theselected to "AAO" & astartcue
- set the midi command of theselected to note_on
- set the midi byte one of theselected to theMIDInote - 1 + astartcue
- set the midi byte two string of theselected to ">0"
- set the midi trigger of theselected to enabled
- end repeat
- end if
- --
- repeat with cc from 1 to numberOfControllers
- --make a group cue for 128 cues that will control slider levels
- make type "Group"
- set theselected to last item of (selected as list)
- set the mode of theselected to start_first
- set the q name of theselected to "Controller " & (cc as string)
- set the q number of theselected to "SetS" & (cc as string)
- move cue id (uniqueID of theselected) of parent of theselected to end of cue "SetS"
- --make 128 cues triggered by cc values 0-127 to set slider levels via OSC and put them in the newly created group cue
- repeat with x from 0 to 127
- make type "Network"
- set theselected to last item of (selected as list)
- --set the correct triggerfor the new cue
- set the midi command of theselected to control_change
- set the midi byte one of theselected to theMIDIcc + (cc - 1)
- set the midi byte two of theselected to x
- set the midi trigger of theselected to enabled
- --set the parameter values of theselected to custom
- --set the OSC message to be sent by the new cue
- set thelevel to theminimum + x * thestep
- set thelevel to round (thelevel) rounding to nearest
- set the parameter values of theselected to "/cue/selected/level/0/" & item cc of listOfSliders & " " & thelevel
- set the q number of theselected to "cc" & theMIDIcc + (cc - 1) & "_" & x
- move cue id (uniqueID of theselected) of parent of theselected to end of cue ("SetS" & (cc as string))
- end repeat
- if allatonce is false then
- -- make a MIDI input script to get current value of QLab parameter and send the equivalent MIDI level to the MIDI controller)
- make type "SCRIPT"
- set theselected to last item of (selected as list)
- set the q number of theselected to "SL" & item cc of listOfSliders
- set the q name of theselected to "send slider" & (item cc of listOfSliders) & " value to MIDI controller"
- set the midi trigger of theselected to enabled
- set the midi command of theselected to note_on
- set the midi byte one of theselected to (theMIDInote + (cc - 1))
- set the midi byte two string of theselected to ">0"
- set the script source of theselected to "set theslider to " & (item cc of listOfSliders) & " -- slider to control, 0 is Master" & return & "set theCC to " & (theMIDIcc + (cc - 1)) & " -- MIDI cc number for this slider" & return & "tell application id \"com.figure53.QLab.5\" to tell front workspace" & return & "try" & return & "set theselected to last item of (selected as list)" & return & "set thelevel to getLevel theselected row 0 column theslider" & return & "set thelevel to round ((thelevel - (notes of cue \"MIN\")) / (notes of cue \"STEP\"))" & return & "set byte one of cue \"MOP\" to theCC" & return & "set byte two of cue \"MOP\" to thelevel" & return & " start cue \"MOP\"" & return & "end try" & return & "end tell"
- move cue id (uniqueID of theselected) of parent of theselected to end of cue "SetS"
- end if
- if encoders is false then
- --make 128 cues triggered by cc values 0-127 to enable a group of 128 level setting cues when the encoder level matches the slider level and move to the group numbered Pick
- repeat with x from 0 to 127
- make type "network"
- set theselected to last item of (selected as list)
- --set the correct triggerfor the new cue
- set the midi command of theselected to control_change
- set the midi byte one of theselected to theMIDIcc + (cc - 1)
- set the midi byte two of theselected to x
- set the midi trigger of theselected to enabled
- set the parameter values of theselected to custom
- --set the OSC for the newcue
- set the custom message of theselected to "/cue/SetS" & (theMIDIcc + (cc - 1)) & "/armed 1"
- set the q number of theselected to "Pcc" & theMIDIcc + (cc - 1) & "_" & x
- set q name of theselected to "compare cc" & theMIDIcc + (cc - 1) & " value " & x & " to slider level for takeover"
- move cue id (uniqueID of theselected) of parent of theselected to end of cue "Pick"
- end repeat
- end if
- end repeat
- --disarm all level setting groups and cues
- if encoders is false then set the armed of cue "SetS" to false
- --disarm this generator script to guard against accidental operation
- set the armed of cue "GEN" to false
- end tell
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement