How to...Block notes in the current octave

What would be the most efficient way to write this generic example code?
if (noteOn)
for (int i = 0; i < 128; i++)
if (i != noteOn)
block(i)
But the dream is to lock all other keys in the current octave (or arbitrary selection) when you push a key on your MIDI keyboard. This would allow me to assign 1 note per octave so i now essentially have a 5 note keyboard that i can play wild without looking down at it :slight_smile:

Are you sure this is what you want? I don’t see any note-off messages so you would definitely have stuck notes. What you are asking would involve a combination of repeating timers and global variable to track the notes that you want to no longer play.

Steve Caldwell
Bome Customer Care


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

NoteBlock.Unblock.bmtp (4.4 KB)

This is a tiny mockup using only 3 notes where 2 of the notes blocks the other 2 from triggering (but one note allows everything to go unhindered). It works but want to make sure if this is “the way” and if there is an easier more efficient path of doing this. Never used any timers but global variables is definitely a must.

I achieved what i was after in Ableton but im not impressed with the cpu usage…hoping bomes will lower it.

Hi,
Still struggling with the logic. Is this what you are looking for?

40 = Red - Unblocks Everything when pressed
41 = Blue - Blocks Red and Yellow when pressed unblocks when released
42 = Yellow - Blocks Red and Blue when pressed unblocks when released

Steve Caldwell
Bome Customer Care


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

Here is what I came up with.

I use a global variable ‘ga’ for a bitmap of notes pressed where bit 0 is red, bit 1 is blue and bit 2 is yellow

I have translators that turn on the note (set bit the bitmap) when pressed and turn off the note (clear bit in the bitmap) when released. Neither one of them has an outgoing action.

I offset the bitmap by 40 which is the starting note you used.

Then I have a translator with Note-On that compares the incoming note bitmap with the notes pressed bitmap.

If bit 1 is set (red), we allow the note through
Otherwise, if any other note is set than the note pressed, the outgoing note-on is suppressed.

The final translator always allows note-off messages to go through.

I enabled Logging with the message ‘Log’. So if you just want to see log message, you can enter the filter ‘Log’ in the log window.

This bitmap would handle up to 32 bits which is the size of a global variable. If you want 128 notes, you would have to do similar with 3 other global variables (4x32 =128).

I also set up a preset for project initialization to make it easier housekeeping and documentation and management of global variables. See this tutorial.
I also setup aliases for the project. You can learn more about aliases from this tutorial.

Block-Note-sjc-2023-03-25.bmtp (3.8 KB)

Steve Caldwell
Bome Customer Care


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

Fantastic code, the bitmap is great!!! Still trying to completely understand the logic (and language) after couple hours of adding logs to your code (I’m getting there).

I like how red allows yellow and blue to be unhindered but how can we make it so red is still blocked when either yellow or blue is triggered first?
Also :slight_smile: would this scale with relative ease? I’m (actually) going to have many “colors” block and/or unrestrict other “colorsl”…going to be rainbow spaghetti. I plan to you use 64 notes in total organizing them into around 10 different colors.

Thank you Steve…and I’ll check out those tutorials too

Here is part of your code for reference:
if pp<40 then exit rules, skip Outgoing Action
if pp>42 then exit rules, skip Outgoing Action
// adjust note number for bitmap
rr=pp-40

// incoming note number
// rr=0 red
// rr=1 blue
// rr=2 yellow
// convert to bitmap
ss=1<<rr

// get value of ga
tt=ga
// if red is set then unblock everything
//mask red bit
uu=tt&1
if uu==1 then Log ‘Log Red Pressed’
if uu==1 then Goto ‘Done’

// compare ss (bitmap of incoming note) with bitmap (tt)
Log ‘Log ss=%ss% tt=%tt%’
// if any other bits are set, then block output
if ss!=tt then Log ‘Log Note-On %pp% suppressed’
if ss!=tt then exit rules, skip Outgoing Action

Label ‘Done’
Log ‘Log Note-On Note %pp%’

It will scale pretty well up to 32 notes, then you have to look at other global variables to determine if another note is pressed.

Steve Caldwell
Bome Customer Care


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