MIDI controller value range as a macro trigger

Hello.
Is it possible to use a MIDI controller value range as a trigger for a macro?
For exmple:
MIDI CC#32 values 0-12 trigger macro 1
MIDI CC#32 values 13-24 trigger macro 2
etcetera.
If not possible then is the smartest way to use controller value ranges with %TriggerValue[3]% and somehow get it to a variable, then use conditional flows in one macro.
I would like to take one MIDI CC and split it to 10 more or less equal ranges, moving the controller would trigger 10 different actions. Specifically- change between 10 possible grid values in Dorico pro 5.

I tried control flow option and still- Switch/Case for example, I cannot set the value range of a variable there.
Seems silly if one has to process all midi CC values 0-127 separately. Maybe there can be some kind of calculation in between etc.
I am a dummy, cant find it.

I believe "not", so trigger on any change and use a Switch/Case action to branch. Middle cases missed out, but this should give you the idea:

image

Since 128/10 isn't a nice integer you'll have to decide how you distribute the "spare" numbers. The above uses chunks of 12 except the last, so values 109-127 all go to "grid 10".

1 Like

Thanks!
Of course Switch/Case is processed from top to bottom so I do not need to specify the ranges.
Thanks also for IF-Text, I will skip the making variable stage as unnecessary.

This works! But one more issue is there:
There has to be an inbetween calculation I think:
When %TriggerValue[3]% is in between 0-12: set variable to 1, between 13-24, set variable to 2 etc.
The action sends otherwise out too many keyboard shortcuts. I need a shortcut sent only when the CC value enters the next range.
So I try to enter one Switch/Case in front and convert MIDI CC values to Variable numbers 0-9.

EDIT: of course that did not change anything... I must only send the variable value further if it changes. Find out, how

Quick way -- in your "Case" statements, set a local variable to 1, 2, etc. After the Switch/Case, compare that number to number stored in a global variable. If it is the same, do nothing. If it is different you need to switch grids -- send the commands to do that to the software then store the new value in the global.

So the global keeps track of which grid you are on and you update it when you move to a new one. You may have to have another macro that resets the global when the app launches or you open a new document.

It would be better, if possible, to query the app to find the current grid instead of storing (potentially out of date) data in a global -- but that's still a lot of interaction with the app and may cause performance issues.

Because grid values are lksted in menu and active value is checkmarked, it would be easy to get the current grid value from app indeed.

Maybe -- or you may have to do a lot of "If menu item 1 is checked then set x to 1. Else if menu item 2 is checked set x to 2. Else...".

Meanwhile, here's one that uses maths to do the chunking and a global to decide whether or not to change. If the global does go out of date it'll be reset on the next MIDI change anyway, so it shouldn't be a problem.

As before 0-12 is 1, 13-24 is 2, etc -- which means 109-127 is all 10.

MIDI Chunks.kmmacros (6.5 KB)

Image

Thank you for help and for the lesson!