Can this be done with a Switches/Pad Object?
Can this be done with a Switches/Pad Object?
I want to create a multi switches object with basically the function radio (the last active switch goes off, once you tap a new one). However, I want kind of a special version of that radio behavior: When I hold a finger on the pad last enabled while touching another pad, both are selected and on. This should also work with multiple pads. I only just started to get into the scripting part of Lemur, but as far as I can see it now, I would need a z-variable (pad touched or not) like the fader objects have. This does not seem to exists for switches, unfortunately. Is there some way to achieve it via scripting? Or is this a job for canvas, only? Right now, my time does not allow me to get into that topic ...
Re: Can this be done with a Switches/Pad Object?
Yup...doable
Make sure you midi map 's' NOT x
Make sure you midi map 's' NOT x
- Attachments
-
- pads-can-be-switches-too.jzml
- (3.61 KiB) Downloaded 189 times
Re: Can this be done with a Switches/Pad Object?
Thanks! I will take a look at that, as soon as I have time!
Re: Can this be done with a Switches/Pad Object?
Works great! I will try to understand, what you did with that script, as I am new to Lemur scripting ...
In the pads object you declare a separate array called s.
In the script:
decl i, size = sizeof(x); // declare variable i as a counter to go through the array of x and define the size of the array, depending on the size of the pad object
for (i=0;i<size;i++){ //scanning through all values of the array for every touch of the pads object ...
if (!x) s=0;
else s=1; // sets the array of s equal to that of x
}
I almost get it, I think, but I don't understand, how this lets the simultaneously pushed pads stay grey, as there is no x manipulated in the script, so, how does the pad object 'know' to highlight the pads activated by s?
I am trying to find out, how to modify this, to only highlight a maximum of 4 pads simultaneously, so that the a fifth pad is not activated. Thank you very much!
In the pads object you declare a separate array called s.
In the script:
decl i, size = sizeof(x); // declare variable i as a counter to go through the array of x and define the size of the array, depending on the size of the pad object
for (i=0;i<size;i++){ //scanning through all values of the array for every touch of the pads object ...
if (!x) s=0;
else s=1; // sets the array of s equal to that of x
}
I almost get it, I think, but I don't understand, how this lets the simultaneously pushed pads stay grey, as there is no x manipulated in the script, so, how does the pad object 'know' to highlight the pads activated by s?
I am trying to find out, how to modify this, to only highlight a maximum of 4 pads simultaneously, so that the a fifth pad is not activated. Thank you very much!
Re: Can this be done with a Switches/Pad Object?
Valid question because you missed one tiny bit of detail. Now that our "s" is the on-off value and not the actual "x"....the pads are really not "on" per se. We just use the "s" array to "light" them up AS IF they were on. Check out the "light" field of the Pads - you will see thjat instead of a static/fixed number I have put "s". This how the Pads "know" what to light up - the trick here is that the light field can accept dynamic arrays and not just fixed static values.
Also notice that the script is executed ONLY when a pad is pressed - NOT when any pad is released (on expression x, up arrow )
On to your other question you just need to impelement a "counter" that will be advancing by one, each time one pad is active and then prohibit the script from running if that counter is larger than 4.
Example coming soon...
Also notice that the script is executed ONLY when a pad is pressed - NOT when any pad is released (on expression x, up arrow )
On to your other question you just need to impelement a "counter" that will be advancing by one, each time one pad is active and then prohibit the script from running if that counter is larger than 4.
Example coming soon...
Last edited by Softcore on 15 Jun 2016 14:51, edited 2 times in total.
Re: Can this be done with a Switches/Pad Object?
Ok sorry for the delay - damn day job lol....so here's how we go about it....we decl an empty variable c (from "counter"). This one is null by default so its 0. We advance it by one ( c ++ ) every time we "scan" and find a "pressed" pad. BUT then......we actually scan ONLY if c is smaller than 5 ( so up to 4 ).
Here's what our script should look like:
Havent tried it but it should work.
Here's what our script should look like:
Code: Select all
decl i,c, size = sizeof(x);
for (i=0;i<size;i++){
if (!x[i]) s[i]=0;
else {if (c<5){
s[i]=1;c++;
}
}
}