Forums > MaxMSP

Random number generation…


February 19, 2007 | 2:55 pm

I’m wondering how I can set the min/max values of a random object, on the fly via two hsliders? I am already using the minimum and maximum objects to determine the absolute min/max values of the two hsliders. Now I need to use the outputs of minimum and maximum to set the min/max values for the random object…

Thanks!

p.s. Sorry for so many posts, I have to build a patch for tomorrow…

February 19, 2007 | 3:05 pm

I have now found a solution via the scale object…

Thanks!

February 19, 2007 | 3:14 pm

I take you need to get a number between two values? If so, give this a
try… It’ll only work for integers. Floats are a little trickier.

Jonathan.

max v2;
#N vpatcher 289 274 889 674;
#P window setfont "Sans Serif" 9.;
#P window linecount 3;
#P comment 59 273 100 196617 random number between low and high given above;
#P window linecount 1;
#P comment 36 48 105 196617 get random int…;
#P newex 53 203 27 196617 + 1;
#P number 20 283 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P button 20 47 15 0;
#P newex 20 249 27 196617 +;
#P newex 53 160 43 196617 pak 0 0;
#P newex 53 183 27 196617 !-;
#P comment 86 113 26 196617 high;
#P number 86 129 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 37 129 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 20 226 43 196617 random;
#P comment 37 113 24 196617 low;
#P window linecount 2;
#P comment 37 84 100 196617 output random number between…;
#P connect 9 0 2 0;
#P connect 2 0 8 0;
#P connect 8 0 10 0;
#P connect 3 0 8 1;
#P fasten 3 0 7 0 42 150 58 150;
#P connect 7 0 6 0;
#P connect 6 0 11 0;
#P connect 11 0 2 1;
#P connect 4 0 7 1;
#P pop;

On 19/02/07, Jack Rosete wrote:
>
>
> I’m wondering how I can set the min/max values of a random object, on the
> fly via two hsliders? I am already using the minimum and maximum objects to
> determine the absolute min/max values of the two hsliders. Now I need to
> use the outputs of minimum and maximum to set the min/max values for the
> random object…
>
> Thanks!
>
> p.s. Sorry for so many posts, I have to build a patch for tomorrow…
>


Jonathan Green
0777 1680 497
jonathan@jg1983.co.uk

February 19, 2007 | 3:21 pm

Check out my random package at

http://www.timara.oberlin.edu/~gnelson/maxdownloads/downloadmax.htm

On 2/19/07 9:55 AM, "Jack Rosete" wrote:

>
> I’m wondering how I can set the min/max values of a random object, on the fly
> via two hsliders? I am already using the minimum and maximum objects to
> determine the absolute min/max values of the two hsliders. Now I need to use
> the outputs of minimum and maximum to set the min/max values for the random
> object…
>
> Thanks!
>
> p.s. Sorry for so many posts, I have to build a patch for tomorrow…

Cheers
Gary Lee Nelson
Oberlin College
http://www.timara.oberlin.edu/GaryLeeNelson

February 19, 2007 | 3:24 pm

The stock random has a fixed minimum of zero. Also note that one of
the most common errors in the world is to think that you are setting
the maximum value of random. You set the number of different integers
random can create, which run from 0 .. n-1.

If you want a random number generator with inlets for min and max,
try lp.tata from the Litter Power Starter Pack. Downloadable from the
address below.

You can patch to get random to do what you want, but lp.tata is an
industrial-strength random number generator. And if you want values
between -25 and 37 it does the thinking for you.

Best,
Peter

On 19-Feb-2007, at 15:55, Jack Rosete wrote:

> I’m wondering how I can set the min/max values of a random object,
> on the fly via two hsliders? I am already using the minimum and
> maximum objects to determine the absolute min/max values of the two
> hsliders. Now I need to use the outputs of minimum and maximum to
> set the min/max values for the random object…

————– http://www.bek.no/~pcastine/Litter/ ————-
Peter Castine +–> Litter Power & Litter Bundle for Jitter

iCE: Sequencing, Recording &
Interface Building for |home | chez nous|
Max/MSP Extremely cool |bei uns | i nostri|
http://www.dspaudio.com/ http://www.castine.de

February 19, 2007 | 3:51 pm

>
>>
>> I’m wondering how I can set the min/max values of a random object,
>>on the fly
>> via two hsliders? I am already using the minimum and maximum objects to
>> determine the absolute min/max values of the two hsliders. Now I
>>need to use
>> the outputs of minimum and maximum to set the min/max values for the random
> > object…

#P user multiSlider 181 304 206 108 0. 100. 1 3193 15 0 0 2 0 0 0;
#M frgb 0 0 0;
#M brgb 255 255 255;
#M rgb2 127 127 127;
#M rgb3 0 0 0;
#M rgb4 37 52 91;
#M rgb5 74 105 182;
#M rgb6 112 158 18;
#M rgb7 149 211 110;
#M rgb8 187 9 201;
#M rgb9 224 62 37;
#M rgb10 7 114 128;
#P window setfont "Sans Serif" 9.;
#P flonum 386 249 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 386 221 99 196617 scale 0 128 0. 100.;
#P user hslider 386 193 18 128 128 1 0 0;
#P newex 236 153 99 196617 scale 0 128 0. 100.;
#P user hslider 236 118 18 128 128 1 0 0;
#P flonum 129 228 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 129 194 105 196617 scale 0 1000 0. 100.;
#P number 129 148 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P toggle 129 43 15 0;
#P newex 129 77 58 196617 metro 100;
#P newex 129 124 70 196617 random 1001;
#P connect 9 0 4 4;
#P connect 9 0 10 0;
#P connect 5 0 11 0;
#P connect 8 0 9 0;
#P connect 7 0 4 3;
#P connect 6 0 7 0;
#P connect 4 0 5 0;
#P connect 3 0 4 0;
#P connect 0 0 3 0;
#P connect 2 0 1 0;
#P connect 1 0 0 0;
#P window clipboard copycount 12;

kasper

February 19, 2007 | 4:54 pm

Thanks for these ideas!

February 19, 2007 | 10:59 pm

Jack Rosete wrote:
> I have now found a solution via the scale object…

And it took only ten minutes…
faster than you’d need to read all the answers…

Have a nice walk in the sun for the rest of your deadline… ;-)

Stefan


Stefan Tiedje————x——-
–_____———–|————–
–(_|_ —-|—–|—–()——-
— _|_)—-|—–()————–
———-()——–www.ccmix.com


_j
February 19, 2007 | 11:15 pm

don’t for the gary lee’s package. I know he mentioned it above, bu t that’s what u want.

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

Forums > MaxMSP