random between two numbers

Apr 16, 2012 at 11:22am

random between two numbers

Hi all!
How is possible in max to do a random number between a minimum and a maximum?
For example if i want random numbers between 5 and 8, only in this range how can i?


Apr 16, 2012 at 11:25am

to get 4 random numbers you need [random 4], which will generate numbers between 0 – 3, use [+ 5] to bring those values up to the required range.


Apr 16, 2012 at 11:32am

Another method is to use the expr object. The random function allows you to determine the minimum and maximum range of numbers.

Marc P.

  1. Rnd.maxpat
Apr 16, 2012 at 1:26pm


Apr 16, 2012 at 1:33pm

Last question… and if i want to save this patch and turn it in a mxo how can i do? thanks

Apr 16, 2012 at 3:43pm

Kind of lazy, but I always use the [between] object in the RTC library.

Apr 17, 2012 at 1:19pm

.mxo’s are written in C.

If you want to reuse your patch as an abstraction, save it as a .maxpat inside your search path and instantiate it by using the file name. BTW, this is all covered with nice, simple explanations in the Tutorials.

I’m also kind of lazy and just use lp.tata from Litter Power.


You must be logged in to reply to this topic.