[PD-dev] PD patches in XML

Johannes M Zmoelnig zmoelnig at iem.at
Mon Dec 13 12:21:40 CET 2004


just some comments...

Georg Holzmann wrote:
> ---------in-xml--------------------------------
> <canvas xpos="828" ypos="549" height="450" width="341">
> 
>   <obj ID="obj0" xpos="49" ypos="134"> print </obj>
>   <msg ID="msg0" xpos="49" ypos="45"> bang </msg>
>   <obj ID="obj1" xpos="49" ypos="105"> f 2 </obj>
>                      <!-- should 2 be an extra tag for init arg ? -->

i think this inherits a bit the weaknesses of pd's standard format.

which is: mixing up functionality (object-name), modifiers (arguments) 
and graphical representation (position).
i would rather seperate them as much as possible, something like

<canvas>
  <gui xpos="828" ypos="549" height="450" width="341">
  <obj ID="obj1">
   f
   <args>2</args>
   <gui xpos="49" ypos="134">
  </obj>
  <obj ID="obj2">
   trigger
   <args>float float</args>
   <gui xpos="49" ypos="134" bgcolor="#FF00FF">
  </obj>
</canvas>

or even worse, breaking lists of arguments into several tags:

<canvas>
  <gui xpos="828" ypos="549" height="450" width="341">
  <obj ID="obj2">
   trigger
   <arg>float</arg>
   <arg>b</arg>
   <gui xpos="49" ypos="134" bgcolor="#FF00FF" width="100">
  </obj>
</canvas>

(some things are not implemented yet in pd...)

as with pd-0.38, objects that pd's not able to create still connect (i 
guess with some wild hack that tracks the highest number of connected 
outlets of an object)
this could also be done simply by giving meta-information such as
  <obj ID="obj10" inlets="1" outlets="4">foo</obj>

> 
>   <connect>
>     <outlet ID="msg0"> 0 </outlet>   <!-- is this good? -->
>     <inlet ID="obj1"> 0 </inlet>
>   </connect>
>   <connect>
>     <outlet ID="obj1"> 0 </outlet>
>     <inlet ID="obj0"> 0 </inlet>
>   </connect>
> </canvas>

well i am not at all into XML (so i do not know which restrictions you 
can put into a validator) but i guess this syntax is very prone for 
things like
<connect>
   <outlet ID="obj1">0</outlet>
   <outlet ID="obj2">1</outlet>
</connect>

how could you avoid this ? (connecting 2 outlets)




i think mathieus rejections are not valid within this context::
it is not clear from your example (because it is short), but:
  object-identifiers ("ID") should be unique identifiers, at least 
within the scope of a (canvas-) tag.
ID's should be able to be chosen arbitrarily, so this would be a valid 
patch:

<canvas>
  <msg ID="foo">bang</msg>
  <obj ID="bar">print</obj>
  <connect>
   <outlet ID="foo" n="0"/>
   <inlet  ID="bar" n="1"/>
  </connect>
  <obj ID="obj9">until</obj>
  <connect>
   <outlet ID="foo" n="0"/>
   <outlet ID="obj9" n="1"/>
  </connect>
</canvas>

pd could give ID's automaticaly, most probably with a counter (like 
"obj0", "obj1", "obj2",...)
on deletion of such an object the ID would be lost, but who cares ?
people that are writing patches in a text-editor could choose whatever 
ID they like (but have to make sure, that it is unique)


another question that arises for me is, whether it is really good to 
separate strictly between objects (and messages) and connections, or 
whether connections are just part of objects.
something like

<obj ID="foo">print</obj>
<msg ID="bar">
  bang
  <connect n="0">
   <inlet ID="foo" n="0">
   <gui color="red">comment</gui>
  </connect>
</msg>

this is just a wild suggestion, having not thought clearly about whether 
it is better to connect bottom-up or top-down (probably allow both in 
addition to distince <connect>-tags that are free-flowing)



as for the index-naming mechanism: i do not think that anyone should 
bother whether this is fast or slow; most likely (if you don't decide to 
use something very stupid as the base for the ID-mechanism) it is way 
faster than the gensym() that needs to be called for each object that 
gets created; so lets skip premature optimization



mfg.as.dr
IOhannes




More information about the Pd-dev mailing list