Invert MIDI CC values - from 0-127 to 127-0

I would like to ask the following question of other users who are more familiar with MIDIhub and its pipes.

I have a MIDI controller keyboard with an expression foot pedal attached (to send MIDI CC 11 data). The pedal (via the MIDI keyboard) sends a range of values from 0 (when the pedal is not depressed) to 127 (when it is fully depressed). I would like for all of the MIDI messages from the MIDI keyboard to pass through MIDIhub unchanged from its source to its destination (MIDI A to USB A), EXCEPT for the expression pedal values: I would like for those MIDI CC 11 expression values to be inverted: from 0-127 to 127-0.

Any suggestions, using the current available MIDIhub pipes?

Hey, try this:

Invert_CC_11.mhp (123 Bytes)

The first Transform pipe swaps the CC ID and Value places, so that CC Remap can invert the value as needed, and then another Transform puts it back into place.

In some future update, we plan to revisit the pipes to allow doing such operations in a more straightforward fashion. :slight_smile:

Btw. to avoid non-CC message duplication, add a Filter pipe to drop everything but Control Change messages in the 2nd line. Forgot to add that there myself. :slight_smile:

Thank you very much, Giedrius! :grin:

From experimenting, the following also seems to work.

The only thing that is a bit counter-intuitive are the labels for the parameters in the Rescale pipe: “In Low,” “In High” and “Out Low,” “Out High,” which could possibly be relabeled as something like “In From,” “In To,” and “Out From,” “Out To” (in case the user wants the rescaled range to be from a higher value to a lower value, such as in this case)


invert_CC_11_using-rescale.mhp (112 Bytes)


Ah, this works even better than my proposed solution! :slight_smile:

1 Like

In my experimental solution above (the 3rd post), the Rescale modifier successfully inverted the values from the expression pedal (MIDI CC 11), with the following settings:
Kind: Control Change
In Low: 0
In High: 127
Out Low: 127
Out High: 0

However, the following settings did not successfully invert the MIDI output values, which remained 0 when the expression pedal is not depressed, to 127 when the expression pedal is fully depressed:
In Low: 127
In High: 0
Out Low: 0
Out High: 127

So while the “Out” parameters seem to be interchangeable, using low/high OR high/low values for its two parameters, the values for the “In” parameters seem to require a lower value as the first parameter and a higher value as the second parameter.

It might be nice for there to exist a dedicated “CC Invert” modifier for MIDIhub which would invert a set of two values (such as 0 and 127, or 24 and 68), or the numbers of a range of values (such as 0-127, or 12-48).

A “CC Inverter” modifier might include two parameters for example, the first to specify which MIDI CC number(s) to apply the inversion to, and the second to specify which of two values or a range of values to invert. For example, the second parameter could be programmed to be user-edited to contain either a comma separated list of two values (like 0, 127 or 56, 12) or a hyphen-separated range (like 0-127 or 64-84). In the first (comma-separated) example, the modifier would invert the first value to the second value and vice versa (0 to 127 and 127 to 0, or 56 to 12 and 12 to 56), and in the second (hyphen-separated) case the modifier would invert each value within the range to its opposite (only the middle value of an odd-number range would remain unchanged).


Hey, we’ve released a fix for the In Low > In High case for Remap pipes.

:slight_smile: [Download] Midihub Firmware 1.11.8

Btw, we’ve noted the CC inverter pipe idea in our todo. :slight_smile:

1 Like

Thank you so much for MIDIhub firmware 1.11.8. It works perfectly so far to invert a range of values, including with the following settings:
In Low: 127
In High: 0
Out Low: 0
Out High: 127

And thank you so much for considering a dedicated CC Inverter pipe. :slightly_smiling_face:

MIDIhub was a great idea to invent, design and to bring into reality, and has been so nicely and thoughtfully implemented. I love that the MIDIhub and editor work perfectly in Linux (my primary OS) as well as Windows and Mac.


I want to do the same for note-on velocity and for note-off velocity.
But those are not CC values.
How do I extract note on and off velocity so I can invert them so a fast hit gives a low value and a soft/slow hit gives a high value?
And then the same inversion of the release as well?

Actually seems like the rescale object can do that, but unfortunately it seems as though I need to invert note-on velocity, but not invert note-off velocity.
Any way to treat note-on and note-off velocity separately and do all the operations that is possible for CC with them?

Hey, you can filter out Note On messages and Note Off messages using Filter pipe, so that way you may apply different effects on each message type, just use a couple of horizontal pipeline rows for each type. Virtual pipes may be helpful to share some of the common pipes.