Page 1 of 1

Posted: 01 Mar 2016, 19:27
by lytz1
Hey guys,

I try to figure out how to use a random generator which is set to generate integer values between 1 and 8,
but it shall not generate two same values in a row, it shall always output a different one so that there is no repetition.

I inspected the "Midi Expand Voices" Fast-Script which basically has this functionality for midi, (see dropdown menu: rnd no repeat)
but I can't figure out how to translate this to the general data.

Also a non-scripting solution (if this is possible at all without scripting?) would suit me better.

Any ideas on a solution for this problem?

Thanks,

tL.

Posted: 01 Mar 2016, 20:56
by fractalist
I would say :
put the successive values in the "queue array" object of size 2
send it to an array
compare value 0 and value 1 with "=" and if they match :
don't pass the last output (connect a "not" to the "=" and make it regulate a "pass flow" object)
and generate another value (the "=" could be linked to the generate inlet of the random generator, so that it generates another values when the last one equals the previous one)

Posted: 01 Mar 2016, 22:56
by lytz1
Good idea, I already gave that a try and I was very confident that this will work, however I am now running into a new interesting problem...

When a generator (no matter which one) outputs, well, lets say three 1's in a row, the data stream interprets this as a single "1", not as three different 1's so to speak.
So basically when I want a different integer value generated on every beat and the generator outputs two 1's in a row, I have a single 1 in the
dataflow which spans two beats. So it seems there is no way that any module afterwards can know that. So three 1's in a row will get interpreted as a single "1". ;/

Best,
tL.

Posted: 02 Mar 2016, 16:09
by fractalist
mmh, haven't thought about it..
I don't have the solution in mind right now but there is always a trick to find with this kind of problem (e.g., forcing a different output than the previous one).
for example, generating another values when the object 'has changed' doesn't output a 1 when a random number should have been generated, something like that.

when it will be sorted out, I guess there is a simpler solution than my proposition : using the object delta, which computes the difference between current and previous value. If it delta=0, then generate another random value..
no need for arrays in this case..

Posted: 03 Mar 2016, 08:23
by lytz1
I have found a workaround for that. I have split the data flow into two streams and have and have two random law generators hooked up to a selector module.
One RLAW with the first half of values assigned to it and the other one with the second half. They get triggered in cycle, so I never get the same integer in a row. That was the only solution I could come up with, but it works fine.

Object delta sounds interesting as well, will take a look into that. Somehow overlooked that module completely. :)

Thanks,
tL.

Posted: 03 Mar 2016, 14:18
by fractalist
cool workaround !

yes, delta can be helpful in many situation :-) !!

Posted: 03 Mar 2016, 21:55
by oli_lab
Is this what you need ?

File uploaded: http://www.sensomusic.com/forums/upload ... %20bag.pat

Posted: 07 Mar 2016, 15:08
by fractalist
@ Lytz1

thanx for your question !!
I just realized I had the same problem in a patch which requires exact precision (scientific experiment and modelling).

If it helps anybody in the future or now, I just made this "corrective" patch which works fine :
http://www.sensomusic.com/forums/upload ... ration.pat

Posted: 07 Mar 2016, 16:15
by fractalist
well, it works well in a patch, not in another one, I don't get why.. but putting a "wait" object after the "and" object makes it work at the moment.

Posted: 07 Mar 2016, 19:05
by lytz1
Guys,

both patches are super-useful to me, thanks a lot!


Thanks again.,
tL.