Same three CC values for many hardware controls... and Rig Manager

Indeed - given the pattern of this test, there is no need to test CC99 and CC98 test up to 5 times or call call CC_msg.GetCCValue() up to 5 times

Here’s a simple improvement with just a single test and a single call to the Inject - I haven’t tried to compile but it should work

var
    newCCNumbers : integer array = [32, 48, 64, 80, 95] // Map old CCs to new CCs
   
   // Then later on in the ControlChange callback ....

   if CC99 == 2 && CC98 == 5
      then            
         InjectMidiEventViaRigManager(XK5, MakeControlChangeMessageEx(111, newCCNumbers[CC_msg.GetCCValue() - 62], 16));                  
   end 
1 Like

Thanks @dhj… i was able to get it to compile however if i press the up or down octive buttons more than one time nothing happens and I get this message:

Gig (GigScript) - Array index out of bounds: index (zero-based) = -60: Current array length = 5

Nothing will work after this unless I recompile the script.

Interestingly though… I can get the buttons to function as desired if I recompile the script after every button press. Perhaps this is a clue?

here’s the full script as I have it now:

Var
  XK5                        : MidiInDeviceAlias // Define XK5 as a RigManager alias to the real controller
  CC_State, CC99, CC98       : Integer = 0;  
  newCCNumbers : integer array = [32, 48, 64, 80, 95] // Map old CCs to new CCs
   

On ControlChangeEvent(CC_msg:ControlChangeMessage) Matching 99,98,6 from XK5
    Select
      CC_State == 0 Do if (CC_msg.GetCCNumber()==99) Then CC99 = CC_msg.GetCCValue(); CC_State = 1 Else CC_State = 0 End
                       
      CC_State == 1 Do if (CC_msg.GetCCNumber()==98) Then CC98 = CC_msg.GetCCValue(); CC_State = 2 Else CC_State = 0 End
    
      CC_State == 2 Do
        if (CC_msg.GetCCNumber()==6)
        then
          Select
			// Leslie Stop => CC#102
            CC99 == 6  && CC98 == 9  Do InjectMidiEventViaRigManager(XK5, MakeControlChangeMessageEx(102, CC_msg.GetCCValue()*127, 1));
			
            // Leslie Fast => CC#103
            CC99 == 1  && CC98 == 9  Do InjectMidiEventViaRigManager(XK5, MakeControlChangeMessageEx(103, CC_msg.GetCCValue()*127, 1));
            
            // Overdrive Depth => CC#104
            CC99 == 2  && CC98 == 48 Do InjectMidiEventViaRigManager(XK5, MakeControlChangeMessageEx(104, CC_msg.GetCCValue(), 1));
			            
            // Effect Amount => CC#105
            CC99 == 8  && CC98 == 48 Do InjectMidiEventViaRigManager(XK5, MakeControlChangeMessageEx(105, CC_msg.GetCCValue(), 1));
			            
            // Reverb Depth => CC#106
            CC99 == 2  && CC98 == 10 Do InjectMidiEventViaRigManager(XK5, MakeControlChangeMessageEx(106, CC_msg.GetCCValue(), 1));
						
            // Overdrive => CC#107
            CC99 == 0  && CC98 == 48  Do InjectMidiEventViaRigManager(XK5, MakeControlChangeMessageEx(107, CC_msg.GetCCValue()*127, 1));
						
            // Effect => CC#108
            CC99 == 4  && CC98 == 48  Do InjectMidiEventViaRigManager(XK5, MakeControlChangeMessageEx(108, CC_msg.GetCCValue()*127, 1));
						
            // Reverb => CC#109
            CC99 == 0  && CC98 == 10  Do InjectMidiEventViaRigManager(XK5, MakeControlChangeMessageEx(109, CC_msg.GetCCValue()*127, 1));
						
            // Bypass Leslie => CC#110
            CC99 == 0  && CC98 == 9  Do InjectMidiEventViaRigManager(XK5, MakeControlChangeMessageEx(110, CC_msg.GetCCValue()*127, 1));
          End  
        end
        if CC99 == 2 && CC98 == 5
      then            
         InjectMidiEventViaRigManager(XK5, MakeControlChangeMessageEx(111, newCCNumbers[CC_msg.GetCCValue() - 62], 16));                  
   end 
     End
