Page 1 of 1

3 Interacting Buttons Script. Help!

Posted: 19 Jul 2014 04:22
by ctconard
Hi everyone,

I'm fairly new to Lemur, and I'm having trouble with a particular script. I want to have three buttons, and have each button output different midi note on/off messages based on the current status of the other two buttons.

So, in other words, when the #1 button is pressed, I want it to query the #2 button and the #3 button and output accordingly based on the status of buttons #2 and #3. So there would be 7 different possible midi notes sent, as there are 7 different possible combinations of off/on that the three buttons could be in at any given time. I also want the same thing to occur whenever a button is turned off as well.

I've successfully done this with two buttons, which I've attached below, but adding a third button seems to complicate things. I think if I could see the proper way to script "when I press button 1, if button 2 and 3 are off then output C1, but if button 2 is on but 3 is off then output D1 etc" then I could probably figure out the rest. I hope I'm explaining this sufficiently. I've searched and searched and my brain is numb. Any help would be much appreciated. Thanks so much!

-craig

Re: 3 Interacting Buttons Script. Help!

Posted: 19 Jul 2014 19:38
by Softcore
In a fast thinking of it (there might be a more elegant script to pull it off)....

For button 1, if button 2 is off -> if button 3 is on do this, if button 3 is off do that

else (so that means if button 2 is on)

-> if button 3 is on do this, if button 3 is off do that


For example lets say for the button HH, noteOn()

Code: Select all

if	(Snr.x==0){
if (Cl.x==0){
noteout(0,12,127,1);
}
else noteout(0,14,0,1);
}

else 
{
	if (Cl.x==0){
noteout(0,12,127,1);
}
else noteout(0,14,0,1);
}

hereis my example above with a third button called CL at button HH noteOn() (didnt do the rest)

Re: 3 Interacting Buttons Script. Help!

Posted: 20 Jul 2014 19:23
by ctconard
That's a big help, thanks!