Using BU16 button to increment value of EN16 | Intech Studio
✅ solution Grid

Using BU16 button to increment value of EN16

ulfopulfo
ulfopulfo · · 49 replies

Hi all!
So I’m setting up for an upcoming concert, which will allow a lot of presets in Ableton. Right now I’m using an encoder of my EN16 to switch through my different instruments.

It works great, but some changes will need to be done very fast. Som I’m thinking that 2 buttons on my BU16 could be used to instantly increment / decrement one step.

Since I’m new to lua and the grid editor in general, I don’t really know how to to this. Thr buttons would need to read the value of the encoder, change it one step up or down depending on the button pressed, send out the value and change the stored value of the other module’s encoder.

Any tips?

Replies (49)

narayb narayb ·

Immediate send is used to change values on other Grid modules usually.

What you could do is to send an immediate send message to the en16 and change one of the values of its encoders.

Then you would trigger that encoder as well in the same message to send the midi out.

narayb narayb ·

This can be done in a code block quite simply, I'll give you an example tomorrow.

ulfopulfo ulfopulfo ·

And this is possible to do between different generations as well, right? My EN16 is Generation 2, BU16 is 3

ulfopulfo ulfopulfo ·

You're the absolute best!

narayb narayb ·

Yeah, even old Series 1 modules are able to do this!

narayb narayb ·

Okay, so the function you will need on the BU16 button will look like the following:

immediate_send(x,y,"element["..n.."]:encoder_value()+1")

-- this will increment the n-th encoder value by 1 on the module that is x modules to the east from the BU16 and y modules to the north from it
narayb narayb ·

The code itself is kind of ugly, but you can read about how it works here.

Let me know if you have any questions or you managed to try it out!

As a real-world example would be:

immediate_send(1,0,"element[0]:encoder_value()+1") <- this code increments the first encoder of a module to the right of the BU16

ulfopulfo ulfopulfo ·

Thank you so much! Will try it out tonight and I'll get back to you!!

ulfopulfo ulfopulfo ·

I've been trying to make it work, but no luck so far...

If I give a fixed value inside the parenthesis, it works, but this code gives me an error. I guess it has to do with the "+1" thing in some way?

My setup is: Encoders to the left, Buttons to the right. I think I understood the address syntax correctly, right? So one step to the left on the same y axis is (-1, 0), yes?

This error gets printed when I move the targeted encoder after pushing the button.

I use the button (and encoder) in the south west corner, first button on the lowest row. I believe that's element 12, right?

Also, I would like for the button to output the MIDI message from the updated encoder. So that my DAW recieves it and changes preset.

Sorry for my crappy coding skills and thank you again for your help!

Screenshot_2025-07-24_at_19.06.28.png
narayb narayb ·

Oh you're right, I forgot to include the trigger

narayb narayb ·

I'll fix it up in a moment. I actually just wrote the code on the fly, did not have the time to test it.

ulfopulfo ulfopulfo ·

I experimented a little and this code removes the error message.

But for some reason beyond me, it also makes the encoder increment 2 steps instead of one? So depending on which way I move the encoder one step to check afterwards, i either get 1 increment (if I move the encoder one step counter clockwise) or 3 increments (if I move the encoder one step clockwise).

Oh well, one step closer!

Screenshot_2025-07-24_at_19.43.54.png
ulfopulfo ulfopulfo ·

Oh hold on, It's probably because my button sends out the message twice! Both on press down and release!

narayb narayb ·
immediate_send(nil, nil, "element[0]:encoder_value(element[0]:encoder_value()+1); element[0]:ec()")

This should be working much better!

narayb narayb ·

instead of nil, you should just use -1, 0

narayb narayb ·

My previous solution was very incomplete, just use this one!

narayb narayb ·

But you're also right about buttons triggering twice!

ulfopulfo ulfopulfo ·

THANK YOU!

ulfopulfo ulfopulfo ·

It works great!

ulfopulfo ulfopulfo ·

2 things left for me:

  • How to only trigger this code when pressing the button, not releasing it
    (Some kind of if statement in the code? Not sure)

  • How to respect the 0-127 boundaries of my MIDI CC message that is triggered.
    (When I move my encoder to 0 or 127, it respects the boundaries and does not send out messages below or above those limits. But the +1 code just increments thevalue and sends it out.)

narayb narayb ·

I would recommend using the Press/Release block on the button.

narayb narayb ·

The +1 doesn't respect it that's true

narayb narayb ·

The easy way to solve that is is like this:

narayb narayb ·
immediate_send(nil, nil, "element[0]:encoder_value(element[0]:encoder_value()+1%(element[0]:encoder_max()+1)); element[0]:ec()")
ulfopulfo ulfopulfo ·

Done! Yay!

narayb narayb ·

We use the modulus of the max+1 of the encoder

narayb narayb ·

Which would be normally 128, and modulus of 128 can't go higher than 127

ulfopulfo ulfopulfo ·

It doesn't work I'm afraid

ulfopulfo ulfopulfo ·

It just keeps going up above 127 if I continue to press the button several times

narayb narayb ·

I made two mistakes, modulus loops back around

narayb narayb ·

And also I missed a ()

narayb narayb ·

Okay my last try

narayb narayb ·

This will work no matter what

ulfopulfo ulfopulfo ·

For Frodo!

narayb narayb ·

Ugly as sin and it's long, but it will work

narayb narayb ·
immediate_send(
    nil,
    nil,
    "element[0]:encoder_value(map_saturate(element[0]:encoder_value()+1,element[0]:encoder_min(),element[0]:encoder_max(),element[0]:encoder_min(),element[0]:encoder_max())); element[0]:ec()"
)
narayb narayb ·

what it does that it forces the encoder value adjustment into the range of the minmax of the encoder

ulfopulfo ulfopulfo ·

It does work! THANK YOU!

narayb narayb ·

I suggest using variables to determine the encoder you're sending to instead of manually hitting in the numer you need for each message

ulfopulfo ulfopulfo ·

If I wanted to go the "IF" block route, how could I check the status of an encoder on another module as a condition?

(If you don't mind me asking, you just solved my problem and deserve a break!)

narayb narayb ·

Now that would be harder to do, because it would have to report back its value:

module1 would say, "hey tell me value for button 1"
module2 would say it back "56"
module1 would have to store this data to check it

narayb narayb ·

You would probably have to to this behind some timer to get rid of race conditions

narayb narayb ·

The problem is that nothing guarantees that module2 tells module1 what the value is, before module1 would try to evaluate it

narayb narayb ·

But still, should be doable

narayb narayb ·

I'm pretty sure I used this paradigm in a Mackie Control configuration to check whether a third module is connected or not. If it was, the default config would change.

ulfopulfo ulfopulfo ·

If it's a trickier route, then I'll let it go. Your code works great. Now I'm gonna implement another button for stepping down one step!

narayb narayb ·

Good luck! This is the easier way for sure

ulfopulfo ulfopulfo ·

Copied the code to another button, switched out the "+" for a "-" and I now have 2 buttons for quick incremental changes between active presets! A thousand thank you!

narayb narayb ·

No problem, glad we got it working!

Discord

View on Discord

This post is from the Intech Studio Discord community.

Open thread →