Forums > MaxMSP

### Easiest way to fill matrixctrl with random values?

Dec 03 2008 | 8:09 pm

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?

Dec 03 2008 | 8:17 pm

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

Dec 03 2008 | 8:33 pm

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

Dec 03 2008 | 9:05 pm

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 4×8 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"

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.

Dec 03 2008 | 9:38 pm

Here is the method Adam described:

lh

— Pasted Max Patch, click to expand. —
Dec 03 2008 | 10:15 pm

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

Andrew B.

— Pasted Max Patch, click to expand. —
Dec 04 2008 | 5:51 am

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…

Dec 04 2008 | 5:59 am

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…

Dec 04 2008 | 6:26 am

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 [+].

— Pasted Max Patch, click to expand. —
Dec 04 2008 | 6:40 am

Dec 04 2008 | 6:44 am

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

— Pasted Max Patch, click to expand. —
Dec 04 2008 | 7:39 am

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

Thanks for all the great suggestions!

Dec 04 2008 | 8:07 am

Dec 04 2008 | 8:56 am

Great stuff, Chris – thanks!

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

Dec 04 2008 | 7:13 pm

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 4×8 matrix, but since you mentioned scalability, at anything over say 100×100 the perfectionist might want to look at another noise source.

Mar 24 2010 | 8:11 pm

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?

— Pasted Max Patch, click to expand. —
Mar 24 2010 | 11:00 pm

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…

try this:

``````
-- Pasted Max  Patch, click to expand. --

```
```
Mar 24 2010 | 11:42 pm

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…:)

— Pasted Max Patch, click to expand. —
Mar 25 2010 | 5:57 am

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

``````
-- Pasted Max  Patch, click to expand. --

```
```
Mar 25 2010 | 10:20 am

cool. thanks a lot!

Viewing 20 posts - 1 through 20 (of 20 total)

Forums > MaxMSP