Midi Triggers From Any Black or White Key?

I'd like to trigger a macro by pressing any black key (or any white key) on a midi keyboard.

I could add 36 possible midi triggers, (and 52 white key midi triggers).
Is there a more elegant way than just adding midi triggers for every piano key?

I know I'm waaaayyyyy late to the party but this should do the job for any Note On:

Adjusting byte 2 could then narrow the key range if so desired.

Here's one way to trigger different actions per key:

Midi Note Trigger.kmmacros (22 KB)

Macro screenshot

I just learned about custom delimiters, so the macro can be simplified a bit. I've edited it above.

I've been digging into this further and have managed to distinguish between all white and all black keys; limiting this to a certain key range should also be possible; however:

Is there a way to access the third byte of the trigger (velocity)? %TriggerValue[3]% does not work for this; at least not in a reliable fashion.
Background: Note On with velocity 0 is the same as Note Off (and many keyboards use this); and in the current form this means that we would get a double trigger: once for pressing the key and once for releasing it.

Here's a typical MIDI TriggerValue:

90 2A 7F,MPKmini2

If we use a space as a dilimiter, it will be broken into three chunks. Note the space before the final %. This is where our custom delimiter is defined:

%TriggerValue[1] % is 90
%TriggerValue[2] % is 2A
%TriggerValue[3] % is 7F,MPKmini2

Now we can split the third chunk (7F,MPKmini2) using the default delimiter, the comma. First set chunk 3 as a variable, then access chunk 2 of this new variable, like so:

Get MIDI Trigger Values.kmmacros (20 KB)

Macro screenshot

You might find it more logical to do it the other way round -- split on the , first to separate the MIDI command and the device identifier, then split the MIDI command on %space% to get the channel, note, and velocity.

Split MIDI.kmmacros (2.9 KB)


1 Like

Yeah I guess so.