Ah yes, I love those "guided randomizations" too. In fact, about the faders - knobs I have already done such stuff, and in fact you can already see such an example in the "files" of the Lemur Users FB group (check my signature) in the form of a complete tutorial. Im planning to make that tutorial into a .pdf file and offer it in user library together with the resulting template.
Now, as for the switches....yeah still doable. Lets say we have a 1x8 Switches object then shall we?
According to what we did previously we will also have a Pad object with this script (set to execute on x, up arrow) in it:
Code: Select all
decl r=rand()*7;
Switches.x=0;
Switches.x[round(r)]=1;
We will now insert a "Range" object and put it next to our Switches object and set its grid setting to 9. This will make the "steps" of the Range object visually represent each button. Using the Range object we can, for the time visually, exclude upper or lower switches.
Now, it is sure we will use the range(x,min, max) function (math internal functions of Lemur) but since we are not mathematicians and we are a bit lost we insert two Monitor objects in our template to observe the Range.x[0] and Range.x[1] values. We do that by using these values in the Monitor objects.
A first thought is to use Range.x[0]*7 as minimum value and Range.x[1]*7 as a maximum value - the goal is to retrieve a 0 rising to 7 for our minimumj value and a 7 falling to 0 for our maximum value. Toying around with the range object and observing the monitors we can quickly see thats NOT the case.
Instead what we are after is
minimum = 7-Range.x[0]*7
maximum= 7-Range.x[1]*7
With this in mind, we dont even have to go "circles" - remember that Range objects x[0] and x[1] are always in the range of 0 to 1 - as our initial rand() function is.
So instead of calculating a rand()*7 and THEN confine it in a range of minimum to maximum as noted above, we do the range thing BEFORE multiplying with 7.
SO......
In our final script with the range incorporated we have:
Code: Select all
decl r=range(rand(),1-Range.x[0],1-Range.x[1])*7;
Switches.x=0;
Switches.x[round(r)]=1;
Try it, works as expected!
Perosnal note: IF I had to make such a "guided randomization" thing for switches I wouldnt use a Range object - what if we want to exclude only two switches in the middle?
Instead I would use a secondary group of switches which would serve as "randomization enable - disable" for EACH of my initial switches.