[PD] Re: trouble with data structures

Julian Peterson julianpeterson at mac.com
Mon Jun 5 15:26:40 CEST 2006


Oops!

Here's the promised patch...

JP


#N struct playhead float x;
#N struct instr1 float x float y float tablenum array notes instr1-note
;
#N struct instr1-note float y float w;
#N canvas 539 478 675 263 10;
#X obj 33 499 csoundapi~ 2;
#X obj 34 536 dac~ 1 2;
#N canvas 1 25 1246 453 bohgud-score 0;
#X scalar playhead 388 \;;
#X scalar instr1 1000 159 100 \; -11.5 68 \; -28 46 \; -27 32 \; -19
20 \; -15 10 \; -7 6 \; -1 4 \; 4 0 \; -1 58 \; -15 30 \; -32 21 \;
-31 22 \; -16 35 \; -15 51 \; -20 61 \; -14 49 \; -4 29 \; -9 29 \;
-11 23 \; -12 12 \; -2 11 \; 0 8 \; -4 58 \; -1 54 \; -2 59 \; -4 56
\; -9 56 \; -11 43 \; -19 35 \; -25 42 \; -30 20 \; 2 61 \; \;;
#X coords 0 0 1 0.5 0 0 0;
#X restore 553 -31 pd bohgud-score;
#N canvas 267 361 450 300 instr1 0;
#N canvas 299 78 450 300 instr1-note-template 0;
#X obj 51 32 struct instr1-note float y float w;
#X obj 51 78 drawnumber w 0 w 525 w=;
#X obj 51 56 drawnumber y 1 -10 222 y=;
#X obj 51 106 filledpolygon 0 0 1 -2 0 0 -2 2 0 0 2;
#X restore 28 19 pd instr1-note-template;
#N canvas 0 0 450 300 instr1-control-template 0;
#X restore 28 39 pd instr1-control-template;
#N canvas 0 0 450 300 instr1-amp-template 0;
#X restore 28 60 pd instr1-amp-template;
#N canvas 142 25 909 642 instr1-template 0;
#X obj 107 28 struct instr1 float x float y float tablenum array notes
instr1-note;
#X obj 107 75 drawnumber tablenum 0 100 0 table=;
#X obj 433 183 pointer;
#X msg 433 160 traverse pd-bohgud-score \, bang;
#X msg 305 184 1 1 1;
#X obj 305 211 append instr1 x y tablenum;
#X obj 135 333 setsize instr1 notes;
#X obj 269 284 pointer;
#X msg 269 249 traverse pd-bohgud-score \, next;
#X obj 108 101 plot notes 255 1 0 0 50;
#X msg 125 303 32;
#X obj 621 499 get instr1-note y;
#X obj 597 557 abs;
#X obj 749 498 get instr1-note w;
#X obj 729 557 abs;
#X obj 599 583 s i1-note-y;
#X obj 620 466 t p p;
#X obj 689 582 s i1-note-w;
#X obj 108 141 drawpolygon 129 0 0 0 0 -100;
#X obj 107 165 drawnumber x 0 -110 129 x=;
#X obj 612 526 * 0.25;
#X obj 729 526 * 0.5;
#X obj 624 433 element instr1 notes;
#N canvas 0 0 450 300 metroblast 0;
#X obj 97 39 inlet;
#X obj 96 79 t b b;
#X msg 124 101 0;
#X obj 90 162 f;
#X obj 285 49 inlet;
#X msg 47 103 1;
#X msg 81 103 0;
#X obj 91 245 outlet;
#X obj 123 193 select 0;
#X obj 123 159 + 1;
#X obj 92 135 metro 100;
#X obj 217 251 outlet;
#X connect 0 0 1 0;
#X connect 1 0 5 0;
#X connect 1 1 2 0;
#X connect 2 0 3 1;
#X connect 3 0 7 0;
#X connect 3 0 9 0;
#X connect 4 0 8 1;
#X connect 5 0 10 0;
#X connect 6 0 10 0;
#X connect 8 0 6 0;
#X connect 8 0 11 0;
#X connect 8 1 3 1;
#X connect 9 0 8 0;
#X connect 10 0 3 0;
#X restore 624 397 pd metroblast;
#X obj 623 369 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
-1;
#X obj 710 365 r i1-size;
#X obj 596 324 r i1metroblast;
#X obj 783 367 r i1-getsize;
#X obj 779 396 pointer;
#X obj 24 446 r i1-getsize;
#X obj 24 551 s i1-size;
#X obj 24 478 pointer;
#X obj 23 516 getsize instr1 notes;
#X text 126 445 <-- this receives a message to get the table size...
;
#X msg 92 479 traverse pd-bohgud-score \, next;
#X text 312 481 (this message);
#X text 146 567 but it gets an error I do not understand?;
#X connect 2 0 5 3;
#X connect 3 0 2 0;
#X connect 4 0 5 0;
#X connect 7 0 6 1;
#X connect 8 0 7 0;
#X connect 10 0 6 0;
#X connect 11 0 20 0;
#X connect 12 0 15 0;
#X connect 13 0 21 0;
#X connect 14 0 17 0;
#X connect 16 0 11 0;
#X connect 16 1 13 0;
#X connect 20 0 12 0;
#X connect 21 0 14 0;
#X connect 22 0 16 0;
#X connect 23 0 22 0;
#X connect 24 0 23 0;
#X connect 25 0 23 1;
#X connect 26 0 24 0;
#X connect 27 0 28 0;
#X connect 28 0 22 1;
#X connect 29 0 31 0;
#X connect 31 0 32 0;
#X connect 32 0 30 0;
#X connect 34 0 31 0;
#X restore 28 85 pd instr1-template;
#N canvas 102 25 639 712 instr1-sequencer 0;
#X obj 376 197 pointer;
#X msg 401 157 traverse pd-bohgud-score \, next;
#X obj 376 99 loadbang;
#X obj 110 13 get instr1 x tablenum;
#X obj 435 197 s i1-getsize;
#X msg 337 163 next;
#X obj 12 122 >=;
#X obj 12 147 select 1;
#X obj 346 443 f;
#X obj 133 495 pack f f f;
#X msg 133 541 \; toCs5 event i 1 0 0.1 \$2 \$3 \$1 7 3 3000 0.15 0
;
#X obj 49 410 r i1-note-y;
#X obj 167 410 r i1-note-w;
#X obj 13 54 r PLAYHEAD;
#X obj 446 98 r rewindpointers;
#X obj 12 179 spigot;
#X msg 66 179 1;
#X obj 376 125 b;
#X msg 99 179 0;
#X obj 33 243 s i1metroblast;
#X obj 169 441 t f b;
#X connect 0 0 3 0;
#X connect 1 0 0 0;
#X connect 1 0 4 0;
#X connect 2 0 17 0;
#X connect 3 0 6 1;
#X connect 3 1 8 1;
#X connect 5 0 0 0;
#X connect 5 0 4 0;
#X connect 6 0 7 0;
#X connect 7 0 15 0;
#X connect 8 0 9 2;
#X connect 9 0 10 0;
#X connect 11 0 9 0;
#X connect 12 0 20 0;
#X connect 13 0 6 0;
#X connect 14 0 17 0;
#X connect 15 0 19 0;
#X connect 16 0 15 1;
#X connect 17 0 1 0;
#X connect 17 0 16 0;
#X connect 18 0 15 1;
#X connect 20 0 9 1;
#X connect 20 1 8 0;
#X restore 28 131 pd instr1-sequencer;
#N canvas 0 0 450 300 instr1-event-editor 0;
#X restore 29 157 pd instr1-event-editor;
#X text 172 85 <-- look here;
#X restore 554 2 pd instr1;
#X obj 33 471 r toCs5;
#X msg 149 427 event f 100 0 512 7 0 10 1 400 0.6 102 0;
#X obj 38 17 loadbang;
#X msg 149 453 event i 1 0 0.2 25 100 7 6 2 6000 0.5 0;
#N canvas 1 477 450 300 playback 0;
#X obj 75 46 inlet;
#X obj 75 79 route float rewind;
#N canvas 477 188 452 442 playhead-template 0;
#X obj 45 48 struct playhead float x;
#X obj 46 222 append playhead x;
#X msg 46 188 0;
#X obj 155 188 pointer;
#X msg 153 156 traverse pd-bohgud-score \, bang;
#X obj 50 338 set playhead x;
#X obj 144 254 loadbang;
#X obj 145 312 pointer;
#X obj 51 293 inlet;
#X obj 47 86 drawpolygon 500 3 x -300 x 300;
#X msg 143 280 traverse pd-bohgud-score \, next;
#X connect 2 0 1 0;
#X connect 3 0 1 1;
#X connect 4 0 3 0;
#X connect 6 0 10 0;
#X connect 7 0 5 1;
#X connect 8 0 5 0;
#X connect 10 0 7 0;
#X restore 264 102 pd playhead-template;
#X floatatom 264 75 5 0 0 0 - - -;
#X obj 75 145 f;
#X msg 149 143 0;
#X obj 149 112 t b b;
#X msg 179 143 0;
#X obj 75 186 s PLAYHEAD;
#X msg 214 142 \; rewindpointers bang;
#X obj 75 113 metro 4;
#X obj 114 151 + 1;
#X obj 265 48 / 3;
#X floatatom 152 239 5 0 0 0 - - -;
#X connect 0 0 1 0;
#X connect 1 0 10 0;
#X connect 1 1 6 0;
#X connect 3 0 2 0;
#X connect 4 0 8 0;
#X connect 4 0 11 0;
#X connect 4 0 12 0;
#X connect 4 0 13 0;
#X connect 5 0 4 1;
#X connect 6 0 5 0;
#X connect 6 1 7 0;
#X connect 6 1 9 0;
#X connect 7 0 10 0;
#X connect 10 0 4 0;
#X connect 11 0 4 1;
#X connect 12 0 3 0;
#X restore 50 195 pd playback;
#X obj 41 154 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
;
#X msg 65 154 rewind;
#X msg 38 49 \; toCs5 open bohgud.csd;
#X msg 514 81 \; pd-bohgud-score sort;
#X text 372 2 The trouble is in here-->;
#X text 215 156 This patch uses csoundapi~ \, but it is not necessary
to reproduce the error I am getting.;
#X connect 0 0 1 0;
#X connect 0 1 1 1;
#X connect 4 0 0 0;
#X connect 5 0 0 0;
#X connect 6 0 11 0;
#X connect 7 0 0 0;
#X connect 9 0 8 0;
#X connect 10 0 8 0;


On Mon, 2006-06-05 at 09:23 -0400, Julian Peterson wrote:
> I'm writing my first piece that will take advantage of data structures
> in PD, and I've stumbled upon an error that I do not understand.
> 
> I have two structures drawn in the same subpatch.  One is a sequence of
> notes, the other is a playhead.  The sequencer was working fine until I
> added the playhead.  Now whenever I try to get data from the sequencer
> (getsize, get) I receive the following error:
> 
> error: getsize pd-instr1: got wrong template (pd-playhead)
> 
> My patch is attached below.  Is it not possible (or not advisable) for
> two structures to draw to the same subpatch?
> 
> (The csoundapi~ object is used to generate the sound for this patch, but
> is unnecessary for duplicating the issue...)
> 
> Thanks in advance for any advice...
> Julian Peterson





More information about the Pd-list mailing list