--create 128 MIDI cues to control a lighting parameter scaled to a range
set theIndex to 0
set theMin to 127 / (100 / 50) --Max MIDI Value/ (100/ Minimum Light parameter percentage)
set theMax to 127 / (100 / 70) --Max MIDI Value/ (100/ Minimum Light parameter percentage)
set theMIDIch to 1 --Channel of Physical MIDI controller
set theMIDIcc to 1 --Controller Number of Physical MIDI controller
set theMIDIccCh to 16 --Channel of QLab Light Binding for parameter
set theMIDIpatch to 1 --Number of MIDI patch to send MIDI to Light Dashboard
----Do not alter anything below this line
set theStep to (theMax - theMin) / 127
tell application id "com.figure53.QLab.5" to tell front workspace
repeat with theValue from 0 to 127
make type "MIDI"
set theSelected to last item of (selected as list)
--MIDI trigger set up
set the midi command of theSelected to control_change
set the midi byte one of theSelected to theMIDIcc
set the midi byte two of theSelected to theValue
set the midi trigger of theSelected to enabled
set the midi trigger channel of theSelected to theMIDIch
--set the MIDI message to be sent by the new cue
set thelevel to theMin + theValue * theStep
set thelevel to round (thelevel) rounding to nearest
set the byte one of theSelected to theMIDIcc
set the byte two of theSelected to thelevel
set the channel of theSelected to theMIDIccCh
set the message type of theSelected to voice
set the midi patch number of theSelected to theMIDIpatch
set the command of theSelected to control_change
set the q number of theSelected to "cc" & theMIDIcc & "_" & theValue
end repeat