Forums > MaxMSP

how do i change the seed number for urn?

June 12, 2008 | 2:58 am

I am working on a patch that will generate a random pattern that repeats, but I want to be able to change the random pattern by having some kind of GUI to allow the user to change the seed number while the patch is running so that the next time urn gets cleared and seeded the pattern will change. Can someone please tell me how to go about doing this?

Feel free to paste in text of the patch file as an example. I figured out how to open the text as a patch.

Thank you!!!


June 12, 2008 | 3:01 am

I forgot to mention, I am using MaxMSP 4.6.


June 12, 2008 | 3:13 am

as the help file says, you can send the seed message followed by an integer to set the seed value for urn.

however the output of urn will be different every time you send it the clear message. no need to re-seed.

-rob


June 12, 2008 | 4:47 am

On Jun 11, 2008, at 7:58 PM, mike wrote:
> Can someone please tell me how to go about doing this?

This is an abstraction I use, called UrnCounter, which repeats a
random pattern, over a settable range, and allows you to set the seed.

– Pasted Max Patch, click to expand. –

Chris Muir
cbm@well.com

http://www.xfade.com


June 12, 2008 | 8:43 am

robtherich,

I’m not sure you understood my post. I am looking for a way to change the seed number through a GUI (like a number object) when the patch is locked. I can’t seem to find anything about how to change the argument to the seed message when the patch is locked in the help file.

I know the urn sequence can be repeated by clearing it and banging it with the same seed number repeatedly. But if you want to change the sequence, you need to change the seed number. I’m not trying to use urn to do complete random output with no repetition. I am trying to repeat random patterns for a set amount of time, and then change the seed number to get a different random pattern either at intervals, or whenever I choose by changing the seed number manually while the patch is running.

Chris Muir,

Um… I’m not sure what to do with that text. The text format I was referring to would be what you get if you save a patch as a text file. Then, it can just be renamed with a .pat extension and opened as a patch.

It looks like you are using MaxMSP 5. Do you know if this will still run on 4.6? If so, how can I convert that text and run it as a patch in my version? I’m used to seeing something like this for the text of a patch:

max v2;
#N vpatcher 135 97 735 497;
#P toggle 295 147 15 0;
#P window setfont "Sans Serif" 9.;
#P number 295 232 54 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 295 179 58 196617 metro 500;
#P newex 295 207 58 196617 random 12;
#P message 134 253 95 196617 seed 9419;
#P newex 134 230 62 196617 prepend set;
#P newex 178 162 103 196617 sprintf seed %i%i%i;
#P button 163 65 15 0;
#P newex 163 87 48 196617 loadbang;
#P message 163 111 30 196617 time;
#P newex 163 136 40 196617 date;
#P fasten 4 0 5 0 183 199 139 199;
#P connect 5 0 6 0;
#P connect 3 0 2 0;
#P connect 2 0 1 0;
#P connect 1 0 0 0;
#P connect 0 1 4 0;
#P connect 10 0 8 0;
#P fasten 4 0 7 0 183 200 300 200;
#P connect 8 0 7 0;
#P connect 7 0 9 0;
#P pop;

Thanks!

Mike


June 12, 2008 | 9:53 am

On 12 juin 08, at 10:43, mike wrote:

> I’m not sure you understood my post. I am looking for a way to
> change the seed number through a GUI (like a number object) when the
> patch is locked. I can’t seem to find anything about how to change
> the argument to the seed message when the patch is locked in the
> help file.

What about this:

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 126 144 27 196617 urn;
#P message 116 107 45 196617 seed $1;
#P number 120 69 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P connect 1 0 2 0;
#P connect 0 0 1 0;
#P window clipboard copycount 3;

_____________________________
Patrick Delges

Centre de Recherches et de Formation Musicales de Wallonie asbl

http://www.crfmw.be/max


June 12, 2008 | 4:34 pm

On Jun 12, 2008, at 1:43 AM, mike wrote:

> Um… I’m not sure what to do with that text.

That’s the Max5 compressed clipboard format.

I do happen to have that abstraction in Max 4, too. Here it is, along
with its help file -
Save this as UrnCounter.pat:

