MIDI keyboard : can we know keys depress state?

Hello !

I’ve made an octaver with MIDI tranlsator pro, so I can play a note + its octave up. Each incoming note ON message in MIDI translator pro is stored in a local variable (uu), which I transpose one octave up (uu = uu+12) and pass it to the output (with the same velocity as the incoming note ON message), along with the original note ON message. Same process with the note OFF message.
It works but I’m facing an issue : let’s say I’m playing C3 and C4 at the same time. When I depress the C3 and C4 keys, MIDI translator will receive note ON messages for C3 and C4, and will output note ON messages for C3, C4 and C4, C5 (so actually C3, C4, C5). But then if I release C3 while keeping C4 depressed, MIDI translator will receive note OFF message for C3 and will output note OFF messages for C3 AND C4. So only C5 will still be playing while C4 key is still depressed.

So I actually need a way to prevent note OFF messages to be send to the octave if the actual upper octave key is depressed (if I release C3 and stil have C4 depressed, I need MIDI translator NOT to send C4 note OFF message).

To be able to do that, I need to know the state of the keys (depressed or not). Is there any way to check at any time the state of the keys on a MIDI keyboard ?

It could be done by storing the Note On and Note Off messages in global variables for each note, but that would mean using 127 variables, and storing them in a table, which I’m not sure MIDI translator is capable of (nor having 127 global variables).

Any ideas to be able to do this would be welcome. Thanks a lot ! :slight_smile:


This should help get you started. I do not use 127 global variable yet I bit map the key state of all notes into 4 global variables:

g0 - For notes 0-31
g1 - For notes 32-63
g2 - For notes 64-95
g3 - For notes 96-127

Every time I press a note (note-on), I check which global variable to use and set a bit.
Every time I release a note (note-off), I use the same logic to clear the bit.

So now in other translators (that I have not created), you should be able to look up the note’s on/off state by looking at a given bit in the appropriate global variable.

I’ve commented the rules to help you understand the logic.

You will need to use bit shifting logic to check if a bit is set (1) or clear (0).

This post should help with that.

Note-On-Off-Bitmap.bmtp (2.3 KB)

Steve Caldwell
Bome Customer Care

Also available for paid consulting services: bome@sniz.biz

Thank you so much Steve, exactly what I was looking for ! :+1:

(I guess the first line on the MT pro file should be if pp>=96 then rr=3 rather than if pp>=86 then rr=3 )

No, 96 to 127 is 3

1 Like