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
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?
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…
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
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?…
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