Easiest way to fill matrixctrl with random values?

oivindi's icon

The title says it all: What is the easiest/fastest way to fill matrixctrl with random values (0s and 1s)?

I have come so far as to guess that "decide" can be used in some way or another, but would I have to make a list?

Gregory Taylor's icon

I'd use jit.noise and add a little scaling voodoo.
Your mileage may vary, what with being up north
and all. :-)

oivindi's icon

"It's grim up north", wasn't that the wisdom that we received from The Justified Ancients of Mu Mu? ;)

And grim they are - because I don't have Jitter!

Back to the drawing board, I guess.

Adam Murray's icon

Quote: oivindi wrote on Wed, 03 December 2008 12:09
----------------------------------------------------
> The title says it all: What is the easiest/fastest way to fill matrixctrl with random values (0s and 1s)?
>
> I have come so far as to guess that "decide" can be used in some way or another, but would I have to make a list?
>
>
----------------------------------------------------

Not in front of Max right now, so bear with me, but this should be pretty easy.

You'll need two [uzi] objects. One for the number of columns, and one for the number of rows. Say your maxtrix is 4x8 then you'll want an [uzi 4] and an [uzi 8]. The right outlet of those will dump out the numbers 0-3 and 0-7. Each time a number comes out of the first uzi, put it into the right inlet of a pack and bang the second uzi. The second uzi will go into the left inlet of pack.

This should output lists "0 0", "0 1", "0 2", ... "3 7"
Those are your matrix coordinates.

Then you just need to pick a random 0 or 1 for each coordinate (try [random]) and append it to the coordinate list and send it to matrixctrl.

Luke Hall's icon

Here is the method Adam described:

lh

Max Patch
Copy patch and select New From Clipboard in Max.

Andrew Benson's icon

I like doing stuff like this with Jitter, because it's easily scalable.

Andrew B.

Max Patch
Copy patch and select New From Clipboard in Max.

lewis lepton's icon

Aye, I was figuring this out as well, to fill the [matrixctrl] with random values. For my FM Sequencer, which i happily ended up figuring out after 2 days of messing around.

After a few days of banging my head against the wall, messing with Max, did actually use the Jitter method instead, mainly because it was less cumbersome and i had paid for Jitter but have not used it to a great extent yet. So now have put my money to use :)

The other non-Jitter methods are more than fine, but if you do have Jitter, use the Jitter method that Andrew has pointed out. It is less space used and much easier...

lewis lepton's icon

the one thing i am now figuring out now, is how to randomize a [function] ?

If any of you know, let me know please

Cheers...

Adam Murray's icon

Quote: Lewis G. Edwards wrote on Wed, 03 December 2008 21:59
----------------------------------------------------
> the one thing i am now figuring out now, is how to randomize a [function] ?
>
> If any of you know, let me know please
>
----------------------------------------------------

Here's an adaptation of the uzi approach. You may want to hardcode a start/end point, and maybe enforce a minimum number of points by running the first [random] through a [+].

Max Patch
Copy patch and select New From Clipboard in Max.

lewis lepton's icon

Nice Adam, Cheers very much...

Adam Murray's icon

And here's the Jitter version. Learned something new today thanks to this thread :)

Max Patch
Copy patch and select New From Clipboard in Max.

oivindi's icon

Well, Adam, you didn't learn as much as me. :)

Thanks for all the great suggestions!

Chris Muir's icon
oivindi's icon

Great stuff, Chris - thanks!

I was about to post a follow-up concerning density, but your solution took care of that.

Peter Castine's icon

Quote: andrewb@cycling74.com wrote on Wed, 03 December 2008 23:15
----------------------------------------------------
> I like doing stuff like this with Jitter, because it's easily scalable.
----------------------------------------------------

Nice example.

It may be worth noting that in generating a random 2d matrix with a linear congruence RNG (and jit.noise is, I think linear congruence, is it not?) there is an issue in that you will get more continuous lines (diagonals, horizontals, verticals) than a "true" random process ought to produce. This probably won't be measurable in a 4x8 matrix, but since you mentioned scalability, at anything over say 100x100 the perfectionist might want to look at another noise source.

oootini's icon

hi all,

i'm using the above method to generate a single 1 per column for a sequencer i'm building (i've set one non zero cell per column). could some one tell me why more often than not the following patcher seems to place all the ones in the bottom half of the rows? shouldn't it be completely random?

Max Patch
Copy patch and select New From Clipboard in Max.

Tj Shredder's icon

You go from top to down, and you have checked "one non-zero cell per column" in the inspector, each setting on a lower row will uncheck the above...

Max Patch
Copy patch and select New From Clipboard in Max.

try this:

oootini's icon

thanks for the reply! that's much better.

I should have said that the external synth i'm going to be sequencing is monophonic. so if i trigger two notes at once, the second note won't fire. you can see here that i can go forwards and backwards in my simple seq.

how can i bang the matrixctrl so that a 1 is put randomly in each column and only 1 in each column - so that it doesn't trigger 2 notes at the same time?

sorry if i'm not explaining myself correctly. i've only been using max the last 3 weeks...:)

Max Patch
Copy patch and select New From Clipboard in Max.

Tj Shredder's icon
Max Patch
Copy patch and select New From Clipboard in Max.

You patch is doing that, or do you mean it should play each row exactly once? Then look into urn or zl scramble...

oootini's icon

cool. thanks a lot!