Make MIDI script

61 views
Skip to first unread message

Tom aspley

unread,
Jun 9, 2022, 4:37:07 AM6/9/22
to QLab
Hello, Me again!

So continuing on from my add to group question (which now works), Ive a script that should make a CC MIDI cue (to fire a Digico snapshot) where it searches for other CC MIDI and then makes byte two the next available integer.

The script works fine until you get to 16-127, it then makes 17-0 correctly but then gets stuck there and keeps making cues of 17-0.  

Interestingly, if I manually add a CC MIDI cue of 17-0 it then it references that correctly and carry on to 17-1.

Any ideas?

Cheers 
Tom


--Create Group--
tell application id "com.figure53.qlab.4" to tell front workspace
    display dialog "Insert Cue Name:" default answer "Cue Name" with title "Cue Name" with icon 1 buttons {"Cancel", "OK"} default button "OK" cancel button "Cancel"
    set changeAmount to text returned of result
    set customnameone to changeAmount
    tell application id "com.figure53.QLab.4" to tell front workspace
        make type "group"
        set newCue to last item of (selected as list)
        set mode of newCue to fire_all
        set q name of newCue to customnameone
        set groupToGoInto to newCue
    end tell
   
    --Search for already used CC MIDI--
    set SSCh to 16 -- Set MIDI Channel to search
    set SSCC to 16 -- Set CC byte one to to start at
    set SSNo to -1
    set midiCues to every cue whose q type is "MIDI"
    set midiCuesRef to a reference to midiCues
    repeat with eachCue in midiCuesRef
        if command of eachCue is control_change and channel of eachCue is SSCh then
           
            set byteTwo to byte two of eachCue
            set byteOne to byte one of eachCue
           
            if byteTwo is greater than SSNo then
                set SSNo to byteTwo
               
                if byteOne is greater than SSCC then
                    set SSCC to SSCC + byteOne - SSCC
                   
                end if
            end if
        end if
    end repeat

    set SSNo to SSNo + 1
    if SSNo is equal to 128 then
        set SSCC to SSCC + 1
        set SSNo to 0

    end if
end tell

-- Create DiGiCo snapshot cue --
set userCueName to "DiGiCo Snapshot"
tell application id "com.figure53.QLab.4" to tell front workspace
    make type "MIDI"
    set newCue to last item of (selected as list)
    set newCueId to uniqueID of newCue
    set listThatIAmIn to parent of newCue
    move cue id newCueId of listThatIAmIn to end of groupToGoInto
    set command of newCue to control_change
    set channel of newCue to SSCh
    set byte one of newCue to SSCC
    set byte two of newCue to SSNo
    set q name of newCue to userCueName & " (Ch 16 / CC " & SSCC & " - " & SSNo & ")"
    set customnametwo to userCueName & " (Ch 16 / CC " & SSCC & " - " & SSNo & ")"
    end tell



make midi cue in a group.qlab4
Reply all
Reply to author
Forward
0 new messages