Forums > MaxMSP

scripting inlets and outlets

June 27, 2006 | 12:32 am

My collegue is making an abstraction that dynamically generates its inlets and outlet via scripting. The problem with this approach is that connections to this abstraction are not preserved when you save and reopen.

Our two workarounds are either to use javascript or to have the maximum number of inlets saved as part of the abstractions, script the connections needed and then use script to delete the unnecessary inlets.

Is there a cleaner way to do this? Abstraction and help patch below.

thanks,

mzed

-=-=-=-=

save as "OSC-unroute":

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#N vpatcher 40 104 639 612;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 50 252 195 196617 sprintf script connect prepend%d 0 out 0;
#P newex 262 340 194 196617 sprintf script new out outlet 20 %d 15 0;
#P newex 342 170 31 196617 + 60;
#P newex 342 149 32 196617 * 20;
#P newex 342 127 34 196617 zl len;
#P newex 55 72 25 196617 iter;
#P newex 156 316 199 196617 sprintf script new in%d inlet %d 20 15 0;
#P newex 263 212 31 196617 + 30;
#P newex 83 379 42 196617 nothing;
#P newex 55 50 40 196617 t s b l;
#P newex 263 191 32 196617 * 20;
#P newex 227 191 32 196617 * 20;
#P newex 137 158 92 196617 t i i i i i i i;
#P newex 55 94 40 196617 t b s s;
#P message 195 115 14 196617 1;
#P number 246 133 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#N counter 1 10000;
#X flags 0 0;
#P newobj 159 134 84 196617 counter 1 10000;
#P newex 128 294 325 196617 sprintf script new prepend%d newex %d %d 300 196617 prepend %s;
#P newex 75 273 203 196617 sprintf script connect in%d 0 prepend%d 0;
#P window linecount 5;
#P comment 343 64 73 196617 # args determines vertical placement of outlet;
#P inlet 55 30 15 0;
#P outlet 83 401 15 0;
#P connect 9 0 21 0;
#P connect 1 0 12 0;
#P connect 12 0 16 0;
#P connect 16 0 8 0;
#P connect 9 1 3 0;
#P connect 21 0 13 0;
#P connect 20 0 13 0;
#P connect 3 0 13 0;
#P connect 4 0 13 0;
#P connect 15 0 13 0;
#P connect 13 0 0 0;
#P connect 9 3 4 0;
#P connect 5 0 9 0;
#P connect 9 4 15 0;
#P connect 8 0 5 0;
#P connect 12 1 7 0;
#P connect 7 0 5 2;
#P connect 9 5 10 0;
#P connect 10 0 4 1;
#P connect 5 0 6 0;
#P connect 19 0 20 0;
#P connect 9 6 11 0;
#P connect 11 0 14 0;
#P connect 9 2 3 1;
#P connect 14 0 4 2;
#P connect 12 2 17 0;
#P connect 17 0 18 0;
#P connect 18 0 19 0;
#P connect 10 0 15 1;
#P fasten 8 1 4 3 83 242 448 242;
#P pop;
#P newobj 584 94 82 196617 p scripting-guts;
#N thispatcher;
#Q end;
#P newobj 584 120 61 196617 thispatcher;
#P message 543 22 370 196617 /1 /2 /3 /4 /ridicluously-long-osc-messaqge-zzzzzzzzzzzzzzzzz /5 /6 /7 /8;
#P newex 584 66 64 196617 patcherargs;
#P connect 0 0 3 0;
#P connect 1 0 3 0;
#P connect 3 0 2 0;
#P window clipboard copycount 4;

Save as "OSC-unroute.help":

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 31 170 32 196617 print;
#P message 91 113 235 196617 /split ice cream whipped cream bananas hot fudge;
#P message 31 114 56 196617 /pie 1 2 3;
#P newex 31 144 138 196617 OSC-unroute /apple /banana;
#P number 485 196 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 485 115 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 445 196 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 445 115 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 405 196 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 405 115 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 365 196 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 365 115 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 365 168 117 196617 OSC-route /1 /2 /3 /4;
#P newex 365 141 127 196617 OSC-unroute /1 /2 /3 /4;
#P window linecount 2;
#P comment 53 37 367 196617 The opposite of OSC-route: Each argument creates an inlet. Messages received in a given inlet come out the outlet with the corresponding argument prepended.;
#P connect 2 3 10 0;
#P connect 2 2 8 0;
#P connect 2 1 6 0;
#P connect 2 0 4 0;
#P window clipboard copycount 15;



f.e
June 27, 2006 | 5:33 am

Dear mzed,

i forgot all my previous ideas and patches relying on a dynamic
inlets/outlets creation via scripting. As you see, too slow
instanciation to build & connect the inlets/outlets.
And no, there’s no cleaner way i know but this workaround about having
hundred inlets to delete.

f.e

f.e chanfrault | aka | personal computer music
> >>>>>> http://www.personal-computer-music.com
> >>>>>> |sublime music for a desperate people|


June 27, 2006 | 9:32 am

What about dynamically deleting, creating an connecting your dynamic
abstraction.

/J


June 28, 2006 | 3:00 pm

mzed wrote:
> Our two workarounds are either to use javascript or to have the
> maximum number of inlets saved as part of the abstractions, script
> the connections needed and then use script to delete the unnecessary
> inlets.

Deleting unused ins and outs is what I do with all of my abstractions
which have varying numbers of them. Ugly, but works…

The only solution would be a change in the behaviour of Max itself by
creating bogus ins and outs instead of the known error message of
missing blahblah and cutting the connections.

Yes cycling, if your listening, this would be a feature request which
would help around some other nasties as well…
(Ever misstyped an object which had been connected before?…)

Stefan


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


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