MIDI Filter for Sustain Pedal

My situation is that I have a somewhat broken keyboard which on sustain pedal use sends only numbers on CC64 between 80 and 127 und sometimes randomly send 0s.
Im looking for a filter solution to filter those 0s out and maybe remap the 80-127 to 1-127.

What could be the best way to achieve this in Gig Performer?
I tried some plugins, but MIDI Filter Plugins all seem to be very old and therefore not available in x64 so I can’t get them loaded in GP.
I messed around a little bit with GPScript, but no success there yet.

Any idea? :slight_smile:

Yes you can use a MIDI learned widget to your pedal with a recale curve. Than you can map this widget to a plugin parameter. This plugin parameter could even be the CC#64 of a MIDI in block. Does this solves your problem?

I’m… actually not sure what you are trying to say.
Can you elaborate what would I have to do? What is a “widget midi learns” and a “recale curve”?

My goal is to further use the pedal and just filter the erronous messages out, not to replace it by a widget, if that was your suggestion. (Could be a bit clungy to play piano pieces and use a mouse whenever pedal is required :D)

Might be that your problem can not be solved:
You want to scale cc64 80-127 to 1-127. This of course is possible using the input scaling function of GP.
You cannot filter out “wrong” cc64 0, because the software does not know if the cc is not wanted or is simply sustain off.
Therefore your sustain would switch on - but never off.

Have you tried a different sustain pedal?

This is much more likely to be a sustain pedal problem rather than your keyboard? Also, are you by chance plugging that pedal into an “expression” input? Sustain pedals should only have two values, 0 and 127

Here is a gig file which rescales a pedal widget from 80-127 to 0-127:

rescaled_CC64.gig (24.4 KB)

First read the following part of the manual:

Who suggested this to you?

You can already start with this, if it works for you, we could also think of a gig script. But, first let us know.

1 Like

Not exclusively, mine produces contineous CC64 values which is usefull as my piano plugin supports sustain half-pedaling.

@Stoffel Well, filtering out the “wrong” 0s should be easy as there are no “right” 0s. :smiley: Sustain offs would be around 80.

@dhj I already tried a different pedal - while that one only has 0 and 127, the keyboard still phases in incorrect 0s. Correcting that would be quite undoable.

@David-san Thats some information, thank you! :slight_smile: Will read and try ASAP. From my first impression, maybe I just misjudged the power of widgets (therefore not understanding your intial answer :wink: )

Fair enough - I’ve never used such a pedal myself

I have the Kawai version of this one: Studiologic SLP3-D

Ok, so the mapping works, cool! :slight_smile:
What is missing though is the more important part: Filtering out the (faulty) 0s. How can I achieve that?

How will you differentiate a real 0 from a faulty one?

There are only faulty 0s - real values are only between 80 and 127!

Or in Programming words, what I want to achieve is:

if (val > 80) send(val - 80 * 2.7) else doNothing

So use GPScript, preferably in a gigscript, to fix the problem programmatically.

Yeah, as in the initial post mentioned, I tried, but had no luck so far. Maybe im getting wrong where a script can/should be placed or which types I need (MidiInput something)?

So, here is a concrete Script I tried within a Scriptlet:

On ControlChangeEvent(m : ControlChangeMessage) Matching 64 

    if (m.GetCCValue() > 0)


What Im Getting is:
Scriptlet (Scriptlet) - - Syntax Error in “Main”: Line 3, Col 5: Unexpected or unrecognized token: ‘if’
Mismatched input ‘if’ expecting End

Add a “then” and an “end”

On ControlChangeEvent(m : ControlChangeMessage) Matching 64 
    if m.GetCCValue() > 0 then

The “Gig Script” that @dhj mentioned is the best option, as it’s acting globally and is taking effect at a very early stage in GP.

See an example here:

You don’t want to do this in a scriptlet - it should be in the GigScript as this is something that applies (I assume) to everything.

Below is a (working) example that I use in my GigScript to reverse the polarity of a sustain pedal that behaves backwards with the particular keyboard to which it is connected.

You need to make sure your keyboard is defined with an alias for it and then you use that name in the declaration (mine was called TopSurface)

Obviously change the implementation of the ControlChangeEvent

   Print("Auto Loaded - reverse sustain pedal polarity")

   TopSurface : MidiInDeviceAlias

//Invert the sustain pedal plugged into the A800 controller

On ControlChangeEvent(m : ControlChangeMessage) Matching 64 from TopSurface
   var val : integer = 127 - m.GetCCValue()

    InjectMidiEventViaRigManager(TopSurface, WithCCValue(m, val))