Incremental midi note value out | Intech Studio
💬 general Grid

Incremental midi note value out

Axel Harpøth · · 14 replies

I want to have a button output a new midi value everytime I press it. Like adding one to the midinote value everytime I press it, so it outputs, c, c#, d, d#, ..., Would this be possible?

Replies (14)

Greg-Orca Greg-Orca ·

You can add button step 127,

then use self:button_value() in the MIDI block Parameter1. To send the note’s full value, set Parameter2 to 127.

Screenshot_2025-09-25_at_14.01.36.png
Axel Harpøth ·

Crazy way to do it, but thanks

Hybrid Hybrid ·

Here's an alternative approach... Set a self:note variable in the Setup and then increment it on each button press. You can set your starting point by whatever value you assign to the self:note variable. I also added a check so it loops back to 0 once it reaches 127.

self.note = self.note + 1
if self.note > 127 then
    self.note = 0
end
image.png
narayb narayb ·

This will never turn the notes off, keep that in mind.

Axel Harpøth ·

Yeah i thought about that too

Axel Harpøth ·

perhaps unles I used button:state, instead of 127 in parameter 2

Greg-Orca Greg-Orca ·

Yes it was just an example to start with, I don’t know your exact usecase:)

Hybrid Hybrid ·

The world of MIDI is still a bit foreign to me but out of curiosity, how would you approach sending the note off command? Would you put it in the Release block? I guess that's also where you'd increment the note number...

narayb narayb ·

Well of course, it would depend on the use-case.

Your solution is good, just use -1 for param2 in the midi block and simplify the code part with a modulus.
You also shouldn't use the Press/Release to have the button trigger on both ways to actually release the notes.

Hybrid Hybrid ·

Thanks for the tips! 🙂

narayb narayb ·

It would look like this (just got to a PC to make an image to illustrate what I mean).

narayb narayb ·

(Even I messed it up.)

image.png
narayb narayb ·

It's actually quite tricky, because the button would run its event twice, so it would count up twice if you just used it without press/release.

Hybrid Hybrid ·

Ah yes, there are quite a few traps in this seemingly simple setup!
Even the modulus operator is tricky with having to use 128 instead of 127 so you can hit all the values. Sometimes I prefer to use more verbose code because it reduces the cognitive load. However, in the character limited environment of the Grid, I see why you used it!

Thanks for taking the time to illustrate it and point out these subtle details, it helps us learn!

Discord

View on Discord

This post is from the Intech Studio Discord community.

Open thread →