[PD] re: state saving

Frank Barknecht fbar at footils.org
Thu Nov 27 23:30:29 CET 2003


Hallo,
florian grassl hat gesagt: // florian grassl wrote:

> try the method that frank barknecht uses in his angriff/seq stuff.
> it writes the values of guis to a textfile and can therefore be
> reloaded dead quick. ( http://footils.org/cgi-bin/cms/     ;thank
> you frank!)

Actually I'm converting all my patches to use Thomas Grill's "pool"
currently, which has several advantages above all other methods of
persistence I tried so far and is now my "Memento" of choice. A new
release of angriff & co using that approach may be ready next week. 

Memento here refers to a software design pattern. Using pool it is
possible to abstract the persistance from the algorithm, that's needs
to persist a state somehow. The way I (intend to) use pool here is to
have a pool object somewhere in an abstraction that is used in e.g.
angriff and that gets a user defined name, so it can share it's
settings with all other pool objects. The actual saving is removed
from angriff and will be the responsibility of the patch author. But
with pool it's dead simple. It's a bit difficult to explain in words,
though, so I'll better attach an example: 

tester.pd is the main patch, that uses the pool-abs abstraction two
times. Each pool-abs contains a named pool object, that gets its name
from the first argument ($0-storage in example). The second argument
is just a key that makes both abstractions use unique names, so that
you can store different settings in each.

tester.pd also has a named pool object, that bares the same name as
the other two pools. This creates a magic global and instantaneous
connection between all the pools (like the tunneling effect in quantum
physics)

So all saving of all used patches can be done in a central place. Dave
MacCallum had to overcome a lot of ugly obstacles to do largely the
same just with builtin objects in his reworked d-angriff patches and a
lot of other patches, but with pool it's so much more simple, that
it's worth the extra external. Dave, don't you agree after seeing the
attached example?

In the end angriff et al. will make use of pool hierarchies but that's
too much to explain here and now.

ciao
-- 
 Frank Barknecht                               _ ______footils.org__
-------------- next part --------------
#N canvas 71 133 708 451 10;
#X floatatom 37 394 5 0 0 0 - - -;
#X floatatom 347 395 5 0 0 0 - - -;
#X obj 18 9 cnv 15 500 160 empty empty Saving/Loading 20 12 0 14 -233017
-66577 0;
#X obj 251 37 bng 15 250 50 0 empty empty empty 0 -6 0 8 -258699 -1
-1;
#X obj 56 41 bng 15 250 50 0 empty empty empty 0 -6 0 8 -24198 -1 -1
;
#X msg 56 85 save storage.dat;
#X msg 281 85 load storage.dat;
#X obj 251 58 t b b;
#X obj 187 84 send restore;
#X obj 37 199 r restore;
#X obj 127 117 pool \$0-storage;
#X obj 347 240 pool-abs \$0-storage 2;
#X obj 37 240 pool-abs \$0-storage 1;
#X text 254 189 Patch argument 1: Name of storage;
#X text 243 117 Storage name is the same as below!;
#X text 253 202 Patch argument 2: Arbitrary value (number here \, but
symbol is possible \, too) as unique key;
#X text 69 146 Save/load could go into an abstraction as well.;
#X connect 3 0 7 0;
#X connect 4 0 5 0;
#X connect 5 0 10 0;
#X connect 6 0 10 0;
#X connect 7 0 8 0;
#X connect 7 1 6 0;
#X connect 9 0 11 0;
#X connect 9 0 12 0;
#X connect 11 0 1 0;
#X connect 12 0 0 0;
-------------- next part --------------
#N canvas 300 202 324 156 10;
#X obj 2 22 cnv 15 300 40 empty empty Not_yet_angriff_here 20 12 0
14 -261681 -66577 0;
#X obj 23 96 hsl 128 15 0 127 0 0 empty empty empty -2 -6 0 8 -262144
-1 -1 12700 1;
#N canvas 676 224 450 300 poolstuff 0;
#X obj 126 97 pool \$1;
#X obj 126 23 inlet;
#X obj 126 162 outlet;
#X obj 207 23 inlet;
#X text 62 21 Setter;
#X text 262 23 Getter;
#X obj 126 44 pack 0 \$2;
#X obj 207 46 f \$2;
#X msg 207 68 get \$1;
#X msg 126 67 set \$2 \$1;
#X connect 0 0 2 0;
#X connect 1 0 6 0;
#X connect 3 0 7 0;
#X connect 6 0 9 0;
#X connect 7 0 8 0;
#X connect 8 0 0 0;
#X connect 9 0 0 0;
#X restore 158 92 pd poolstuff;
#X obj 249 86 bng 15 250 50 0 empty empty read-out 0 -6 0 8 -262144
-1 -1;
#X obj 158 122 outlet;
#X msg 97 122 set \$1;
#X obj 214 55 inlet;
#X connect 1 0 2 0;
#X connect 2 0 4 0;
#X connect 2 0 5 0;
#X connect 3 0 2 1;
#X connect 5 0 1 0;
#X connect 6 0 3 0;
#X coords 0 0 1 1 304 140 1;
-------------- next part --------------
 , 1 , 79
 , 2 , 32


More information about the Pd-list mailing list