Custom buttons - how to turn off all but selected?

Discuss Lemur and share techniques.
Post Reply
joe
Newbie
Posts:9
Joined:10 Aug 2014 18:41
Custom buttons - how to turn off all but selected?

Post by joe » 10 Aug 2014 18:59

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!

Joe Soap
Regular
Posts:475
Joined:07 Jul 2012 15:04

Re: Custom buttons - how to turn off all but selected?

Post by Joe Soap » 10 Aug 2014 21:53

Pads with 'Radio Mode' enabled instead of CustomButton(s) would be a better fit for this.

denisp2
Newbie
Posts:9
Joined:09 Aug 2014 14:13

Re: Custom buttons - how to turn off all but selected?

Post by denisp2 » 10 Aug 2014 22:00

Post your template, and ill try to help you.

joe
Newbie
Posts:9
Joined:10 Aug 2014 18:41

Re: Custom buttons - how to turn off all but selected?

Post by joe » 10 Aug 2014 22:49

denisp2 wrote:Post your template, and ill try to help you.
Thanks! Here's my template.
Attachments
setup_v3.jzml
(57.99KiB)Downloaded 111 times

denisp2
Newbie
Posts:9
Joined:09 Aug 2014 14:13

Re: Custom buttons - how to turn off all but selected?

Post by denisp2 » 11 Aug 2014 13:40

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
Attachments
setup_v4.jzml
(64.8KiB)Downloaded 201 times

joe
Newbie
Posts:9
Joined:10 Aug 2014 18:41

Re: Custom buttons - how to turn off all but selected?

Post by joe » 11 Aug 2014 14:21

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?

denisp2
Newbie
Posts:9
Joined:09 Aug 2014 14:13

Re: Custom buttons - how to turn off all but selected?

Post by denisp2 » 11 Aug 2014 16:18

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.

joe
Newbie
Posts:9
Joined:10 Aug 2014 18:41

Re: Custom buttons - how to turn off all but selected?

Post by joe » 11 Aug 2014 16:40

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.
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?

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)

oldgearguy
Regular
Posts:315
Joined:02 Nov 2013 11:19

Re: Custom buttons - how to turn off all but selected?

Post by oldgearguy » 11 Aug 2014 16:57

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.

joe
Newbie
Posts:9
Joined:10 Aug 2014 18:41

Re: Custom buttons - how to turn off all but selected?

Post by joe » 11 Aug 2014 17:10

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.
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.

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.

Post Reply