[PD] Variable in/outlets

Thomas Grill gr at grrrr.org
Fri Aug 20 21:43:24 CEST 2004


Hi Gerard,

> BTW dyn~ is very nice, but doesn't seem to work with GEM for some reason.

Hmmm, it works for me... can you send me a simple demonstration patch?

> The original idea was that you can make an abstraction to act (for
> instance) like pack but will all inlets active.
> Hiding a bunch of [t b a]'s inside. And that it would be nice if you can
> make a single abstraction like this with a variable number of inlets, so
> that you don't have to make a seperate one for each case.
>
> Can this be done at all?

one way would be to use py/pyext

----------------------------------

# Python script: pak.py

import pyext

class pak(pyext._class):
    def __init__(self,n):
        # n should be type-checked
        self._inlets = n
        self._outlets = 1
        # initialize list
        self.lst = [0 for x in range(n)]

    def _anything_(self,n,args):
        # args should be type-checked!
        self.lst[n-1] = args
        self._outlet(1,self.lst)

--------------------------

PD patch:

#N canvas 463 293 278 228 12;
#X obj 17 32 nbx 5 14 -1e+037 1e+037 0 0 empty empty empty 0 -6 0 10
-262144 -1 -1 18 256;
#X obj 34 52 nbx 5 14 -1e+037 1e+037 0 0 empty empty empty 0 -6 0 10
-262144 -1 -1 11 256;
#X obj 56 68 nbx 5 14 -1e+037 1e+037 0 0 empty empty empty 0 -6 0 10
-262144 -1 -1 13 256;
#X obj 68 88 nbx 5 14 -1e+037 1e+037 0 0 empty empty empty 0 -6 0 10
-262144 -1 -1 21 256;
#X obj 118 29 nbx 5 14 -1e+037 1e+037 0 0 empty empty empty 0 -6 0
10 -262144 -1 -1 13 256;
#X obj 135 49 nbx 5 14 -1e+037 1e+037 0 0 empty empty empty 0 -6 0
10 -262144 -1 -1 13 256;
#X obj 157 65 nbx 5 14 -1e+037 1e+037 0 0 empty empty empty 0 -6 0
10 -262144 -1 -1 10 256;
#X obj 169 85 nbx 5 14 -1e+037 1e+037 0 0 empty empty empty 0 -6 0
10 -262144 -1 -1 11 256;
#X obj 36 168 print;
#X obj 37 129 pyx pak pak 8;
#X connect 0 0 9 1;
#X connect 1 0 9 2;
#X connect 2 0 9 3;
#X connect 3 0 9 4;
#X connect 4 0 9 5;
#X connect 5 0 9 6;
#X connect 6 0 9 7;
#X connect 7 0 9 8;
#X connect 9 0 8 0;

--------------------------------------

best greetings,
Thomas





More information about the Pd-list mailing list