MIDI Filter for Sustain Pedal

Well, if you start scripting, this is the Scriptlet version with the rescale function in it:

On ControlChangeEvent(m : ControlChangeMessage) Matching 64 
Var CCValue : integer = m.GetCCValue();
    rescaledCCValue : integer; 
    if (CCValue > 0)
    then
      rescaledCCValue = ScaleInt(CCValue, 80, 127, 0, 127);         
      SendNow(MakeControlChangeMessage(64, rescaledCCValue));
    end
End

It it works for you, as I explained earlier, you can rather use the a gig script for that:

var
   LGPP : MidiInDeviceAlias

On ControlChangeEvent(m : ControlChangeMessage) Matching 64 from LGPP
Var CCValue : integer = m.GetCCValue();
    rescaledCCValue : integer;
    if (CCValue > 0)
    then
      rescaledCCValue = ScaleInt(CCValue, 80, 127, 0, 127);       
      InjectMidiEventViaRigManager(LGPP, WithCCValue(m, rescaledCCValue));
    end  
End

Replace LGPP by the MIDI port alias defined in Rig Manager for the MIDI port where your sustain pedal is.

Orā€¦ buy a good working sustain pedal :stuck_out_tongue_winking_eye:

1 Like

Just a nit but Iā€™d put that rescaledCCValue assignment inside the block before the Inject. Why calculate it if you donā€™t need it?

You are very right. Usually I even donā€™t use intermediary variables, I put everything in the SendNow/Inject line. But it is more difficult to read when someone else has to. I modified the code.

Yeah, at some point Iā€™d like to allow variables to be declared ANYWHERE in a function but I just havenā€™t had time to think about that.