[PD-dev] Data Structures: Arrays shouldn't be that slow

Frank Barknecht fbar at footils.org
Tue Mar 29 17:32:10 CEST 2005


Hi,

attached is a patch which shows a bad performance problem of data
structure arrays. If those arrays are larger and if they are redrawn
in a subpatch, while their surrounding subpatch is visible, the
redrawing is very slow. If however the redrawing happens when the
subpatch is closed, the redraw is very fast even then, when I
immediatly open the subpatch again.

In the attachement, both kinds of behaviour can be switched with a
little radio button marked "hide/show". An array with 800 random
values is written to [pd data] when the red bang is pressed. (You can
set the size to be smaller with the "width" number.

Now, as the drawing can be done very fast in invisibility, I wonder,
if there is some optimization missing for the visible case? And I
wonder, if this optimization shouldn't be rather easy to do? (But this
is just an uneducated guess.)

Ciao
-- 
 Frank Barknecht                               _ ______footils.org__
             
          _ __latest track: "scans" _ http://footils.org/cms/show/41
-------------- next part --------------
#N canvas 360 321 881 527 10;
#N canvas 722 109 450 300 sample 0;
#X obj 56 52 struct sample float y;
#X restore 32 127 pd sample;
#N canvas 0 0 984 622 data 1;
#X restore 37 63 pd data;
#N canvas 664 618 450 300 appender 0;
#X msg 291 152 traverse pd-data \, bang;
#X obj 291 179 pointer;
#X obj 176 124 t b b;
#X obj 173 95 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
-1;
#X obj 99 246 setsize wave s;
#X floatatom 101 224 5 0 0 0 - - -;
#X obj 111 32 inlet;
#X obj 111 52 t f b b;
#X obj 221 237 s last_array;
#X obj 163 203 append wave x y c;
#X msg 274 105 \; pd-data clear;
#X obj 245 37 inlet;
#X obj 168 166 pack 10 300 9;
#X connect 0 0 1 0;
#X connect 1 0 9 3;
#X connect 2 0 12 0;
#X connect 2 1 0 0;
#X connect 3 0 2 0;
#X connect 5 0 4 0;
#X connect 6 0 7 0;
#X connect 7 0 4 0;
#X connect 7 1 3 0;
#X connect 7 2 10 0;
#X connect 9 0 4 1;
#X connect 9 0 8 0;
#X connect 11 0 12 2;
#X connect 12 0 9 0;
#X restore 583 107 pd appender;
#N canvas 391 349 450 300 wave 0;
#X obj 44 104 struct wave float x float y float c array s sample;
#X obj 61 159 plot s c 1 0 0 1 1;
#X obj 51 210 drawpolygon 0 1 0 0 800 0;
#X restore 32 149 pd wave;
#N canvas 216 99 836 754 loadfile 0;
#X obj 611 48 openpanel;
#X obj 611 90 soundfiler;
#X obj 611 16 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
-1;
#X msg 611 69 read -resize \$1 snd;
#X floatatom 611 133 5 0 0 0 - - -;
#X obj 54 135 until;
#X obj 54 167 f 0;
#X obj 82 167 + 1;
#X obj 54 107 t f f f f b;
#X msg 93 136 0;
#X obj 169 173 outlet;
#X obj 281 197 r last_array;
#X obj 188 222 element wave s;
#X obj 543 22 inlet;
#X obj 406 324 * 1;
#X obj 54 40 t b;
#X obj 406 412 * 400;
#X obj 91 39 r display-width;
#X obj 54 447 set sample y;
#X obj 406 390 tabread4 snd;
#X obj 513 192 table snd 200;
#X obj 543 124 s paint;
#X obj 54 13 r paint;
#X obj 422 303 r sample_per_px;
#X obj 406 368 + 0;
#X obj 422 344 r start-sample;
#X obj 54 62 f 800;
#X obj 54 83 min 800;
#X obj 54 407 random 400;
#X obj 54 195 t b f;
#X obj 54 427 - 200;
#X connect 0 0 3 0;
#X connect 1 0 4 0;
#X connect 2 0 0 0;
#X connect 3 0 1 0;
#X connect 5 0 6 0;
#X connect 6 0 7 0;
#X connect 6 0 29 0;
#X connect 7 0 6 1;
#X connect 8 0 5 0;
#X connect 8 3 10 0;
#X connect 8 4 9 0;
#X connect 9 0 6 1;
#X connect 11 0 12 1;
#X connect 12 0 18 1;
#X connect 13 0 21 0;
#X connect 14 0 24 0;
#X connect 15 0 26 0;
#X connect 17 0 26 1;
#X connect 19 0 16 0;
#X connect 22 0 15 0;
#X connect 23 0 14 1;
#X connect 24 0 19 0;
#X connect 25 0 24 1;
#X connect 26 0 27 0;
#X connect 27 0 8 0;
#X connect 28 0 30 0;
#X connect 29 0 28 0;
#X connect 29 1 12 0;
#X connect 30 0 18 0;
#X restore 583 85 pd loadfile;
#X obj 583 66 bng 15 250 50 0 empty empty make_noise 0 -6 0 8 -262144
-1 -1;
#X obj 155 48 s pd-data;
#X msg 155 24 clear;
#X obj 328 130 s display-width;
#X floatatom 298 88 5 0 0 1 width_(px) - -;
#X obj 682 265 s sample_per_px;
#X floatatom 652 218 5 0 0 1 zoom_(samples/px) - -;
#X msg 58 281 bang;
#X obj 80 412 s paint;
#X obj 593 455 mousefilter;
#X obj 652 238 t f f;
#X obj 298 105 t f f;
#X floatatom 726 394 5 0 0 1 startsample - -;
#X obj 726 411 t f f;
#X obj 726 461 s redraw;
#X obj 571 425 r redraw;
#X obj 652 286 s redraw;
#X obj 298 152 s redraw;
#X obj 756 436 s start-sample;
#X floatatom 684 84 5 0 0 1 color - -;
#X obj 684 107 s redraw;
#X text 19 40 Your soundfile:;
#X obj 58 374 t b b b;
#X obj 87 476 s pd-data;
#X msg 103 445 vis 0;
#X msg 58 445 vis 1;
#X text 97 284 if you don't have mousefilter \, bang manually.;
#X text 605 348 not used for noise;
#X obj 204 396 s paint;
#X msg 205 374 bang;
#N canvas 0 0 735 532 demux 0;
#X obj 120 266 spigot;
#X obj 172 266 spigot;
#X obj 209 229 unpack 1 0;
#X obj 120 124 inlet;
#X obj 230 124 inlet;
#X obj 120 310 outlet;
#X obj 172 311 outlet;
#X obj 230 164 select 0 1;
#X msg 209 192 1 0;
#X msg 269 189 0 1;
#X obj 209 92 loadbang;
#X connect 0 0 5 0;
#X connect 1 0 6 0;
#X connect 2 0 0 1;
#X connect 2 1 1 1;
#X connect 3 0 0 0;
#X connect 3 0 1 0;
#X connect 4 0 7 0;
#X connect 7 0 8 0;
#X connect 7 1 9 0;
#X connect 8 0 2 0;
#X connect 9 0 2 0;
#X connect 10 0 8 0;
#X restore 58 345 pd demux;
#X text 156 449 with hiding!;
#X text 257 377 while visible;
#X obj 109 324 hradio 15 1 0 2 empty empty hide/show 0 -6 0 8 -262144
-1 -1 1;
#X obj 245 97 bng 15 250 50 0 empty empty draw_me! 0 -6 0 8 -258699
-1 -1;
#X connect 4 0 2 0;
#X connect 5 0 4 0;
#X connect 7 0 6 0;
#X connect 9 0 16 0;
#X connect 11 0 15 0;
#X connect 12 0 35 0;
#X connect 15 0 21 0;
#X connect 15 1 10 0;
#X connect 16 0 22 0;
#X connect 16 1 8 0;
#X connect 17 0 18 0;
#X connect 18 0 19 0;
#X connect 18 1 23 0;
#X connect 24 0 2 1;
#X connect 24 0 25 0;
#X connect 27 0 30 0;
#X connect 27 1 13 0;
#X connect 27 2 29 0;
#X connect 29 0 28 0;
#X connect 30 0 28 0;
#X connect 34 0 33 0;
#X connect 35 0 27 0;
#X connect 35 1 34 0;
#X connect 38 0 35 1;
#X connect 39 0 12 0;


More information about the Pd-dev mailing list