[PD] note data record / playback

Frank Barknecht fbar at footils.org
Tue Sep 12 15:23:31 CEST 2006


Hallo,
Kyle Klipowicz hat gesagt: // Kyle Klipowicz wrote:

> You know, after a few years of Pd frustration, I'm starting to agree
> with you!  Time to hunker down on data structures.

I attached a little sequencer example (I think, I posted it in the
past as well) which just creates some random notes any plays them back
according to x-position. y-position is taken as midi note value. 

[pd note] contains the structure definition for this, sequence-data.pd
is a general purpose struct-player. 

In this form it isn't much more than a [qlist], but it's easy to
extend the [struct note float x float y] data structure with more
fields, for example "float length", "float instrument", "float cc"
etc. Then you don't need to juggle with lots of seperate arrays and
you can still edit single events. 

Live recording is possible as well of course: I'd just use [timer] for
this, just reset the timer at the start of recording, then on every
incoming event bang the timer to output the current time and use that
as x-position when [append]ing a new struct-instance, maybe scaled by
a speed-factor.

Ciao
-- 
 Frank Barknecht                 _ ______footils.org_ __goto10.org__
-------------- next part --------------
#N struct dial float x;
#N struct note float x float y;
#N canvas 451 63 757 543 10;
#N canvas 0 0 641 403 note 0;
#X obj 25 51 struct note float x float y;
#X obj 23 89 drawnumber y;
#X obj 393 92 inlet;
#X msg 450 187 traverse pd-data \, bang;
#X obj 393 137 t b b b b;
#X obj 450 216 pointer;
#X obj 354 306 append note x y;
#X obj 274 171 s pd-data;
#X msg 278 149 sort;
#X msg 227 150 clear;
#X obj 266 238 random 400;
#X msg 464 108 bang;
#X obj 344 238 random 60;
#X obj 369 276 + 40;
#X connect 2 0 4 0;
#X connect 3 0 5 0;
#X connect 4 0 8 0;
#X connect 4 1 10 0;
#X connect 4 2 12 0;
#X connect 4 3 3 0;
#X connect 5 0 6 2;
#X connect 8 0 7 0;
#X connect 9 0 7 0;
#X connect 10 0 6 0;
#X connect 11 0 4 0;
#X connect 12 0 13 0;
#X connect 13 0 6 1;
#X restore 611 360 pd note;
#N canvas 50 196 779 437 data 1;
#X scalar dial 0 \;;
#X scalar note 37 68 \;;
#X scalar note 83 83 \;;
#X scalar note 89 56 \;;
#X scalar note 194 70 \;;
#X scalar note 215 95 \;;
#X scalar note 255 59 \;;
#X scalar note 320 61 \;;
#X scalar note 337 83 \;;
#X scalar note 376 65 \;;
#X scalar note 386 45 \;;
#X restore 384 51 pd data;
#X msg 610 341 make notes;
#X floatatom 81 337 5 0 0 0 x - -;
#X floatatom 160 338 5 0 0 1 y - -;
#X obj 202 266 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
-1;
#X obj 81 359 print x;
#X obj 160 357 print y;
#X msg 81 66 play;
#X floatatom 588 404 5 0 0 1 speed - -;
#N canvas 389 419 691 497 dial 0;
#X obj 124 82 struct dial float x;
#X obj 122 168 drawpolygon 0 1 0 0 0 200;
#X msg 407 123 traverse pd-data \, bang;
#X obj 407 152 pointer;
#X obj 311 242 append dial x;
#X obj 341 78 inlet;
#X obj 310 266 outlet;
#X obj 335 101 t b b;
#X msg 333 131 0;
#X msg 387 80 bang;
#X connect 2 0 3 0;
#X connect 3 0 4 1;
#X connect 4 0 6 0;
#X connect 5 0 7 0;
#X connect 7 0 8 0;
#X connect 7 1 2 0;
#X connect 8 0 4 0;
#X connect 9 0 7 0;
#X restore 430 268 pd dial;
#X msg 430 244 bang;
#X obj 365 299 set dial x;
#X floatatom 378 220 5 0 0 0 - - -;
#N canvas 0 0 610 505 move-dial 0;
#X obj 173 279 f 0;
#X obj 200 280 + 1;
#X msg 270 111 0;
#X obj 173 165 metro 10;
#X msg 173 101 1;
#X obj 275 88 del 200;
#X obj 173 64 inlet;
#X obj 224 62 inlet;
#X obj 275 62 inlet;
#X obj 173 311 outlet;
#X connect 0 0 1 0;
#X connect 0 0 9 0;
#X connect 1 0 0 1;
#X connect 2 0 3 0;
#X connect 2 0 0 0;
#X connect 3 0 0 0;
#X connect 4 0 3 0;
#X connect 5 0 2 0;
#X connect 6 0 4 0;
#X connect 7 0 3 1;
#X connect 8 0 5 0;
#X restore 365 190 pd move-dial;
#X obj 81 95 t b b b;
#X obj 632 272 s pd-data;
#X msg 632 247 clear;
#X obj 588 186 loadbang;
#X obj 588 211 t b b b;
#X obj 610 315 until;
#X msg 610 295 10;
#X msg 588 167 bang;
#X obj 202 293 s \$0-EOF;
#X obj 444 161 r \$0-EOF;
#X text 588 142 INIT;
#X text 6 97 Traversal;
#X obj 588 425 s \$0-speed-mult;
#X obj 141 180 r \$0-speed-mult;
#X obj 404 136 r \$0-speed-mult;
#X text 359 108 Make and move dial (naive version);
#X obj 81 316 get note x y;
#X obj 81 238 sequence-data note;
#X msg 81 158 symbol pd-data;
#X msg 588 383 10;
#X obj 202 214 bng 15 250 50 0 empty empty stop 0 -6 0 8 -262144 -1
-1;
#X obj 273 393 osc~;
#X obj 273 367 mtof;
#X obj 312 392 vline~;
#X obj 272 427 *~;
#X obj 273 333 t f b;
#X obj 273 447 *~;
#X obj 272 470 *~ 0.4;
#X obj 312 445 hsl 128 15 0 1 0 0 empty empty empty -2 -6 0 8 -262144
-1 -1 8700 1;
#X obj 273 496 dac~;
#X msg 312 366 0 5 \, 1 20 5 \, 0 300 25;
#X connect 2 0 0 0;
#X connect 3 0 6 0;
#X connect 4 0 7 0;
#X connect 5 0 23 0;
#X connect 8 0 15 0;
#X connect 9 0 27 0;
#X connect 10 0 12 1;
#X connect 11 0 10 0;
#X connect 14 0 13 0;
#X connect 14 0 12 0;
#X connect 15 0 33 0;
#X connect 15 2 14 0;
#X connect 17 0 16 0;
#X connect 18 0 19 0;
#X connect 19 0 11 0;
#X connect 19 0 34 0;
#X connect 19 1 21 0;
#X connect 19 2 17 0;
#X connect 20 0 2 0;
#X connect 21 0 20 0;
#X connect 22 0 19 0;
#X connect 24 0 14 2;
#X connect 28 0 32 1;
#X connect 29 0 14 1;
#X connect 31 0 3 0;
#X connect 31 1 4 0;
#X connect 31 1 40 0;
#X connect 32 0 31 0;
#X connect 32 1 5 0;
#X connect 33 0 32 0;
#X connect 34 0 9 0;
#X connect 35 0 32 2;
#X connect 35 0 5 0;
#X connect 36 0 39 0;
#X connect 37 0 36 0;
#X connect 38 0 39 1;
#X connect 39 0 41 0;
#X connect 39 0 41 1;
#X connect 40 0 37 0;
#X connect 40 1 45 0;
#X connect 41 0 42 0;
#X connect 42 0 44 0;
#X connect 42 0 44 1;
#X connect 43 0 42 1;
#X connect 45 0 38 0;
-------------- next part --------------
#N canvas 416 118 758 660 10;
#X obj 123 77 inlet;
#X obj 123 619 outlet;
#X msg 147 262 next;
#X text 190 443 speed;
#X obj 153 586 s \$0-next;
#X obj 147 239 r \$0-next;
#X obj 188 328 outlet;
#X obj 153 443 * 10;
#X obj 174 503 -;
#X obj 153 465 t a a;
#X obj 167 131 s \$0-start;
#X obj 327 436 r \$0-start;
#X msg 327 458 0;
#X obj 176 417 r \$0-speed;
#X obj 457 104 s \$0-speed;
#X obj 457 77 inlet;
#X text 260 131 reset delta time below;
#X text 257 330 Bang at EOF;
#X text 233 587 get next note;
#X text 262 514 delta = x[current] - x[previous];
#X text 263 494 calculate delta time between notes:;
#X text 183 623 Pointer out;
#X text 408 436 reset delta;
#X text 260 389 get x position;
#X obj 123 296 pointer \$1;
#X obj 153 389 get \$1 x;
#X msg 123 207 traverse \$1 \, next;
#X text 123 27 Argument: data structure name;
#X text 66 56 Inlet: name of subpatch containing data structures;
#X text 452 58 Inlet: speed mult;
#X obj 123 108 t a a b;
#X msg 145 158 \; \$1 sort;
#X obj 123 535 pipe p 0;
#X obj 123 561 t a b;
#X obj 123 329 t p p;
#X obj 45 475 r \$0-stop;
#X obj 603 78 inlet;
#X obj 603 105 s \$0-stop;
#X text 598 59 Inlet: STOP;
#X msg 45 496 clear;
#X connect 0 0 30 0;
#X connect 2 0 24 0;
#X connect 5 0 2 0;
#X connect 7 0 9 0;
#X connect 8 0 32 1;
#X connect 9 0 8 1;
#X connect 9 1 8 0;
#X connect 11 0 12 0;
#X connect 12 0 8 1;
#X connect 13 0 7 1;
#X connect 15 0 14 0;
#X connect 24 0 34 0;
#X connect 24 1 2 0;
#X connect 24 2 6 0;
#X connect 25 0 7 0;
#X connect 26 0 24 0;
#X connect 30 0 26 0;
#X connect 30 1 31 0;
#X connect 30 2 10 0;
#X connect 32 0 33 0;
#X connect 33 0 1 0;
#X connect 33 1 4 0;
#X connect 34 0 32 0;
#X connect 34 1 25 0;
#X connect 35 0 39 0;
#X connect 36 0 37 0;
#X connect 39 0 32 0;


More information about the Pd-list mailing list