max v2;
#N vpatcher 314 44 787 484;
#P origin 0 -2;
#P window setfont "Sans Serif" 9.;
#P newex 117 288 45 196617 onebang;
#P newex 330 262 43 196617 route 0;
#P newex 350 154 52 196617 unpack i i;
#P newex 350 135 88 196617 patcherargs 52 1;
#N comlet Cycle;
#P outlet 339 398 15 0;
#P comment 354 398 34 196617 Cycle;
#P hidden comment 0 412 55 196617 lower left;
#P window linecount 2;
#P comment 2 34 442 196617 Steps through a random pattern between
RangeLow and RangeHigh. A bang in NewPattern creates a new random
pattern (and reports the seed). Seeds can be passed in through
NewPattern.;
#P window linecount 1;
#P newex 276 205 40 196617 t b b i;
#P newex 330 243 27 196617 – 0;
#P newex 276 185 27 196617 – 1;
#P newex 27 366 27 196617 + 1;
#N comlet Seed;
#P outlet 232 397 15 0;
#P comment 247 397 34 196617 Seed;
#P newex 142 104 72 196617 route bang int;
#P comment 271 83 57 196617 Range Low;
#N comlet Range Low;
#P inlet 254 83 15 0;
#P comment 347 83 64 196617 Range High;
#P comment 103 83 35 196617 Reset;
#P comment 43 83 29 196617 Trig;
#P newex 49 182 30 196617 t b b;
#P number 142 156 49 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 142 136 70 196617 random 9999;
#P newex 142 200 85 196617 prepend set seed;
#P newex 88 216 30 196617 t b b;
#P message 142 242 69 196617 seed 5343;
#P newex 27 324 40 196617 urn 52;
#B color 5;
#P message 88 242 33 196617 clear;
#P button 27 242 15 0;
#P comment 158 83 64 196617 NewPattern;
#N comlet Reset;
#P inlet 88 83 15 0;
#N comlet NewPattern;
#P inlet 142 83 15 0;
#N comlet Range High;
#P inlet 330 83 15 0;
#N comlet Trig;
#P inlet 27 83 15 0;
#N comlet Index;
#P outlet 27 397 15 0;
#P comment 42 397 34 196617 Index;
#P window setfont "Sans Serif" 18.;
#P comment 2 6 108 196626 UrnCounter;
#P window setfont "Sans Serif" 9.;
#P comment 110 19 71 196617 Deck Shuffler;
#P comment 298 58 122 196617 Args: high and low range;
#P comment 110 7 73 196617 By Chris Muir;
#P connect 6 0 11 0;
#P connect 19 0 11 0;
#P connect 11 0 13 0;
#P connect 14 0 13 0;
#P connect 12 0 13 0;
#P connect 13 0 28 0;
#P connect 28 0 5 0;
#P fasten 37 1 28 1 397 360 49 360;
#P fasten 23 0 28 1 259 360 49 360;
#P fasten 13 1 19 0 62 349 12 349 12 176 54 176;
#P fasten 38 1 13 1 368 317 62 317;
#P connect 9 0 15 0;
#P connect 19 1 15 0;
#P connect 15 0 12 0;
#P connect 11 0 39 0;
#P connect 8 0 25 0;
#P connect 25 0 17 0;
#P connect 17 0 18 0;
#P connect 25 1 16 0;
#P lcolor 7;
#P connect 18 0 16 0;
#P connect 15 1 14 0;
#P connect 16 0 14 0;
#P connect 31 0 14 0;
#P connect 15 1 39 1;
#P connect 25 1 27 0;
#P lcolor 7;
#P fasten 18 0 27 0 147 181 237 181;
#P connect 23 0 29 0;
#P connect 29 0 31 0;
#P fasten 37 1 29 1 397 179 298 179;
#P connect 37 0 30 0;
#P connect 31 1 30 0;
#P connect 7 0 30 0;
#P connect 30 0 38 0;
#P connect 39 0 35 0;
#P fasten 13 1 35 0 62 349 344 349;
#P connect 31 2 30 1;
#P connect 36 0 37 0;
#P pop;