End

Because I assumed there were only 5 possible values based on your example, 62,63,64,65 and 66

this is true, there are only 5 values that come from those buttons.

If i compile the script and I am on no octive change (64) and I push the button once to drop the octive, i send CC6 value of 63. If I then press the button up again to return to the value of 64, I get teh Array index out of bounds error.

I am not sending any other values than those 5 values.

The individual script lines worked, those were the only values being sent on CC6.

Here is what Global Midi Monitor is hearing:

That is me pushing the down octive and up octive buttons through the range.

Just before line 32234 I compile the script, then the script works once, then stops and Global Midi Monitor again displays NRPN.

As I said, I didn’t test it….also, you’re using it in a more complicated script, there may be other factors.

I also don’t understand why you have it as a separate IF test rather than another item in the SELECT clause.

Maybe just go back to the version that worked for you. My replacement was just to demonstrate how to make your original code segment simpler, I’m can’t debug your entire script, sorry.

1 Like

That was the issue, that and the code expected do instead of then once that was moved up into the select clause.

Except… now that breaks the rest of the code.

The octive buttons work fine but any of the other buttons now break the code.

The array doesn’t seem to be compatible with any other incomming instance of CC6 with any value other than those integer array values despite that they are being sent with different CC99, CC98 commands.

I think what you have to do is something like that:

CC99 == 2 && CC98 == 5 Do InjectMidiEventViaRigManager(XK5, MakeControlChangeMessageEx(111, CC_msg.GetCCValue(), 1));

This will generate a CC#111 with the value adjusted by your two buttons, as if it were a knob. Once done it could be interesting to check in the MIDI monitor if it covers the regular MIDI range from 0 to 127. If not what is the range covered? Then tell us which value you want to use and what for . Your array can be coded in a widget curve, which in my opinion is much cleaner as doing range conversion within a Gig script. This way you define/change what the controller button can achieve in each rackspace.

@David-san yes, that does adjust the octive buttons as if they were a knob but the range it covers is only 3 semitones.

With each press of the button the value should move up or down +/- 12 semitones.

I have the same knob based code running on other parts of the XK so I mapped one of those to CC111 and tested the intervals at which I get the correct trasnposition. They are already defined in some of the above examples but those array values would be: [32, 48, 64, 80, 95]

@dhj’s last script suggestion worked but at the expense of all the other functions in that script so how we’re defining things with your original script isn’t jiving with DHJ’s array example.

I am not a coder but it would seem to me if we want CC6 to be any value between 1-127 for some select examples of CC99 and CC98 (like my Leslie Speed switch or my Reverb Depth knob) but for a specific select of CC99, CC98 (these octive buttons) we want it to isolate to an array, something in the code needs to establish both these as mutually exclusive possibilites with out interupting each other.

As a friend of mine observed, “no good deed goes unpunished”

Go back to using the original version :grinning:

It is very easy with a step curve to convert a MIDI input range 0…127 to [32, 48, 64, 80, 95]. But, it is very difficult to produce a curve which does the same for the restricted range 62…66 as you want to jump from one octave at each button pushed. So, keep with the former GPScript. :wink:

But I am worrying about this :thinking::

not sure why you’re worring about that… or why it’s the case. :wink:

I’m more interseted in this question, which I asked above in a different way:

Do NRPN situations like this mean having values of 1-127 and an array of specific values are not possible together because they are referencing the same CC#?

I’ve reverted back to the script where the octives each have their own line of script.

Sorry, but I am not sure to understand this question. :face_with_monocle: