Forums > MaxMSP

random between two numbers

April 16, 2012 | 11:22 am

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?

Thanks!!


April 16, 2012 | 11:25 am

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

Brendan


April 16, 2012 | 11:32 am

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

Marc P.

Attachments:
  1. Rnd.maxpat

April 16, 2012 | 1:26 pm

Great!!!


April 16, 2012 | 1:33 pm

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


April 16, 2012 | 3:43 pm

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


April 17, 2012 | 1:19 pm

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


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