CC Toggle on buttons

Hi, I wish to set the 4 buttons of my PBF4 as CC toggles, switching from 0 to 127.
I can’t find in the editor any toggle mode, am I wrong?


To set step mode use the Button Mode actionblock on the Init event of the button to set up toggle mode! After that you can change the MIDI action block on the Button event to CC!



Here you can also find a general overview how buttons can be set up in the Editor.

This link is broken. FYI

How do you set the two CC values that the button toggles between? I’m trying to setup a toggle that, on first press, sends CC 23 with a value of 1. Then, on second button press, sends CC 23 with the value of the encoder. That latter, I can program but I don’t know how to set the two values that toggle steps through.

I’ve tried two MIDI action blocks but it just sends both values; 1 and whatever the encoder’s value is. I can’t find any detailed info in the reference docs about this. It just says to set the button to ‘Toggle’ type.

Link has been reorganized: 2.1: Buttons | Intech Studio Documentation

As for change the for the encoder:


1.) on init, create variable, set button mode to toggle
2.) on button, add an if action and change the assignment based on button value, which is either 0 or 127 in simple toggle setup
3.) consume the on the encoder’s midi action block

I just realised, that you need to do this on a PBF4.

Biggest difference in that case is that the button event is on a different element scope, on the button itself.

So on the button, you should use element[INDEX_OF_ELEMENT].cc reference to make the value assignment.

Here’s what I came up with. It’s working flawlessly and precisely as I need (this is on an EN16 btw. There’s also some variables that I can clean up but the logic is spot on):

‘init’ = 23
local num = self:element_index()
led_color(num, 1, 0, 0, 0, 1)
led_color(num, 2, 0, 255, 0, 1)
led_value(num, 1, nil)
led_value(num, 2, 127)


local num, val, eval = self:element_index(), self:button_value(), self:encoder_value()
if self:button_value() == 0 then
	led_value(num, 2, 0)
	midi_send(11, 176,, eval)
if self:button_value() == 127 then
	self.st8 = self:encoder_value()
	led_value(num, 2, 127)
	midi_send(11, 176,, 1)


local num, eval = self:element_index(), self:encoder_value()
midi_send(11, 176,, eval)

I’m using this on the bottom 8 encoders with relevant assigned. Each encoder will send out its value when in one button_state() and send out ‘1’ as the value in the other state. On state switch, the current encoder value is saved (self.st8 <= each encoder will have it’s on ‘num’ value here for possible external referencing later (could this be an array instead?)), the second state sends out ‘1’ and restricts encoder min/max to 1 (prevents changes from encoder turns). On state switch back, encoder_value returns to the state saved on transition. LED is light when in locked mode and unlit without any intensity on the other mode.

My next steps are to configure an encoder button press to set all bottom 8 encoders back to the first state. I did some reading before bed and I think I can achieve this some event.trigger coder.

Once that is complete, the last step is to configure midi_rx to send the corresponding incoming parameter changes back to their respective encoders. This will need to check the state of the button on each encoder so that I can set the min/max encoder range to 1 if the encoder is in ‘locked’ mode. I only want to update the encoder value when the encoder is ‘unlocked’. I have ideas on how to do all of this.

Excited to start working through coding the remaining bits up! So, not a request for help…yet.

As an aside, I am absolutely loving the EF44 and EN16 that I ordered. I’ve ordered another EF44 and a PO16! One of the big motivators for me is that it finally gives me something where I can learn to code. I’ve wanted to learn programming for a very, very long time but I only ever learn the basics and never have projects to apply the knowledge to. The knowledge fades and the interest wanes. Not that LUA is particularly challenging but, it’s loads of fun finding solutions to my problems.



1 Like

A journey for sure. Happy exploring! If you get stack at any point, let us know.

1 Like