05.array.pd 5.5 KB
Newer Older
Miller Puckette's avatar
Miller Puckette committed
1 2 3
#N struct template5 float x float y float z float q array bazoo template5-element
;
#N struct template5-element float y;
4
#N canvas 425 44 448 473 10;
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#X obj 165 343 pointer;
#X floatatom 106 168 0 0 0 0 - - -;
#X msg 165 320 bang;
#X floatatom 147 270 0 0 0 0 - - -;
#X floatatom 12 300 0 0 0 0 - - -;
#X floatatom 165 389 0 0 0 0 - - -;
#X floatatom 298 293 0 0 0 0 - - -;
#X obj 298 246 pointer;
#X obj 282 163 pointer;
#X msg 298 221 bang;
#N canvas 454 37 332 220 data5 1;
#X scalar template5 50 75 30 9 \; 0 \; 0 \; 0 \; 0 \; 0 \; 3 \; 0 \;
0 \; 0 \; 7 \; -30 \; 0 \; 0 \; 0 \; 0 \; 0 \; 0 \; 0 \; 0 \; 0 \;
0 \; 0 \; 0 \; 0 \; 0 \; 0 \; 0 \; 0 \; 0 \; 0 \; 0 \; 0 \; 0 \; 0
\; 0 \; 0 \; 0 \; 0 \; 0 \; 0 \; 0 \; 0 \; 0 \; 0 \; 0 \; 43 \; 0 \;
0 \; 0 \; 0 \; \;;
#X restore 315 344 pd data5;
#N canvas 191 327 428 260 template5 0;
#X obj 24 125 filledpolygon 244 q 3 0 0 20 z 40 0;
#X text 22 78 this declares an array named "bazoo" whose elements are
Miller Puckette's avatar
Miller Puckette committed
25 26
described by "template5-element." Array declarations take three arguments
while "float" declarations take only two.;
27
#X text 22 170 Here we ask to plot the array \, color 700 \, line width
Miller Puckette's avatar
Miller Puckette committed
28 29
3 \, starting location (30 \, 10) relative to the scalar \, points
spaced 4 apart.;
30 31 32 33 34 35 36 37 38 39 40
#X text 23 220 You can also do (x \, y) plots and/or make the line
thickness variable---see the help window for "plot".;
#X obj 22 42 struct template5 float x float y float z float q array
bazoo template5-element;
#X obj 24 147 plot bazoo 700 3 30 40 4;
#X obj 1 1 cnv 15 425 20 empty \$0-pddp.cnv.subheading empty 3 12 0
14 -261139 -33289 0;
#X text 7 2 Data Structure Template;
#X restore 315 367 pd template5;
#N canvas 65 248 428 149 template5-element 0;
#X text 19 66 This says that array elements will have a single floating-point
Miller Puckette's avatar
Miller Puckette committed
41 42 43
number named "y". The variable name "y" is automatically assumed to
control screen height \; if you don't have at least that variable you
can't plot the array..;
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
#X obj 22 42 struct template5-element float y;
#X obj 1 1 cnv 15 425 20 empty \$0-pddp.cnv.subheading empty 3 12 0
14 -261139 -33289 0;
#X text 7 2 Data Structure Template;
#X restore 315 390 pd template5-element;
#X msg 282 140 traverse pd-data5 \, next;
#X obj 298 269 getsize template5 bazoo;
#X obj 106 190 setsize template5 bazoo;
#X obj 12 323 set template5-element y;
#X obj 165 366 get template5-element y;
#X obj 147 293 element template5 bazoo;
#X text 19 37 Scalars may contain arrays \, and moreover the elements
of an array can be of any scalar type (and can have sub-arrays recursively.)
The type of the element of an array is fixed in the template. In this
case \, "template5" contains the definition of the top-level scalar
and "template5-element" is the template of each array element (see
the template subpatch.);
#X text 292 121 click to get pointer;
#X text 298 201 get size;
#X text 94 148 set size;
#X text 144 218 select an individual;
#X text 144 233 element \, which is a;
#X text 144 248 scalar with template;
#X text 210 264 template5;
#X text 12 360 work as before \, but on;
#X text 12 375 array elements...;
70
#X text 12 345 normal "set" and "get";
71 72 73 74 75 76
#X obj 1 1 cnv 15 445 20 empty \$0-pddp.cnv.header arrays_in_data_structures
20 10 1 18 -261139 -33289 0;
#X obj 407 2 pddp/pddplink http://puredata.info/dev/pddp -text pddp
;
#X obj 1 451 cnv 15 445 20 empty \$0-pddp.cnv.footer empty 20 12 0
14 -233017 -33289 0;
77 78 79 80 81 82
#N canvas 45 271 494 284 META 0;
#X text 12 105 WEBSITE http://crca.ucsd.edu/~msp/;
#X text 12 85 AUTHOR Miller Puckette;
#X text 12 65 LIBRARY PDDP;
#X text 12 25 LICENSE SIBSD;
#X text 12 125 HELP_PATCH_AUTHORS Updated for release 0.35. Jonathan
83 84
Wilkes revised the patch to conform to the PDDP template for Pd version
0.42.;
85 86
#X text 12 45 DESCRIPTION arrays in data structures;
#X text 12 5 KEYWORDS data_structure tutorial;
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
#X restore 392 453 pd META;
#N canvas 9 256 428 190 References 0;
#X obj 1 1 cnv 15 425 20 empty \$0-pddp.cnv.subheading empty 3 12 0
14 -261139 -33289 0;
#X text 7 2 Arrays in Data Structures- Related Help Documents;
#X text 19 37 Links:;
#X restore 103 453 pd References;
#X obj 6 453 pddp/pddplink ../5.reference/pddp/help.pd -text help;
#N canvas 99 170 428 429 init 0;
#X obj 163 180 pointer;
#X obj 22 91 t b b b;
#X msg 22 66 bang;
#X text 56 66 click here to re-initialize;
#X obj 22 202 append template5 x y z q;
#X msg 163 117 \; pd-data5 clear;
#X msg 163 157 traverse pd-data5 \, bang;
#X msg 41 246 50;
#X obj 41 268 setsize template5 bazoo;
#X obj 22 42 loadbang;
#X obj 22 224 t b b p;
#X floatatom 55 341 0 0 0 0 - - -;
#X floatatom 22 341 0 0 0 0 - - -;
#X obj 22 392 set template5-element y;
#X obj 55 364 element template5 bazoo;
#X obj 22 317 unpack;
#X msg 22 295 3 5 \, 7 9 \, -30 10 \, 43 45;
#X obj 1 1 cnv 15 425 20 empty \$0-pddp.cnv.subheading empty 3 12 0
14 -261139 -33289 0;
#X text 7 2 Data Structure Initialization;
#X msg 22 180 50 75 30 9;
Miller Puckette's avatar
Miller Puckette committed
117
#X connect 0 0 4 4;
118
#X connect 1 0 19 0;
Miller Puckette's avatar
Miller Puckette committed
119 120 121
#X connect 1 1 6 0;
#X connect 1 2 5 0;
#X connect 2 0 1 0;
122
#X connect 4 0 10 0;
Miller Puckette's avatar
Miller Puckette committed
123 124 125
#X connect 6 0 0 0;
#X connect 7 0 8 0;
#X connect 9 0 2 0;
126 127 128 129 130 131 132 133 134 135 136 137 138 139
#X connect 10 0 16 0;
#X connect 10 1 7 0;
#X connect 10 2 8 1;
#X connect 10 2 14 1;
#X connect 11 0 14 0;
#X connect 12 0 13 0;
#X connect 14 0 13 1;
#X connect 15 0 12 0;
#X connect 15 1 11 0;
#X connect 16 0 15 0;
#X connect 19 0 4 0;
#X restore 315 413 pd init;
#X connect 0 0 17 0;
#X connect 1 0 15 0;
Miller Puckette's avatar
Miller Puckette committed
140
#X connect 2 0 0 0;
141 142 143 144 145
#X connect 3 0 18 0;
#X connect 4 0 16 0;
#X connect 7 0 14 0;
#X connect 8 0 15 1;
#X connect 8 0 18 1;
Miller Puckette's avatar
Miller Puckette committed
146 147
#X connect 8 0 7 0;
#X connect 9 0 7 0;
148 149 150 151 152
#X connect 13 0 8 0;
#X connect 14 0 6 0;
#X connect 17 0 5 0;
#X connect 18 0 0 0;
#X connect 18 0 16 1;