[PD] Random number generation quest

Lorenzo Sutton lorenzofsutton at gmail.com
Wed Nov 14 16:57:59 CET 2012


On 14/11/12 15:53, Enrique Erne wrote:
> Hi List!
>
> Can a random number form 0 to 100 be generated with the following requirements:
>
>    - No externals / Vanilla Pd only
>    - DSP must be off
>    - The patch is loaded with Pd through command line interface i.e.
> `pd -noprefs -nogui givemerandom.pd`
>    - The output should not always be the same number
>
Something like the attached should do it...

But as someone already pointed out is it really worth it?
Why not just do something like (assuming you have BASH):

echo $[ $RANDOM % 100]

Lorenzo.
-------------- next part --------------
#N canvas 560 444 657 443 10;
#X obj 137 -24 loadbang;
#X obj 139 233 random 100;
#X obj 249 -16 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144
-1 -1;
#X msg 191 356 \; pd-givemerandom.pd menusave 1;
#X obj 191 299 del 10;
#N canvas 0 0 450 300 (subpatch) 0;
#X array array1 1 float 3;
#A 0 25;
#X coords 0 1000 1 0 200 140 1 0 0;
#X restore 426 231 graph;
#X obj 274 202 tabwrite array1;
#X msg 361 175 1;
#X obj 289 55 tabread array1;
#X msg 289 27 1;
#X obj 274 125 f;
#X obj 302 125 + 1;
#X obj 139 264 t f b;
#X obj 137 -1 t b b b b;
#X msg 387 124 0;
#X obj 274 151 t f f b;
#X msg 209 202 seed \$1;
#X text 421 124 manual reset;
#X text 473 206 Y range set from 0 to 1000;
#X text 388 29 'load' the stored seed;
#X text 244 219 add +1 and use as seed \; also save to array;
#X text 190 390 save the patch (and with it the array...);
#X floatatom 339 87 5 0 0 0 - - -;
#X obj 140 332 print RANDOM;
#X connect 0 0 13 0;
#X connect 1 0 12 0;
#X connect 2 0 13 0;
#X connect 4 0 3 0;
#X connect 7 0 6 1;
#X connect 8 0 10 1;
#X connect 8 0 22 0;
#X connect 9 0 8 0;
#X connect 10 0 11 0;
#X connect 10 0 15 0;
#X connect 11 0 10 1;
#X connect 12 0 23 0;
#X connect 12 1 4 0;
#X connect 13 0 1 0;
#X connect 13 1 10 0;
#X connect 13 2 10 0;
#X connect 13 3 9 0;
#X connect 14 0 15 0;
#X connect 15 0 16 0;
#X connect 15 1 6 0;
#X connect 15 2 7 0;
#X connect 16 0 1 0;


More information about the Pd-list mailing list