[PD] Simple editor like patch for dynamically create/delete objects.........

Frank Barknecht fbar at footils.org
Fri Nov 26 00:41:38 CET 2004


Hallo,
chun lee hat gesagt: // chun lee wrote:

> Yes, I know of dyn~ but have not tried it yet. I should find sometime to try
> it. Will look at it a bit later, am on my way out just now. But I like the
> way that things that have been created and deleted are all viewable, is this
> true in dyn~?

It is viewable, but connections are not. Also it's not possible to
edit the patch by hand, or rather, it is possible, but against the
whole concept of dyn~. 

The real advantage is scripting. With dyn~ every object you create has
to get identifiers, for example "foo" and "bar".  These ids can be
used to make connections then or send messages.  [connect foo 0 bar 0(
then will connect object foo outlet 0 to object bar inlet 0. This is
very clean, especially if combined with scripting in e.g. Python:


id = 0

class Obj:
    def __init__(self, theObj, target="."):
        # stupid, I know, see below. Just for illustration!
        global id
        self._id = "/obj_%d" % id
        id = id + 1
        print "newobj %s %s %s, " % (target, self.id(), theObj)

    def delete(self):
        print "del %s, " % self._id
        # here id gets out of sync, so don't use this naive approach!
        global id
        id = id - 1
        self._id = None

    def id(self):
        return self._id

    def connect(self, otherObject, my0utlet=0, theirInlet=0):
        print "conn %s %d %s %d, " % (self.id(), my0utlet,
            otherObject.id(), theirInlet)
    
    def disconnect(self, otherObject, my0utlet=0, theirInlet=0):
        print "dis %s %d %s %d, " % (self.id(), my0utlet,
            otherObject.id(), theirInlet)

o1 = Obj("f 0")
o2 = Obj("+ 1")
o1.connect(o2)
o2.connect(o1, 0, 1)
o1.disconnect(o2)
o2.delete()
o1.delete()


etc. or similar.

This idea is developed further with Thomas' dyn-library, which he
presented in Graz. There should be a paper on the convention site.

Hint: You see, how I used a slash to start the object's name? ;)

Ciao
-- 
 Frank Barknecht                               _ ______footils.org__




More information about the Pd-list mailing list