Q: MIDI packet trigger to match ANY note : how to

A dummy question. I would like to have a macro triggered when ANY key of my 88-key MIDI keyboard controller is pressed. When "MIDI Learn" is on, the lowest key produces this:


And the highest:

I can deduct that the "byte 2" field shows the MIDI key values 21 and 108, which indeed does make 88 values in total.
So the goal is to edit the trigger to allow any MIDI key value to trigger the macro.

I can think of two possible ways, but I can't test either of my ways because I don't have a MIDI device.

  1. Create a macro with 88 note triggers (not packet triggers, unless you like the pain)
  2. Replace 6C above with \S+ as that means any sequence of non-space characters. I'm not really certain that will work, but I suspect it will.

Will this not do it?

It does! Now…

There seems to be a bug (@peternlewis) which caught me out.

  1. Activate "MIDI Learn".
  2. Press a key.
  3. Turn "MIDI Learn" off.
  4. Change the "matches" value back to .*

The macro will continue to trigger on the previously set key value only.

To get the wildcard matching working again, remove the MIDI trigger and add it back again.

Thanks! I have now one final task. Using @Airy solution for a reason but I have one more issue:
The last 3 characters 00$ - the 00 means note off and 01-7F MIDI key velocities. So the last two characters before $ should match hex values 01-7F and NOT 00.
I want the macro triggered by note on message and not note off (00$)
Is this also doable?

Then you can replace 00 with \S\S or ask others for alternate solutions, which I'm sure there will be.

This should do it (right now I shall have to leave it for you to test in that MIDI action):

^0*?[1-9\D]\d*$

FYI: that $ just marks the end of the regex string.

1 Like

I based that on this recipe at regex101. I added the \D to allow characters other than digits (in practice, these will be in the range A – F for hexadecimal).

Thenk you @kevinb for the lesson and hint.
It took me a minute to understand that I have to combine things and my final pattern that works is:
^90 \S+ 0*?[1-9\D]\d*$
Now the macro indeed triggers on MIDI note on messages only.

1 Like

Yes, well done. I went to bed and realised I hadn't spelled that out, but I decided any clarification would have to wait till morning! :smile:

Great!