[PD] left mouse click abuse

Mathieu Bouchard matju at artengine.ca
Mon Jan 5 21:19:16 CET 2009


On Mon, 5 Jan 2009, marius schebella wrote:

> 1) the position of the objects is actually not really interesting for
> the pd engine. neither are comments or subpatches.

I'd like to say that object positions do not matter, but [inlet] and 
[outlet] still depend on their x-coordinate to sort themselves. Again the 
solution would be to add an inlet-number or outlet-number as argument of 
those objects, but [inlet~] and [outlet~] already have optional arguments, 
and some people use the arguments of [inlet] and [outlet] to write 
comments as symbols because those arguments are ignored instead of 
forbidden.

> 2) there is no way to add and delete objects. and I think this is not
> only becaue it is not possible to access the total number of objects
> inside a canvas or their individual IDs. there is no communication from
> the Pd engine to the outside world.

It's easy to access the total number of objects as an external. For 
example:

#include <m_pd.h>
#include "g_canvas.h"
typedef struct {t_object o; t_canvas *c;} t_objectcount;
static t_class *objectcount_class;
t_pd *objectcount_new (void) {
   t_objectcount *self = (t_objectcount *)pd_new(objectcount_class);
   self->c=canvas_getcurrent();
   outlet_new((t_object *)self,0);
   return (t_pd *)self;
}
void objectcount_bang(t_objectcount *self) {
   int i=0; t_gobj *o = self->c->gl_list; while (o) {i++; o=o->g_next;}
   outlet_float(self->o.te_outlet,i);
}
void objectcount_setup (void) {
   objectcount_class=class_new(gensym("objectcount"),
     (t_newmethod)objectcount_new,0,sizeof(t_objectcount),0,0);
   class_addbang(objectcount_class,objectcount_bang);
}

And this is very short for a C external.

  _ _ __ ___ _____ ________ _____________ _____________________ ...
| Mathieu Bouchard - tél:+1.514.383.3801, Montréal, Québec


More information about the Pd-list mailing list