Custom buttons - how to turn off all but selected?
Custom buttons - how to turn off all but selected?
I've made a template with custom buttons, all sending different midi program change commands to easily switch between my drumkits. I was simply hoping to be able to use the buttons as switches so that when I select a drumkit, that button becomes active and the previous button turns off.. (to see right away which kit I have loaded.) I don't need any feedback. Just a simple script that turns the other buttons off when I tap one.
I appreciate any help. I will try to learn to use the lemur editor better, but right now I don't have the time to and I just need to get this working asap.
Thanks!
I appreciate any help. I will try to learn to use the lemur editor better, but right now I don't have the time to and I just need to get this working asap.
Thanks!
Re: Custom buttons - how to turn off all but selected?
Pads with 'Radio Mode' enabled instead of CustomButton(s) would be a better fit for this.
Re: Custom buttons - how to turn off all but selected?
Post your template, and ill try to help you.
Re: Custom buttons - how to turn off all but selected?
Thanks! Here's my template.denisp2 wrote:Post your template, and ill try to help you.
- Attachments
-
- setup_v3.jzml
- (57.99 KiB) Downloaded 107 times
Re: Custom buttons - how to turn off all but selected?
Here you go , did it for the Kits.
now what u need to know is that there are at least 5 different ways to do what you asked for, i showed you the probably simplest one to understand. i did 2 things.
1.
So what i did just added a script to ewery button so once you push it it just turns off all the other buttons. Now if you have 12 buttons thats ok, but if you have 100 you would probably want to look for a different solution.
2.
under the properties window of ewery button there is a light setting. i just put in "nameofthebutton".x
Regards Denis
now what u need to know is that there are at least 5 different ways to do what you asked for, i showed you the probably simplest one to understand. i did 2 things.
1.
So what i did just added a script to ewery button so once you push it it just turns off all the other buttons. Now if you have 12 buttons thats ok, but if you have 100 you would probably want to look for a different solution.
2.
under the properties window of ewery button there is a light setting. i just put in "nameofthebutton".x
Regards Denis
- Attachments
-
- setup_v4.jzml
- (64.8 KiB) Downloaded 194 times
Re: Custom buttons - how to turn off all but selected?
Great, thank you! I see what you’ve done here.. So you had to make a list of all the other buttons for each button.
I guess there’s no way to write a script to simply ”turn off all the other buttons”?
I really don’t know how the programming in these scripts work, but would it be possible to write a few lines of code that could be copied to each button.. something like:
on button press:
- add +1 to a global variable y
- if y = 2, then x=0, and reset y to 1 (so if another button is pressed, each button turns itself off)
- and finally set the pressed button x=1 (so it would stay on)
I’m not into programming as you can see, and I don’t even know if there are global variables in lemur, (I suppose so as it seems quite advanced) but with bome’s midi translator it could have been done this way. Is something like this possible in lemur too?
I guess there’s no way to write a script to simply ”turn off all the other buttons”?
I really don’t know how the programming in these scripts work, but would it be possible to write a few lines of code that could be copied to each button.. something like:
on button press:
- add +1 to a global variable y
- if y = 2, then x=0, and reset y to 1 (so if another button is pressed, each button turns itself off)
- and finally set the pressed button x=1 (so it would stay on)
I’m not into programming as you can see, and I don’t even know if there are global variables in lemur, (I suppose so as it seems quite advanced) but with bome’s midi translator it could have been done this way. Is something like this possible in lemur too?
Re: Custom buttons - how to turn off all but selected?
well im no programming expert either, i just found a few things that work
Well ass far as i know there is no way to say "all other buttons" that easily, especialy with custom buttons. Cause in a way that is the point of a custom button so you need to declare ewerything yourself.
As your idea :
on button press:
- add +1 to a global variable y
- if y = 2, then x=0, and reset y to 1 (so if another button is pressed, each button turns itself off)
- and finally set the pressed button x=1 (so it would stay on)
difficult to say, you would just then need a big script that would have all the conditions in it(if button1 is pressed turn off b2,3,4,5...if b2 is pressed turn off b1,3,4,5...etc) so in a way its the same thing, just in one big script.
if you are looking for another way to do it, you could:
you could do a loop that would check all the buttons, but for that to work you would first have to rename all the buttons to something simple like b1,b2,b3,b4,b5...
Then each button would have a small code with a global variable, and then the loop.
So each button would first have:
b1 would have:
globaly=1;
b2 would have:
globaly=2;
etc....
then the loop
for(i=1,i<13,i++) // the loop checks is it our pushed button, if yes we do nothing, if no turn it off.
{
if(i==globaly)
{}
else
b.x=0;
}
as far as global variables, all your stuff with the green dot , before the RUMMUT folder, are considered global variables.
Well ass far as i know there is no way to say "all other buttons" that easily, especialy with custom buttons. Cause in a way that is the point of a custom button so you need to declare ewerything yourself.
As your idea :
on button press:
- add +1 to a global variable y
- if y = 2, then x=0, and reset y to 1 (so if another button is pressed, each button turns itself off)
- and finally set the pressed button x=1 (so it would stay on)
difficult to say, you would just then need a big script that would have all the conditions in it(if button1 is pressed turn off b2,3,4,5...if b2 is pressed turn off b1,3,4,5...etc) so in a way its the same thing, just in one big script.
if you are looking for another way to do it, you could:
you could do a loop that would check all the buttons, but for that to work you would first have to rename all the buttons to something simple like b1,b2,b3,b4,b5...
Then each button would have a small code with a global variable, and then the loop.
So each button would first have:
b1 would have:
globaly=1;
b2 would have:
globaly=2;
etc....
then the loop
for(i=1,i<13,i++) // the loop checks is it our pushed button, if yes we do nothing, if no turn it off.
{
if(i==globaly)
{}
else
b.x=0;
}
as far as global variables, all your stuff with the green dot , before the RUMMUT folder, are considered global variables.
Re: Custom buttons - how to turn off all but selected?
What I meant is that in this the global variable 'y' could be same for all buttons. -> so in case all buttons in lemur are actively "monitoring" the global variables, then there would be no need to tell every button to turn off independently. I don't know if this is the case? The code could be identical in all of the buttons, so whenever a button is pressed, all buttons - that have the script code "if y=2, then x=0" - would be automatically turned off. After that the code would tell only the button that was pressed to turn on. Others would stay off, as their button was not pressed. But again, I don't know if lemur works this way, and how could it be written to a script. Any wizards out there?denisp2 wrote:difficult to say, you would just then need a big script that would have all the conditions in it(if button1 is pressed turn off b2,3,4,5...if b2 is pressed turn off b1,3,4,5...etc) so in a way its the same thing, just in one big script.
on button press:
- add +1 to a global variable y ( so by default y=1, but when any of the buttons is pressed then y=2 for all buttons!)
- if y = 2, then x=0, (so if any button is pressed, all buttons turn off)
- reset y to 1 (so the script will work again for all buttons when another button is pressed)
- and finally set the pressed button x=1 (so it will stay on until any of the buttons is pressed again)
-
- Regular
- Posts: 315
- Joined: 02 Nov 2013 11:19
Re: Custom buttons - how to turn off all but selected?
You can do it with a global as you describe, but since Lemur is multi-touch, you'll have to handle the case if a user presses more than one button at the same time. Also, since Lemur works on frames, the 'state of the world' is evaluated each frame and then actions are taken, so things may happen slightly differently than you expect at first.
Re: Custom buttons - how to turn off all but selected?
I think the worst that can happen here is that lemur doesn't show which kit is selected, or shows multiple kits selected at once if multiple buttons are touched simultaneously. Neither case is dangerous and can be fixed by simply pushing only one of the buttons again. I would just love to see which kit I have selected as I play other instruments too, so I may quickly forget which drum kit I have active.oldgearguy wrote:You can do it with a global as you describe, but since Lemur is multi-touch, you'll have to handle the case if a user presses more than one button at the same time. Also, since Lemur works on frames, the 'state of the world' is evaluated each frame and then actions are taken, so things may happen slightly differently than you expect at first.
perhaps "if y ≥ 2, then x=0" would be enough to handle this?
But if there's anyone experienced in scripting who could write the script without too much trouble, I would really appreciate it. This is not the only situation I would use it in, and the number of buttons rises to hundreds, so a simple code like this would save a ton of work.