Hi there. Building a little drum machine toy.
16 steps. 10 channels.
So 10 rows of 16 buttons in a container. So far so good.
But I want to be able to set the button states in a number of different ways.
a) Reset all buttons back to zero.
b) Only allow a certain number of buttons to be selected per row. ie, only two cymbals at any one time.
it depends a bit on how your file is setup, but generally resetting buttons back to their off state could be done with a python script to loop over all buttons. For example if all the buttons are located in a COMP of some sort:
myComp = op('myComp')
for button in myComp.findChildren(type=buttonCOMP):
button.click(0)
For rules like only allowing a certain amount of buttons to be turned on, you could utilize a Panel Execute DAT which when a button is clicked, checks how many buttons are turned on and in case more than n buttons are already turned on, set’s the last selected button back to 0.
My colleague built something where the last 4 button states are stored in a DAT, so if you turn on more than 4 buttons, the oldest button goes off.
But having done this, we realised the UI experience isn’t great. It goes a bit ‘whack-a-mole’
From a UI perspecitve, it’s actually much better to limit the amount of buttons that you can turn on.
So if you want to change a sequence, you have to turn a button off, to give yourself room to turn another one on.
Your method under the code snippet looks like a great route.
Will post where we got to.
Sadly my Python is terrible. So I’ll have to hit the tutorials…