Hi,
I'm trying to sort out a script.. I want the position of a fader to determine the selected tab of a container. This is based on a MIDI message sent to Lemur from my DAW (not my manual movement of the fader) and it doesn't necessarily even have to be a fader, just something that can select a tab based upon the current position of a particular CC value...
Here's what I'm currently working with:
if(firstof.x>=0.75) selecttab(ContainerDiva,0);
else
if(firstof.x>=0.5) selecttab(ContainerDiva,1);
else
if(firstof.x>=0.25) selecttab(ContainerDiva,2);
else
selecttab(ContainerDiva,3);
Any help with this would be greatly appreciated, I'm a little stumped as to what I'm doing wrong!
Cheers
Fader Script to Select Tabs
Re: Fader Script to Select Tabs
If we are talking about a fader here, you shouldnt have used firstof(x) - its as simple as.... x
(fader.x if the script resides outside of fader, where "fader" the actual name of the fader object inside your template)
firstof(x) is a function useful for an array of x (usually a row of pads or switches) and returns the first position of the array where x != 0. For example, if you have a row of 16 pads and you press the third pad then firstof(x) = 2 (0 being the first position, x[0]). Furthermore the correct syntax is firstof(x) not .x but you dont even need it in your case.
So here's the corrext syntax
if(x>=0.75) selecttab(ContainerDiva,0);
else
if(x>=0.5) selecttab(ContainerDiva,1);
else
if(x>=0.25) selecttab(ContainerDiva,2);
else
selecttab(ContainerDiva,3);
Furthermore lets assume that x == 0.6;
it satisfies BOTH if(x>=0.5) and if(x>=0.25) so you might end up with the third case even though you are after the second.
I dont remember if the if - else if exits the statement when one of the ifs are satisfied - if not, you might have to make the syntax like this:
if(x>=0.75) {selecttab(ContainerDiva,0); return;}
else
if(x>=0.5) {selecttab(ContainerDiva,1); return;}
else
if(x>=0.25) {selecttab(ContainerDiva,2); return;}
else
selecttab(ContainerDiva,3);
Finally, the "return" function will exit the script so if you have more stuff down the script (below the if - else if) you will be exiting the script and those wont be executed so you are looking at this solution
if(x>=0.75) selecttab(ContainerDiva,0);
else
if(x<0.75 && x>=0.5) selecttab(ContainerDiva,1);
else
if(x<0.5 && x>=0.25) selecttab(ContainerDiva,2);
else
selecttab(ContainerDiva,3);
more info, and how to use other objects to control tabs of a container here:
http://forum.liine.net/viewtopic.php?f=34&t=3022
(fader.x if the script resides outside of fader, where "fader" the actual name of the fader object inside your template)
firstof(x) is a function useful for an array of x (usually a row of pads or switches) and returns the first position of the array where x != 0. For example, if you have a row of 16 pads and you press the third pad then firstof(x) = 2 (0 being the first position, x[0]). Furthermore the correct syntax is firstof(x) not .x but you dont even need it in your case.
So here's the corrext syntax
if(x>=0.75) selecttab(ContainerDiva,0);
else
if(x>=0.5) selecttab(ContainerDiva,1);
else
if(x>=0.25) selecttab(ContainerDiva,2);
else
selecttab(ContainerDiva,3);
Furthermore lets assume that x == 0.6;
it satisfies BOTH if(x>=0.5) and if(x>=0.25) so you might end up with the third case even though you are after the second.
I dont remember if the if - else if exits the statement when one of the ifs are satisfied - if not, you might have to make the syntax like this:
if(x>=0.75) {selecttab(ContainerDiva,0); return;}
else
if(x>=0.5) {selecttab(ContainerDiva,1); return;}
else
if(x>=0.25) {selecttab(ContainerDiva,2); return;}
else
selecttab(ContainerDiva,3);
Finally, the "return" function will exit the script so if you have more stuff down the script (below the if - else if) you will be exiting the script and those wont be executed so you are looking at this solution
if(x>=0.75) selecttab(ContainerDiva,0);
else
if(x<0.75 && x>=0.5) selecttab(ContainerDiva,1);
else
if(x<0.5 && x>=0.25) selecttab(ContainerDiva,2);
else
selecttab(ContainerDiva,3);
more info, and how to use other objects to control tabs of a container here:
http://forum.liine.net/viewtopic.php?f=34&t=3022
Re: Fader Script to Select Tabs
Ok I had to check - according to Lemur manual:
"By using else if, it is possible to combine several conditions. Only the statement(s) following the
first condition that is found to be true will be executed, and all other statement(s) will be skipped."
(page 82)
so, in my above reply, disregard the second and third suggestions (the return and the && statements)
"By using else if, it is possible to combine several conditions. Only the statement(s) following the
first condition that is found to be true will be executed, and all other statement(s) will be skipped."
(page 82)
so, in my above reply, disregard the second and third suggestions (the return and the && statements)
Re: Fader Script to Select Tabs
Hi
Another option
Script executing on Fader.x
decl tabs= {0,1,2,3};
selecttab(Container,tabs[Fader.x*4]);
This allows you reorder the tabs fairly easily by altering the array
Could also throw some introspection in ie Fader.x*sizeof(Fader.x) making it easily mutable
Similar thing with Switches
selecttab(Container,firstof(Switches.x)); // Direct correlation or use an array as in other example
Then it is simply a matter of mapping those objects . . .
The other option if you don't require the local object for use is to simply use a similar script executing OnMidi . .
This would make it purely dependent on Midi control which could be sent from anywhere ...
Hope that helps
Another option
Script executing on Fader.x
decl tabs= {0,1,2,3};
selecttab(Container,tabs[Fader.x*4]);
This allows you reorder the tabs fairly easily by altering the array
Could also throw some introspection in ie Fader.x*sizeof(Fader.x) making it easily mutable
Similar thing with Switches
selecttab(Container,firstof(Switches.x)); // Direct correlation or use an array as in other example
Then it is simply a matter of mapping those objects . . .
The other option if you don't require the local object for use is to simply use a similar script executing OnMidi . .
This would make it purely dependent on Midi control which could be sent from anywhere ...
Hope that helps
iMac 2.8G i7 12G 10.6.8/10.7.2, Legacy Dexter/Lemur, Liine Lemur/iPad2, KMI SoftStep, 12Step & QuNeo , B-Controls, Mackie C4 etc
MaxMSP, Live Suite, Native Instrument stuff, etc Modified Virtual Guitar System etc All Projects/Modules © CC-BY-NC-SA[*][/b]
MaxMSP, Live Suite, Native Instrument stuff, etc Modified Virtual Guitar System etc All Projects/Modules © CC-BY-NC-SA[*][/b]
Re: Fader Script to Select Tabs
And this, ladies and gentlemen, is what I call "just working" scripts (mine) vs "elegant" scripts (Macizza's).
Re: Fader Script to Select Tabs
Why thank you good sir . . .
Many ways to skin a Lemur . . .
Cheers
Many ways to skin a Lemur . . .
Cheers
iMac 2.8G i7 12G 10.6.8/10.7.2, Legacy Dexter/Lemur, Liine Lemur/iPad2, KMI SoftStep, 12Step & QuNeo , B-Controls, Mackie C4 etc
MaxMSP, Live Suite, Native Instrument stuff, etc Modified Virtual Guitar System etc All Projects/Modules © CC-BY-NC-SA[*][/b]
MaxMSP, Live Suite, Native Instrument stuff, etc Modified Virtual Guitar System etc All Projects/Modules © CC-BY-NC-SA[*][/b]
Re: Fader Script to Select Tabs
We also make mistakes when we don't check our work properly . . .
Sorry about that...
For various reasons the following works far better. ....
selecttab(Container,tabs[Fader.x*sizeof(tabs)-0.01]); //3.99 for 4 tabs
This value could also be declared locally
Cheers
Mm
Sorry about that...
For various reasons the following works far better. ....
selecttab(Container,tabs[Fader.x*sizeof(tabs)-0.01]); //3.99 for 4 tabs
This value could also be declared locally
Cheers
Mm
iMac 2.8G i7 12G 10.6.8/10.7.2, Legacy Dexter/Lemur, Liine Lemur/iPad2, KMI SoftStep, 12Step & QuNeo , B-Controls, Mackie C4 etc
MaxMSP, Live Suite, Native Instrument stuff, etc Modified Virtual Guitar System etc All Projects/Modules © CC-BY-NC-SA[*][/b]
MaxMSP, Live Suite, Native Instrument stuff, etc Modified Virtual Guitar System etc All Projects/Modules © CC-BY-NC-SA[*][/b]
Re: Fader Script to Select Tabs
Thanks so much for the responses and all of the insight gents!!!
On a related note, I am trying to get CC info TO a set of switches, so that they respond to even portions of 0-127.. I.E. 0-31 selects switch 1, 32-64 selects switch 2, etc.
I attempted this by using a fader to receive the CC, and writing a script under the switches for x=Fader.x*127/4
I was unsuccessful with that but ultimately it is not even necessary for it to receive the CC information from the Fader, I just need it to respond to a CC value being sent from Ableton.
On a related note, I am trying to get CC info TO a set of switches, so that they respond to even portions of 0-127.. I.E. 0-31 selects switch 1, 32-64 selects switch 2, etc.
I attempted this by using a fader to receive the CC, and writing a script under the switches for x=Fader.x*127/4
I was unsuccessful with that but ultimately it is not even necessary for it to receive the CC information from the Fader, I just need it to respond to a CC value being sent from Ableton.