live.grid random pattern, but "density" control

encoder audio's icon

Hi there guys,

I know that you can fill up a 1 row live.grid with random 0 and 1 values, yet, I'm interested if you can control the density of this randomness somehow?

I mean, if the user sets the "density" to 100%, the whole grid would be filled with 1s.

I'm not sure if I was able to tell what I'm trying to achieve here, but hopefully yes...

TFL's icon

Simple: create a list of random values in a given range, and apply a threshold representing your density. If the random value is below the threshold, you get a 1, if it's below you get a 0.

Here are two ways to do this, list or matrix flavor:

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

double_UG's icon

zl.scramble

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