Using a Control Change Message to increment incoming Program Change Messages

Hello, I am new to scripting in GP.
I have a Novation Launchkey MK3, in which I have assigned my Drum pads to send Program Change Messages ranging from 0 to 15, to change Rackspaces. But I want to be able to trigger more than 16 Rackspaces. Therefore, I need to assign CC 103 to increment the incoming Program Change messages by 16, so that when I press CC103, my drum pad which used to trigger PG 0, would trigger PG 16… the drum pads triggering PG 1 would trigger PG 17 and so on…
Can anyone please help me? I need this to work urgently for a gig.
Thank you all in advance.

Do you need to be able to jump around between random rackspaces, or are you commonly just moving forward through the rackspaces, one at a time?

If you do want the control banks of 16, do you have another button to use as ‘previous’, as otherwise you could be stuck if you accidentally increment too many?

I do need to jump between rackspaces.

Yes, you are correct. I have a “previous” button on my keyboard, mapped to CC102. It should also be mapped to decrement the incoming PG messages by 16 in case I need to access the previous rackspaces.

This method using a Gig Script (via Window > Show Gig Script Editor) to intercept the PC messages and CC messages from your controller to manage the rackspace changes and the tracking of which bank of 16 you are on.

For this to work, give your controller an alias via GP’s Rig Manager, and then replace XTOUCH below with your alias name.

The only limitation with what I’ve done, is that you get no on-screen feedback of which bank you are on.

Var
    XTOUCH : MidiInDevice
    Bank : Integer = 0
    RacksInBank : Integer = 16
    
On ProgramChangeEvent(m : ProgramChangeMessage) from XTOUCH
    SwitchToRackspace(GetProgramChangeNumber(m) + RacksInBank * Bank, 0)    
End

On ControlChangeEvent(m : ControlChangeMessage) Matching 102 from XTOUCH
    Bank = Bank - 1
    If Bank < 0 Then Bank = 0 End
End

On ControlChangeEvent(m : ControlChangeMessage) Matching 103 from XTOUCH
    Bank = Bank + 1
End

I tried it but even without triggering CC 103, my pad assigned with PG 0 is switching to the first rackspace irrespective of the rackspace’s assigned PG number.

Oh, I wasn’t aware you had explicit PC numbers mapped to the rackspaces. In that case, the ‘SwitchToRackspace’ function will need to be substituted with something else to pass through an adjusted PC message.

Var
    XTOUCH : MidiInDevice
    Bank : Integer = 0
    RacksInBank : Integer = 16
    
On ProgramChangeEvent(m : ProgramChangeMessage) from XTOUCH
    Var NewPC : Integer = GetProgramChangeNumber(m) + RacksInBank * Bank
    InjectMidiEventViaRigManager(XTOUCH, MakeProgramChangeMessage(NewPC))
End

On ControlChangeEvent(m : ControlChangeMessage) Matching 102 from XTOUCH
    Bank = Bank - 1
    If Bank < 0 Then Bank = 0 End
End

On ControlChangeEvent(m : ControlChangeMessage) Matching 103 from XTOUCH
    Bank = Bank + 1
End

Oh my God! It finally is working… Thank you so much it saved my life!!

By the way, I had to change RacksInBank variable to 8 instead of 16, otherwise triggering CC 103 was incrementing by 32 instead of 16.

And one more request, please! Can I choose that only the PG numbers from 0 to 15 get incremented or decremented and not all PG numbers?

This was caused because I wasn’t testing the received CC for the value 127, so it was actually incrementing on both press and release of the button. I will fix this.

Oh, I got it. Still, thank you so much for this.
Can you look into my last request, if possible?

Var
    XTOUCH : MidiInDevice
    Bank : Integer = 0
    PCperBank : Integer = 16
    
On ProgramChangeEvent(m : ProgramChangeMessage) from XTOUCH
    Var PC : Integer = GetProgramChangeNumber(m)
    If PC < 16 Then 
        PC = PC + PCperBank * Bank
    End
    InjectMidiEventViaRigManager(XTOUCH, MakeProgramChangeMessage(PC))
End

On ControlChangeEvent(m : ControlChangeMessage) Matching 102 from XTOUCH
    If GetCCValue(m) == 127 Then
        Bank = Bank - 1
        If Bank < 0 Then Bank = 0 End
    End
End

On ControlChangeEvent(m : ControlChangeMessage) Matching 103 from XTOUCH
    If GetCCValue(m) == 127 Then
        Bank = Bank + 1
    End
End
1 Like

Worked like a charm!!!

I just had to add an “End” after this line.

Again, you saved my life… Thank you sooo much for this :heart_eyes: :innocent:

1 Like

No problem. You might have had to scroll within the code window to see the last “End” (as it was obscured in my browser as well)

Yeah… Got you