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?
Incremental midi note value out
Replies (14)
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.
Crazy way to do it, but thanks
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
endThis will never turn the notes off, keep that in mind.
Yeah i thought about that too
perhaps unles I used button:state, instead of 127 in parameter 2
Yes it was just an example to start with, I don’t know your exact usecase:)
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...
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.
Thanks for the tips! 🙂
It would look like this (just got to a PC to make an image to illustrate what I mean).
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.
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!
View on Discord
This post is from the Intech Studio Discord community.


