Math.randInt
-
Good morning all you developers of fascinating plug-ins -
I haven't started yet and I'm still in a good mood :-)I would like to have a problem, as we say here.
I would like to use Math.randInt so that it only randomises between 2 values.
One value is 0 and the other 99.
So either 0 or 99. -
@MikeB something like
var myValue = 0; var chance = Math.random(); if (chance > .5) myValue = 99; else myValue = 0;
-
@iamlamprey Thank you - you are the man of the morning. :-)
However, I need to transfer this to a slider pack.
So I need two values or vars - right?SliderPack3.setSliderAtIndex(i, Math.randInt(0, 99));
-
@MikeB If that's a for loop for each slider in the sliderpack, the code I posted above should still work.
var chance; //use reg if it's during playback stuff for (i=0; i<sliderpacklength; i++) { chance = Math.random(); if (chance > .5) SliderPack3.setSliderAtIndex(i, 99); else SliderPack3.setSliderAtIndex(i, 0); }
-
@iamlamprey
Now you have become the man of the day :-)Thank you very much.
-
@MikeB Oh also if it's in a loop you can use local variables :)
-
@iamlamprey I have done this - thank you
-
You can also do it like this:
Math.randInt(0, 2) * 99);
(Note that the second argument is the exclusive limit of the range so for 0..1 you have to specify 2 as upper limit).
-
@Christoph-Hart
or so :-)
I will try it out - thanks -
@Christoph-Hart It worked. Thank you.
Now all I need for a successful Sunday is an Arp Start/Stop button that works independently of Note On/Off.
Or a way to give a Note On/Off callback when a preset is called.