Convert CC to PC messages script not working

I’m sure it’s me but can’t figure why this simple script is not working. I get input from the device WORLDE so no problem there just the script to convert CC 23-38 to program change 0-15
Script below…

//Called when a CC message is received at some MidiIn device
//The CC numbers must be within the specified range

Var
    WORLDE : MidiInDeviceAlias
    PADNOTES : Integer Array = [23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38] // The note numbers for the 16 pads
    
// Converting the 16 for WORLDE buttons (CC 23 to 38) to PC messages 0 to 15
On ControlChangeEvent(m : ControlChangeMessage) Matching [23..38] from WORLDE

    
        InjectMidiEventViaRigManager(WORLDE, MakeProgramChangeMessage(GetCCNumber(m)-23))
    
End

Is that in the Rackspace script, Global rackspace script, or Gig script?

Gig script…

I just had a Quick Look to your Gig Script, but it seems to be correct.

What do you see in the Global MIDI monitor when acting on you controller?

The program Changes are for the rackspaces… The midi monitor shows the incoming CC’s 23-38

Maybe a silly question but in the options, there is a place where you define which devices are allowed to accept program changes. How is that configured?

I’m not at my computer so I can’t show a picture

It is page 307 of the manual:

Thanks I should have RTFM but GP is so intuitive I rarely need to look. The device wasn’t checked,I’ll remember that one in future but the script is still not working with that option checked. I took this routine from another controller script which changes pads which use note to PC and that works ok. Midi monitor still only shows the CC messages. It seems InjectMidiEventViaRigManager(WORLDE, MakeProgramChangeMessage(GetCCNumber(m)-23)) is not working. I am still trying to find the reason…

Eureka!
This now works with the added code…

Var
    LAUNCHKEY : MidiInDeviceAlias
 
// Converting the 8 Launchkey(I kept Alias Name for WORLDE buttons (CC 23 to 38) to PC messages 0 to 7
On ControlChangeEvent(m : ControlChangeMessage) Matching [23..38] from LAUNCHKEY
    if GetCCValue(m) == 127 then
        InjectMidiEventViaRigManager(LAUNCHKEY, MakeProgramChangeMessage(GetCCNumber(m)-23))
    end
End

Oh, when you said it didn’t work, I thought you meant the rackspace or song wasn’t being changed.

You meant that the GPScript code didn’t compile.

That said, are you trying to send a program change into a particular plugin or are you trying to change the rackspace or song using a CC message?

The script compiled without error but didn’t work until I added the If GetCCValue. All now works perfectly

Well, it is better so, but it only results in sending the same PC only once rather than several times. Sending it several times should also work. Or did I miss something?… :thinking:

What exactly are you trying to do with this script? Where is the created program change going?

If you’re trying to change rackspaces using CC numbers rather than program changes, here is a much easier approach -

You don’t need to inject messages nor do you need to create program change messages. You can just extract the incoming CC number, do the subtraction as you were doing, and then use a script function called SwitchToProgramNumber to directly switch to the desired rackspace.

Var
   LAUNCHKEY : MidiInDeviceAlias
   
Const
   FirstCC : integer = 23  // Naming the first and last CC number makes it easier to change
   LastCC  : integer = 38 //   the range later without having to modify hard-coded numbers all over the place

On ControlChangeEvent(m : ControlChangeMessage) Matching [FirstCC .. LastCC] from LAUNCHKEY
var
   desiredPCNumber : integer  // This is the program number we want to find
   
   if GetCCValue(m) == 127 
      then
         desiredPCNumber = GetCCNumber(m) - FirstCC   // Normalize so that the first CC represents program number ZERO   
         SwitchToProgramNumber(desiredPCNumber, 0) // Use GPScript function instead of injecting messages
   end   

End      

GP never ceases to amaze me, there’s always a way and an easier way to get things done. I love it!
Thank you…

1 Like

Alternative approach: How to set a widget to jump to a specific rackspace

Just assign the desired CC messages to widgets.