Save in your max-help folder as UrnCounter.help:
max v2;
#N vpatcher 11 216 478 553;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P message 286 286 45 196617 Counter;
#P message 333 286 22 196617 Uzi;
#P comment 287 272 135 196617 see also: Tutorial 31 , Loops;
#P message 358 286 38 196617 incdec;
#P message 398 286 36 196617 tempo;
#P hidden newex 286 305 64 196617 prepend help;
#P hidden newex 350 304 45 196617 pcontrol;
#P hidden comment 174 134 55 196617 1 , 2 , 3 , 4;
#P hidden message 138 134 34 196617 1390;
#P comment 129 24 72 196617 by Chris Muir;
#P window linecount 2;
#P comment 235 96 177 196617 UrnCounter can take two arguments: Range
High , and Range Low;
#P comment 17 68 407 196617 UrnCounter steps through a random pattern
between RangeLow and RangeHigh. It will repeat this pattern until a
new seed is set.;
#P window linecount 1;
#P hidden message 108 110 26 196617 500;
#P newex 49 130 37 196617 metro;
#P toggle 49 111 15 0;
#P number 76 111 32 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window setfont "Sans Serif" 18.;
#P comment 22 17 106 196626 UrnCounter;
#B frgb 21 56 9;
#P window setfont "Sans Serif" 9.;
#P comment 22 42 292 196617 A "counter" with a random order pattern;
#P user panel 17 12 400 50;
#X brgb 255 247 207;
#X frgb 0 0 0;
#X border 0;
#X rounded 0;
#X shadow 0;
#X done;
#P hidden comment 174 155 55 196617 4 , 3 , 2 , 1;
#P hidden message 138 153 34 196617 7020;
#P hidden newex 243 139 48 196617 loadbang;
#P hidden message 239 178 14 196617 4;
#P hidden message 195 182 14 196617 1;
#P window linecount 2;
#P comment 71 212 34 196617 Reset Cycle;
#P button 101 222 15 0;
#P comment 212 194 34 196617 Range High;
#P number 212 220 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 175 220 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P comment 231 266 34 196617 Cycle;
#P button 214 265 15 0;
#P comment 132 283 69 196617 Current Seed;
#P comment 15 159 34 196617 Clock;
#P comment 17 267 45 196617 "Count";
#P button 129 176 15 0;
#P number 138 219 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 139 265 48 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window setfont "Sans Serif" 14.;
#P number 64 265 43 14 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P button 49 151 27 0;
#P window setfont "Sans Serif" 9.;
#P newex 64 244 160 196617 UrnCounter;
#B color 5;
#P comment 138 205 31 196617 Seed;
#P window linecount 2;
#P comment 175 194 41 196617 Range Low;
#P window linecount 3;
#P comment 101 150 41 196617 New Random Seed;
#P connect 28 0 29 0;
#P connect 29 0 4 0;
#P fasten 4 0 3 0 54 236 69 236;
#P connect 3 0 5 0;
#P hidden connect 30 0 27 0;
#P connect 27 0 29 1;
#P connect 17 0 3 1;
#P hidden connect 21 0 30 0;
#P hidden connect 21 0 22 0;
#P hidden connect 34 0 7 0;
#P hidden connect 22 0 7 0;
#P fasten 8 0 3 2 134 239 143 239;
#P connect 7 0 3 2;
#P connect 3 1 6 0;
#P hidden connect 19 0 14 0;
#P connect 14 0 3 3;
#P hidden connect 21 0 19 0;
#P hidden connect 20 0 15 0;
#P connect 15 0 3 4;
#P connect 3 2 12 0;
#P hidden connect 21 0 20 0;
#P hidden connect 42 0 37 0;
#P hidden connect 41 0 37 0;
#P hidden connect 39 0 37 0;
#P hidden connect 38 0 37 0;
#P hidden connect 37 0 36 0;
#P pop;

Chris Muir
cbm@well.com

http://www.xfade.com


June 13, 2008 | 1:59 am

Awesome! The UrnCounter patch was a bit more complex than what I needed. However, I was able to pull the part of the puzzle I needed out of this patch. The key is using a prepend object with "set seed" as the argument.

Here is the patch for the solution I was trying to find in case anyone else is looking for it.

max v2;
#N vpatcher 744 383 1344 783;
#P window setfont "Sans Serif" 9.;
#P number 40 109 49 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 40 158 85 196617 prepend set seed;
#P message 40 200 69 196617 seed 81;
#P connect 2 0 1 0;
#P connect 1 0 0 0;
#P pop;

As you will notice, this just allows you a simple way of changing the seed number through a number box.

Also, I just found out something really cool. All you need to do is select the text above and paste it into a new patch, and it will paste in the actual objects in the patch! This works in reverse too, so if you want to give someone a patch file, all you have to do is highlight/select everything in the patch, apple+c to copy, then apple+v to paste it into text. Apparently MaxMSP handles translating the objects into the text of the code through the Mac OS somehow. Neat!

Thanks again for your very helpful response!

Mike


June 13, 2008 | 3:28 am

On Jun 12, 2008, at 6:59 PM, mike wrote:
> The key is using a prepend object with "set seed" as the argument.

If that’s all you need, Patrick’s solution, a few messages back, will
do the job slightly more easily.

-C

Chris Muir
cbm@well.com

http://www.xfade.com


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