Page 1 of 1

trying to get attribute from switch labels....

Posted: 27 Feb 2016 20:18
by stevendieveney
Hopefully someone can help me here. I'm trying to use a fader to send midi CC values. Got that working. I've got some switches with labels corresponding to the CC I want to send. I've got things working with sending my cc value to a .cc variable on my fader and then using that for the ctlout. But I'd like to simplify things. Right now my script from the switches uses if and else if lines for each switch (there are 12 of them). Is there a way to just set my fader variable by using a getattribute call to the 'labels' in the switches? something like this:

decl s;
s=firstof(x);

Fader2.cc=getattribute(Switches2,'labels',[s]);

I have a feeling I'm in the ballpark but something is wrong. Maybe it can't be done?

Thanks so much!!!!
Steve

Re: trying to get attribute from switch labels....

Posted: 28 Feb 2016 12:34
by MrCorba
When you get the labels attribute, lemur returns a array. So your right using [s], but you have to put it outside the get attribute like this:

Code: Select all

Fader2.cc=getattribute(Switches2,'labels')[s];
The only problem I can think of is that it returns a string instead of an integer, so it might nog work on a ctl out. If you got that problem, you can just create an expression with all the cc's in them and use the switch to select the one something like this:

Code: Select all

ccs = {1,2,3,4} //This expression holds the cc's
ctlout(0,css[firstof(Switches.x)],127,1); // This should be inside the script.