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?

Thanks!!

#63005
Apr 16, 2012 at 11:25am

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

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

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

Great!!!

#227382
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

#227383
Apr 16, 2012 at 3:43pm

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

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

#227385

You must be logged in to reply to this topic.