Random Gen. Integer Value, but never two values the same in a row?
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.
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.
-
fractalist
- Member
- Posts: 84
- Contact:
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)
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)
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.
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.
-
fractalist
- Member
- Posts: 84
- Contact:
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..
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..
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.
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.
-
fractalist
- Member
- Posts: 84
- Contact:
cool workaround !
yes, delta can be helpful in many situation
!!
yes, delta can be helpful in many situation
http://oli-lab.org
Win11 Ryzen9/32GB RAM - RME MADIFACE - SSL alpha link 4-16 - OSC capable interfaces
follow OLI_LAB adventures on Mastodon
@olivar_premier@mastodon.social
Win11 Ryzen9/32GB RAM - RME MADIFACE - SSL alpha link 4-16 - OSC capable interfaces
follow OLI_LAB adventures on Mastodon
@olivar_premier@mastodon.social
-
fractalist
- Member
- Posts: 84
- Contact:
@ 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
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
-
fractalist
- Member
- Posts: 84
- Contact:
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.
Guys,
both patches are super-useful to me, thanks a lot!
Thanks again.,
tL.
both patches are super-useful to me, thanks a lot!
Thanks again.,
tL.
Who is online
Users browsing this forum: No registered users and 84 guests
