[PD-dev] loading abstractions into objcts...?

Daniel Heckenberg daniel at bogusfront.org
Mon Sep 23 01:47:33 CEST 2002

Hi Olaf, list

This is similar to a problem that I've just spent some time working on: a
poly~ style object/abstraction array container object. I've been writing
this as a pd internal object because I don't think that it can easily be
done from a external(?).  I'd appreciate any help/comments from those who've
delved inside PD more than I.

Apologies to Olaf - there are more questions than answers here.

I've pasted in the constructor at the end of the message.

Things to note:
This works for objects or abstractions and dynamically creates the inlets
and outlets according to the contained object.

I'm using an inlet proxy object (called ainlet) which is basically vinlet
but without the canvas references.  I attach each my object's inlets to an
ainlet (which simply forwards its input to its output).  Then I connect
(using obj_connect) each ainlet to the inlets of the currently indexed
container member object.  Similarly, I'm using an outlet proxy object.

Is it possible to avoid the proxy objects in any way?  I couldn't see a way
of having multiple inlets on an object that could forward to other inlets on
a contained object (and ideally to multiple inlets for an omni mode)?

Things not supported (yet):
 - Introspection into the contained object/abstraction.  I think that I can
just make a canvas visible somehow?
 - Signals.  (Should be straightforward, I think... it might even work

Other questions:
 - How can this be done better?
 - Can this be done as an external?
 - Should I just programmatically create a canvas with my objects (inlets
and outlets) in it and connect them together (avoids custom ainlet/aoutlet
 - Should this object just be a specialization of the canvas class?


static void *objarray_new(t_symbol *s, int argc, t_atom *argv)
	t_objarray *x = NULL;

	if (argc >= 2)
		int i;

		x = (t_objarray *)pd_new(objarray_class);
		x->x_nobj = atom_getfloat(&argv[argc-1]);
		x->x_index = -1;
		x->x_objname = atom_getsymbol(&argv[0]);
		x->x_objarray = (t_object**)getbytes(x->x_nobj * sizeof(t_object*));

		// make the object array
		for (i = 0; i < x->x_nobj; i++)
			pd_typedmess(&pd_objectmaker, x->x_objname, argc-2, argv+2);
			x->x_objarray[i] = (t_object*)newest;
			if (newest && pd_class(newest) == canvas_class)
			    	canvas_loadbang((t_canvas *)newest);

		// make the inlet and outlet arrays
		x->x_ninlets = obj_ninlets(x->x_objarray[0]);
		x->x_noutlets = obj_noutlets(x->x_objarray[0]);
		x->x_inarray = (t_ainlet**)getbytes(x->x_ninlets * sizeof(t_ainlet*));
		x->x_outarray = (t_aoutlet**)getbytes(x->x_noutlets * sizeof(t_aoutlet*));

		// make the inlets
		for (i = 0; i < x->x_ninlets; i++)
			x->x_inarray[i] = ainlet_new(NULL);
			inlet_new(&x->x_obj, &x->x_inarray[i]->x_obj.ob_pd, 0, 0);

		// make the outlets
		for (i = 0; i < x->x_noutlets; i++)
			x->x_outarray[i] = aoutlet_new(outlet_new(&x->x_obj, NULL));

		// make the index inlet
		inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("index"));
	} else
		error("objarray: usage [objarray object_name <args> array_size]");


> -----Original Message-----
> From: pd-dev-admin at iem.kug.ac.at [mailto:pd-dev-admin at iem.kug.ac.at]On
> Behalf Of Olaf Matthes
> Sent: Friday, 20 September 2002 6:44 PM
> To: PD dev
> Subject: [PD-dev] loading abstractions into objcts...?
> Hi developers,
> say I have an abstraction having one (control) inlet and one (control)
> outlet and an external with the same number of inlets/outlets that does
> nothing by it's own. What I now would like to do is to 'load' the
> abstraction into may external instead of loading it as a 'stand-alone
> object'. Thus my external would always be there but I could load
> different abstractions into it. Would that be possible without having to
> write a second Pd in an external?
> I tried some things but it all ended up in a new canvas popping up
> containing my abstraction (or parts of it or even parts of the calling
> patch...).
> please enlighten me!
> Olaf
> _______________________________________________
> PD-dev mailing list
> PD-dev at iem.kug.ac.at
> http://iem.kug.ac.at/cgi-bin/mailman/listinfo/pd-dev

More information about the Pd-dev mailing list