Académique Documents
Professionnel Documents
Culture Documents
Abstra
t
DesireData is a derivative of PureData with many goals, the rst of
whi
h is to implement a true
lient-server separation of the
ore vs the
GUI. It is part of the devel_0_39 bran
h of PureData, available as a
ompile-time option. This paper serves as an introdu
tion to DesireData
and its design prin
iples. It is primarily targeted at people who are familiar with the
urrent development status of PureData; however, we hope
to attra
t keen developers through the new features of DesireData.
Contents
1
Introdu tion
1.1
Prin
iples
2.1
. . . . . . . . . . . . .
3.1
3.2
Obje
tive T
l . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.1.1
Classes
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.1.2
Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.1.3
Instan e Variables
. . . . . . . . . . . . . . . . . . . . . .
3.1.4
Further Developments . . . . . . . . . . . . . . . . . . . .
3.1.5
Client-Server
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.3
Model-View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.4
Observer-Observable . . . . . . . . . . . . . . . . . . . . . . . . .
3.5
. . . . . . . . . . . . . .
3.6
Current status
Introdu
tion
1
DesireData, the name being derived from latin desiderata , is a proje
t whose
main goal is to enhan
e the everyday experien
e of the PureData users and
developers. The most
riti
al
hanges are those that happen in the internals of
PureData, be
ause they enable developers to extend PureData with less eort
and even enable them to do things whi
h otherwise would have been nearly
impossible. Some of those features are: an Obje
t-Orientation extension to T
l,
Model-View separation, Client-Server separation, an abstra
ted RPC me
hanism, et
. DesireData is implemented as a
ompile-time option to PureData's
devel_0_39 be
ause it represents a almost
omplete rewrite of the user interfa
e
odebase, and would ae
t developers using the
onventional PureData UI.
As well, it will mean that DesireData will benet dire
tly from development
progress on that bran
h. This is dierent from the original proje
t, then
alled
ImpureData, whi
h Mathieu Bou
hard developed between February and May
2004, in that a fully separate bran
h had been
reated (impd_0_37), whi
h in
retrospe
t was a real bad idea.
What does this mean to the users? I in
lude developers here: it's user as a
role. Well, a more user-friendly front-end, with aids su
h as
lass browsers,
lass
name
ompletion, argument
ompletion, tooltips on arguments/inlets/outlets,
ongurable look and feel,
olourised
onsole with hyperlinked error messages,
status bar, button bar, T
l evaluator, zoomable
anvas, and so on.
Some of
these features are implemented, some have been in impd_0_37 but need to be
reintegrated in the new
ode, and some are pure vapourware (but have inuen
ed
the design de
isions of either impd_0_37 or DesireData).
This paper aims to present the design and related issues in the implementation of DesireData.
1.1
a CVS repository
the purpose of
entralising the externals so that they are easier to distribute.
Around version 0.38, Miller started using CVS dire
tly. Within the PureData
CVS, there are two bran
hes that are
urrently being developed. The MAIN
bran
h is mostly Miller's eort whereas the devel bran
h is mostly the produ
t
of team eort and is often
onsidered being more exoti
. To be pre
ise, the
desideratum
as something
devel bran
h is a
tually one new bran
h per release of PureData: devel_0_37,
devel_0_38, devel_0_39. Miller does not work on the devel bran
h, whi
h is
ontrary to what happens in most other proje
ts, where all new features rst
start in a devel bran
h, no matter who
odes them, and a new bran
h is
reated
for ea
h stable release, updated only with bugxes.
Prin iples
2.1
The best
By
intera
ting with only one feature whi
h is the
ommon part between the
10 features I just mentioned. That's the point.
3.1
Obje tive T l
A major tool for organising
ode better (and thus enabling better OAOO) is
Obje
t-Oriented Programming (OOP). An in
arnation of it,
alled Obje
tive
T
l, has been designed espe
ially for DesireData (and was merely a dream when
the proje
t was
alled ImpureData). The user interfa
e of PureData is made
using a popular s
ripting language
alled T
l/Tk (as well as way too mu
h C
ode).
way that pro
edures may be organised together. Well, almost so: in a remarkably short pie
e of T
l
ode (no C required), T
l
an be extended with those
additional semanti
s. Yes, all of Obje
tive T
l is written in T
l.
Nota Bene: the name Obje
tive T
l was
hosen with haste and navet, as
there are already a few shovelfuls of OOP systems for T
l, and already at least
two are
alled Obje
tive T
l. It doesn't matter mu
h. We'll pi
k another name
later)
3.1.1
Classes
This rst de
lares a
lass named textbox and also de
ides its inheritan
e.
There is a root
lass
alled thing.
CLASSNAME_new_as whi h
are used to
onstru
t instan
es of the
lass using a generated ID or a spe
ied
ID, respe
tively. The IDs of obje
ts are used as strings; we usually make them
hex
odes.
3.1.2
Methods
The syntax Obje
tive T
l uses for
alling methods (sending messages to obje
ts)
may be des
ribed as the subje
t-verb-
omplements syntax, also known as the
appli
able methods for ea
h message, so that you may now
all a method of any
instan
e of a
lass through the following syntax: OBJECT_ID ACTION ARG1
ARG2 ...
5 In T
l syntax, {} is a list delimiter, pro
s are dened by
alling the pro
pro
, whose
2nd argument is the list of arguments, in whi
h ea
h argument may be represented by a list,
in whi
h the rst element is the name of the argument and the se
ond is the default value.
See? it's
that
easy. ;-) Now just distinguish between dening a pro and alling a pro that's
6 pro def is intended to mimi pro pro ex ept an extra 1st arg has been added so the
Methods sharing the same name in the same hierar hy may be hained using
pro
super {args}, whi
h nds the method in the
hain it is
alled from, and
gures out the next method in the
hain to be
alled. This allows sub
lasses to
wrap methods dened in the super
lass. The method lookup algorithm traverses
the re
eiver's
lass' an
estors, depth-rst, pre-order, with ordered
hildren (ea
h
node has a list of parents), and dupli
ates are (supposed to be) removed, keeping only the last instan
e.
inheritan
e that is used in Lisp, Ruby, and the diale
ts of Smalltalk that have
multiple inheritan
e.
3.1.3
Instan e Variables
In Obje
tive T
l, the sigil is the prex whi
h denotes instan
e variables.
This makes typing variable names mu
h qui
ker
ompared to what it was in
ImpureData. For example, instead of typing _($self:x), all we need to do now
is just x. Furthermore, this makes it easy to adapt the existing
ode to work
with the new
di t feature
as a list instead. All that is required is to update the arguments of regsub that
handles the prex substitution (in
3.1.4
pro def).
Further Developments
able to update one's own obje
t system allows one to grow the system as needs
grow. The world does not end at C++. It doesn't even end at Ruby.
If we
have a use for them, we
ould implement more exoti
OOP features su
h as:
lass-obje
ts, meta-
lasses, ree
tion, delegators, around-methods,
ontra
ts,
point
uts/advi
es, multiple-dispat
h, et
.
Update: there are OOP systems for T
l that support those features. We
will
onsider one to be bundled with PureData, with a free enough li
ense or
maybe we
an sti
k with what we've got, to satisfy Mathieu's language design
addi
tions.
3.1.5
thing
> view
|>
|>
|>
>
< observable
wire
canvas
scalar
box
|> textbox
|
|> objectbox
|
|> atombox
|
|> messagebox
|
> comment
|> numbox
|> radio
|> slider
|> bang
|> toggle
|> vu
|> dropper
> cnv
In this
observable.
3.2
Client-Server
In the
urrent PureData, the
ode that handles GUI elements mostly lies in the
server. For example, the
lient sends ba
k the mouse positions and then the
server gures out whi
h obje
ts needs to be sele
ted and updated. As a result,
the
ommuni
ation between the server and the
lient is very
ongested and the
server is doing most of the work that the
lient
ould/should do.
Desiredata therefore de
ouples su
h a Client-Server relationship by implementing a Model-View design, removing the rendering
ode from the server and
rewriting it as part of the
lient.
3.3
Model-View
The Model-View design essentially refers to the separation of GUI obje
ts into
a non-GUI (Model) part and a GUI part (View). The Model lives in the server
while the View lives in the
lient. This Model-View implementation is similar
to the standard Model-View-Controller[3 design but with two main dieren
es.
First, the View and Controller in DesireData refers to a single entity. Se
ond, a
opy of Model is stored in the View. This is be
ause that Model and View may
be far apart so that it's more e
ient to
a
he the Model's data in the
lient.
This
ould have also been handled by
opying ea
h Model obje
t on the
lient
as separate from the View, but for today's needs, the benets of that separation
are not obvious.
3.4
Observer-Observable
To handle the
ommuni
ation between Model (on the Server) and View (on the
Client), an Observer-Observable[4 pattern is implemented, as in most implementations of MVC. Several instan
es of the pattern are
hained to ea
h other
for several reasons.
First, ea
h obje
t is observed by its owner, so that noti
es are aggregated
towards the root of a tree and then managed together using an ordered-set
(priority queue) that prioritizes updates, removes dupli
ate updates, and delays
too frequent updates.
Se
ond, there are two su
h trees (per pat
her window): the tree of models
organises the sending of updates to the views on the
lient; the tree of views
organises the sending of updates to the Tk
anvas. (We have not veried whether
any other systems do Observers the way we do; in fa
t Mathieu has just
hanged
the design of DesireData's Observers and at the time of this writing they're not
really implemented yet).
In the server, the updates get s
heduled using one
pat
her window.
t_ lo k
allba k per
pro after.
Both
me
hanisms are fun
tionally equivalent, it's just that one is a server-side feature
of Pd, and the latter is a feature of T
l.
3.5
sys_vgui()
sys_vgui()
generates
.x82946
0 450 300 +0+0 1 that are evaluated as T
l
ode on the
lient side,
alling pro
pdtk_
anvas_new. DesireData
repla
es
s, x1, y1, name), where s means two oats and a string. This way, the
aller is no longer
onstru
ting T
l
ode strings and does not have to know T
l
syntax.
many that
urrently plague the use of bra
es, ba
kslashes and even spa
es (!)
within strings sent through
sys_vgui().
pd_upload()
making data updates and letting the
lient gure out whi
h methods have to
be
alled and when. This is the part that sits between both Observer noti
ation trees mentioned above. It
opies the server-side obje
t to the
lient-side
using
t_savefn,
*.pd
le
format. A faster upload me
hanism may send only dieren
es from previously
sent data by notifying only about attributes being modied instead of about the
whole obje
t. The noti
es are still sent towards a pat
her window Model whi
h
now also manages dirty-sets of attribute-keys within ea
h entry in its priority
queue; noti
es relative to a same Model obje
t get
oales
ed by
omputing the
set-unions of their dirty-sets; and when the time of
pd_upload()
omes, only
the new data is sent, whi
h
ould be X11-style (send a bit-set of keys, then all
the values) or keyword-argument style (alternate between keys and values).
3.6
Current status
DesireData is
urrently in its early stage of development and is not fun
tional.
Obje
tive T
l has already been implemented along with parts of the rendering
ode in the
lient, while the Observer-Observable pattern is
urrently being
implemented.
Referen
es
[1 T
l by John Ousterhout, 1987; T
l8, 1997.
[2 Tk, a GUI toolkit for T
l.
[3 http://en.wikipedia.org/wiki/MVC
http://
2.
om/
gi/wiki/wiki?ModelViewController
[4 http://
2.
om/
gi/wiki/?ObserverPattern
http://
2.
om/
gi/wiki/wiki?PublishSubs
ribeModel
http://en.wikipedia.org/wiki/Observer_pattern