Switching widget functionality

I made an example for a rackspace script with three white and three black faders.
Depending on the postion of the “Destination switch”, either the white or the black faders will react on
incoming CC# messages on numbers 20, 21, 22 (change the numbers in the script to your needs).
That might be something you could adapt and expand for your rackspace, just add more items to the arrays and the “Select” statement.

destination switch

switch destination.gig (98.3 KB)

This is the code i used:

var
MIDI_in : MidiInBlock
swt_changeDest : widget //switch destination of CC#
fdr_w1, fdr_w2, fdr_w3 : widget // wihte faders
fdr_s1, fdr_s2, fdr_s3 : widget // black faders

ccNrs : integer array = [20, 21, 22] // incoming cc# for the three faders

faders_white : widget array = [fdr_w1, fdr_w2, fdr_w3] // array for white faders
faders_black : widget array = [fdr_s1, fdr_s2, fdr_s3] // array for black faders

// User function to move either the black or white faders, depending on the destination-switch position
function MoveFader (index : integer, ccNr : integer, ccVal : integer)
    If GetWidgetValue(swt_changeDest) >0.6 Then
        SetWidgetValue (faders_white[index], MidiToParam(ccVal))
    Else
        SetWidgetValue (faders_black[index], MidiToParam(ccVal))
    End
    SendNow (MIDI_in, MakeControlChangeMessage(ccNr, ccVal))
End

//Called when a CC message is received at some MidiIn block
On ControlChangeEvent(ccMsg : ControlChangeMessage) from MIDI_in
var
ccNr : integer = GetCCNumber(ccMsg)
ccVal : integer = GetCCValue(ccMsg)

    Select
        ccNr == ccNrs[0] do MoveFader (0, ccNr, ccVal) //CC# array item 1
        ccNr == ccNrs[1] do MoveFader (1, ccNr, ccVal) //CC# array item 2
        ccNr == ccNrs[2] do MoveFader (2, ccNr, ccVal) //CC# array item 3
        // as many as you need

        //Optionally include this for when none of the above matched
        True do SendNow (MIDI_in, MakeControlChangeMessage(ccNr, ccVal))
    End
End
5 Likes