Welcome to %s forums

BrainModular Users Forum

Login Register

Random Gen. Integer Value, but never two values the same in a row?

I need help on a Patch
Post Reply
lytz1
Member
Posts: 123
Contact:

Unread post by lytz1 » 01 Mar 2016, 19:27

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.

fractalist
Member
Posts: 84
Contact:

Unread post by fractalist » 01 Mar 2016, 20:56

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)

lytz1
Member
Posts: 123
Contact:

Unread post by lytz1 » 01 Mar 2016, 22:56

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.

fractalist
Member
Posts: 84
Contact:

Unread post by fractalist » 02 Mar 2016, 16:09

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..

lytz1
Member
Posts: 123
Contact:

Unread post by lytz1 » 03 Mar 2016, 08:23

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.

fractalist
Member
Posts: 84
Contact:

Unread post by fractalist » 03 Mar 2016, 14:18

cool workaround !

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

User avatar
oli_lab
Member
Posts: 1263
Location: Brittany, France
Contact:

Unread post by oli_lab » 03 Mar 2016, 21:55

Is this what you need ?

File uploaded: http://www.sensomusic.com/forums/upload ... %20bag.pat
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

fractalist
Member
Posts: 84
Contact:

Unread post by fractalist » 07 Mar 2016, 15:08

@ 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

fractalist
Member
Posts: 84
Contact:

Unread post by fractalist » 07 Mar 2016, 16:15

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.

lytz1
Member
Posts: 123
Contact:

Unread post by lytz1 » 07 Mar 2016, 19:05

Guys,

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


Thanks again.,
tL.

Post Reply

Who is online

Users browsing this forum: No registered users and 40 guests