Page 1 of 2

random selections

Posted: Mon Nov 04, 2013 11:04 pm
by tester
Speaking of the future. Array based slider concept brought by Nubeat7 introduced few questions for me. So here is one of them. Ruby based (I guess) random generator vs array.

Let say, that the first array, is the float array, and its size is fixed.

23.000
33.000
21.000
65.000
...

Let say, that there is second array, that refers to indexes of the first one, array containing int 0's and 1's.

0
1
0
1
...

Zero means, that at that index, in first array (float array) - value is untouched. 1 means - that at that index - value is being randomized. These 0's and 1's come from on/off buttons.

How to pick selective randomization that way, via ruby?

There could be third and fourth array :-) for min/max, but let say that min and max values are common for all.

Second part to that question would be, to pass these randomizations through "logarithmic spread" (the same amounts of hits per octave), to get more lower values, but my head is too small now to visualize that.

Re: random selections

Posted: Mon Nov 04, 2013 11:12 pm
by RJHollins
If I follow ...

Using RUBY to make choice distinctions ... would maybe involve the IF condition, or the CASE statement.

Here is one example I refer back to and help me recall this in Ruby.

Code: Select all

score = @in
# score = 70

result = case score
   when 0..40 then "Fail"
   when 41..60 then "Pass"
   when 61..70 then "Pass with Merit"
   when 71..100 then "Pass with Distinction"
   else "Invalid Score"
end

output result


the INTEGER INPUT I labeled 'score'. The string ouput I have sent to Output 0.

This is just a generic ... but can help illustrate ... and hope this is of help !

Re: random selections

Posted: Tue Nov 05, 2013 12:01 am
by tester
Watching at the code contents, I'm not sure if it's the answer to the question.

Maybe I explain a little bit. Right now - I'm using set of single units (clones). They can be randomized all at once (whole array so to speak), or just selected clones only (equivalent would be: selected values on array, at indexes chosen via second array).

Some of these randomizations are refering to frequencies, and at these parts - a nonlinear function is used, to make the spread of hits "equal across the octaves". And - yes, it is (and should be) based on frequencies, not pitches.

Right now these are just free thoughts, I'm starting to see the greater picture..

Re: random selections

Posted: Tue Nov 05, 2013 12:53 am
by RJHollins
Right now these are just free thoughts, I'm starting to see the greater picture..


that 's what the example pointed to ... even a 'random selection' will have to select. The simple code is only to illustrate a possiblity.

Re: random selections

Posted: Tue Nov 05, 2013 1:18 pm
by TrojakEW
this is array you want to alter:
a = [23,33,21,65]

this is range you want to choose for randomization (example)
b = [11,22,33,44]

now lets say user or you want to randomize first index (0) out of four
a[0] = b.shuffle.first

result array with only first index randomized in selected range:
a

Don't know if is this what you want.

Re: random selections

Posted: Tue Nov 05, 2013 3:26 pm
by tester
I think i meant something like this...

...with included editing option (forgot to add there).

Re: random selections

Posted: Tue Nov 05, 2013 3:27 pm
by Nubeat7
you mean something like this?

Code: Select all

0.upto @frequencies.length do |i|
   if @randomSelections[i]==1
     @frequencies[i] = rand(60..44100)
   end
end

output @frequencies


edit: ahh, saw your example.. so this should do the job

Re: random selections

Posted: Tue Nov 05, 2013 3:35 pm
by tester
Where is the trigger? :-)
How to trigger selective randomization?

Re: random selections

Posted: Tue Nov 05, 2013 5:26 pm
by Nubeat7
use array ins and out, if you want a trigger, write it inside the event methode and add a trigger input..

Code: Select all

if'triggerIn'
..methode
end

Re: random selections

Posted: Tue Nov 05, 2013 5:46 pm
by TrojakEW
Since I don't know what do you want for output and what for input I made two versions.