aboutsummaryrefslogtreecommitdiff
path: root/tracker
diff options
context:
space:
mode:
Diffstat (limited to 'tracker')
-rw-r--r--tracker/demo1.pd346
-rw-r--r--tracker/tracker.c222
-rw-r--r--tracker/tracker.h2
-rw-r--r--tracker/tracker.tk125
4 files changed, 250 insertions, 445 deletions
diff --git a/tracker/demo1.pd b/tracker/demo1.pd
deleted file mode 100644
index fc763fb..0000000
--- a/tracker/demo1.pd
+++ /dev/null
@@ -1,346 +0,0 @@
-#N canvas 145 93 697 679 10;
-#X obj 34 132 tracker 2 16 0 4 4 6 0 8 2 6 4 6 10 16 0 16 0 2 14 16 4
-8 5 12 3 7 4 12 1 3 7 11 8 16;
-#X obj 34 108 r sequencer;
-#N canvas 49 507 560 341 metronome 0;
-#X obj 252 172 s \$0-playstop;
-#X msg 261 135 color \$1;
-#X obj 115 105 tgl 25 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
-1;
-#X obj 261 112 * -1;
-#X obj 115 105 cnv 5 25 25 empty \$0-playstop empty 20 12 0 14 -1 -262144
-0;
-#X obj 131 115 cnv 5 5 5 empty empty empty 20 12 0 14 -1 -66577 0;
-#X obj 125 110 cnv 5 5 15 empty empty empty 20 12 0 14 -1 -66577 0
-;
-#X obj 119 105 cnv 5 5 25 empty empty empty 20 12 0 14 -1 -66577 0
-;
-#X obj 260 89 == 0;
-#X obj 257 40 t f f;
-#X obj 312 73 metro;
-#X obj 145 105 nbx 3 25 -1e+37 1e+37 0 1 empty empty empty 0 -8 0 20
--1 -262144 -1 353 256;
-#X obj 145 147 t b f;
-#X obj 145 212 /;
-#X msg 145 184 60000;
-#X obj 341 122 f;
-#X obj 369 121 + 1;
-#X msg 363 86 0;
-#X obj 364 60 sel 0;
-#X obj 285 246 s metro;
-#X obj 344 200 / 16;
-#X obj 345 222 i;
-#X obj 380 200 i;
-#X obj 379 178 / 64;
-#X obj 347 287 s metro/16;
-#X obj 391 262 s metro/64;
-#X obj 347 247 change;
-#X obj 382 225 change;
-#X obj 345 148 t f f f f f f f f;
-#X connect 1 0 0 0;
-#X connect 2 0 9 0;
-#X connect 3 0 1 0;
-#X connect 8 0 3 0;
-#X connect 9 0 8 0;
-#X connect 9 1 10 0;
-#X connect 9 1 18 0;
-#X connect 10 0 15 0;
-#X connect 11 0 12 0;
-#X connect 12 0 14 0;
-#X connect 12 1 13 1;
-#X connect 13 0 10 1;
-#X connect 14 0 13 0;
-#X connect 15 0 16 0;
-#X connect 15 0 28 0;
-#X connect 16 0 15 1;
-#X connect 17 0 15 1;
-#X connect 18 0 17 0;
-#X connect 20 0 21 0;
-#X connect 21 0 26 0;
-#X connect 22 0 27 0;
-#X connect 23 0 22 0;
-#X connect 26 0 24 0;
-#X connect 27 0 25 0;
-#X connect 28 0 19 0;
-#X connect 28 2 20 0;
-#X connect 28 4 23 0;
-#X coords 0 -1 1 1 107 51 1 110 84;
-#X restore 34 35 pd metronome;
-#X floatatom 20 418 5 0 0 0 - - -;
-#X msg 20 440 \; sequencer getrow \$1;
-#X obj 34 351 s sequencer.out;
-#X obj 102 389 r sequencer.out;
-#X obj 102 414 unpack f f;
-#X obj 151 450 -;
-#X obj 138 528 %;
-#X obj 89 552 +;
-#X obj 138 477 r metro;
-#X obj 136 132 tracker 10 16 77 45 167 700 699 80 0 0 0 0 560 30 0 94
-0 200 0 0 0 0 36 20 0 20 340 300 567 300 100 20 165 888 0 777 0 100
-120 0 0 0 56 345 270 888 330 50 999 76 800 999 46 0 0 999 0 20 0 0
-30 0 236 0 564 0 500 0 0 0 0 5 647 0 0 0 0 400 0 0 60 0 467 546 0 0
-0 0 300 170 0 13 564 0 0 45 0 0 0 0 0 24 547 0 0 0 0 0 0 0 0 34 534
-0 37 57 0 0 7 0 0 28 289 0 165 0 0 56 51 0 0 9 5 57 0 245 0 0 0 119
-0 27 36 0 0 0 0 0 0 0 185 54 534 0 0 0 0 0 0 0 0 90;
-#X obj 136 108 r pattern;
-#X obj 136 351 s pattern.out;
-#X msg 89 578 \; pattern getrow \$1;
-#X obj 138 502 % 16;
-#N canvas 0 0 450 300 (subpatch) 0;
-#X array array1 11 float 4;
-#X coords 0 999 10 0 200 140 1;
-#X restore 416 32 graph;
-#X obj 192 425 r pattern.out;
-#X obj 192 473 drip;
-#X obj 192 449 t a b;
-#X msg 228 471 0;
-#X obj 231 498 f;
-#X obj 254 498 + 1;
-#X obj 192 498 t f b;
-#X obj 192 520 pack f f;
-#X obj 192 543 tabwrite array1;
-#X obj 423 453 tabosc4~ array1;
-#X obj 311 541 delwrite~ d 1000;
-#X obj 313 367 hradio 15 1 0 8 empty empty empty 0 -8 0 10 -262144
--1 -1 2;
-#X obj 313 387 * 12;
-#X obj 350 490 *~ 0.8;
-#X obj 402 640 dac~;
-#X obj 313 408 lop~ 0.1;
-#X obj 406 583 hip~ 60;
-#X obj 20 393 r metro/64;
-#X obj 414 612 moog~;
-#X obj 422 560 mtof~;
-#X obj 474 578 hsl 128 15 0 127 0 0 empty empty empty -2 -8 0 10 -262144
--1 -1 8800 1;
-#X obj 420 509 delread~ d 600;
-#X obj 369 513 *~ 0.7;
-#X obj 311 558 delwrite~ c 1000;
-#X obj 313 513 lop~ 1200;
-#X obj 420 492 delread~ c 500;
-#X obj 471 559 line;
-#X obj 474 538 hsl 128 15 0 127 0 0 empty empty empty -2 -8 0 10 -262144
--1 -1 8800 1;
-#X msg 502 558 \$1 8000;
-#X obj 371 430 sig~;
-#X obj 501 372 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 1
-1;
-#X obj 314 429 mtof~;
-#X obj 365 389 r metro;
-#X obj 368 409 % 16;
-#X obj 398 428 sel 0 12;
-#X obj 414 388 r metro;
-#X obj 458 411 sig~;
-#X obj 518 372 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 1
-1;
-#X obj 361 594 *~ 0.4;
-#N canvas 0 0 450 300 (subpatch) 0;
-#X array shape 998 float 3;
-#A 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 0 0 0 0 0 0 0 0.142857 0.14 0.137143 0.134285 0.131428 0.114286
-0.114286 0.114286 0.114286 0.114286 0.0999998 0.0999998 0.0999998 0.0999998
-0.0999998 0.0857141 0.082857 0.0799999 0.0771427 0.0742856 0.0571427
-0.0542856 0.0514285 0.0485713 0.0457142 0.042857 0.042857 0.042857
-0.042857 0.042857 0.0285713 0.0285713 0.0285713 0.0285713 0.0285713
-0.0142857 0.0142857 0.0142857 0.0142857 0.0142857 -3.91155e-08 -3.91155e-08
--3.91155e-08 -3.91155e-08 -3.91155e-08 -3.91155e-08 -3.91155e-08 -3.91155e-08
--3.91155e-08 -3.91155e-08 -0.0142857 -0.0142857 -0.0142857 -0.0142857
--0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857
--0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857
--0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857
--0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857
--0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857
--0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857
--0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857
--0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857
--0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857
--0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857
--0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857
--0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857
--0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857
--0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857
--0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857
--0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857
--0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857
--0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857
--0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857
--0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857
--0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857
--0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857
--0.0142857 -0.0142857 -3.91155e-08 -3.91155e-08 -3.91155e-08 -3.91155e-08
--3.91155e-08 -3.91155e-08 -3.91155e-08 -3.91155e-08 -3.91155e-08 -3.91155e-08
--3.91155e-08 -3.91155e-08 -3.91155e-08 -3.91155e-08 -3.91155e-08 -3.91155e-08
--3.91155e-08 -3.91155e-08 -3.91155e-08 -3.91155e-08 -3.91155e-08 -3.91155e-08
--3.91155e-08 -3.91155e-08 -3.91155e-08 -3.91155e-08 -3.91155e-08 -3.91155e-08
--3.91155e-08 -3.91155e-08 -3.91155e-08 -3.91155e-08 -3.91155e-08 -3.91155e-08
--3.91155e-08 -3.85568e-08 0.0028571 0.00571424 0.00857138 0.0114285
-0.0142857 0.0142857 0.0142857 0.0142857 0.0142857 0.0142857 0.0142857
-0.0142857 0.0142857 0.0142857 0.0142857 0.0142857 0.0142857 0.0142857
-0.0142857 0.0142857 0.0142857 0.0142857 0.0142857 0.0142857 0.0142857
-0.0142857 0.0142857 0.0142857 0.0142857 0.0142857 0.0157142 0.0171428
-0.0185714 0.0199999 0.0214285 0.0228571 0.0242856 0.0257142 0.0271428
-0.0285713 0.0285713 0.0285713 0.0285713 0.0285713 0.0285713 0.0285713
-0.0285713 0.0285713 0.0285713 0.0285713 0.0285713 0.0285713 0.0285713
-0.0285713 0.0285713 0.0285713 0.0285713 0.0285713 0.0285713 0.042857
-0.042857 0.042857 0.042857 0.042857 0.042857 0.042857 0.042857 0.042857
-0.042857 0.042857 0.042857 0.042857 0.042857 0.042857 0.042857 0.042857
-0.042857 0.042857 0.042857 0.0428571 0.0457142 0.0485713 0.0514285
-0.0542856 0.0571427 0.0571427 0.0571427 0.0571427 0.0571427 0.0571427
-0.0571427 0.0571427 0.0571427 0.0571427 0.0571427 0.0571427 0.0571427
-0.0571427 0.0571427 0.0571427 0.0571427 0.0571427 0.0571427 0.0571427
-0.0571427 0.0571427 0.0571427 0.0571427 0.0571427 0.0571427 0.0571427
-0.0571427 0.0571427 0.0571427 0.0571427 0.0571427 0.0571427 0.0571427
-0.0571427 0.0571427 0.0599999 0.062857 0.0657142 0.0685713 0.0714284
-0.0714284 0.0714284 0.0714284 0.0714284 0.0714284 0.0714284 0.0714284
-0.0714284 0.0714284 0.0714284 0.0714284 0.0714284 0.0714284 0.0714284
-0.0714284 0.0714284 0.0714284 0.0714284 0.0714284 0.0857141 0.0857141
-0.0857141 0.0857141 0.0857141 0.0857141 0.0857141 0.0857141 0.0857141
-0.0857141 0.0999998 0.0999998 0.0999998 0.0999998 0.0999998 0.0999998
-0.0999998 0.0999998 0.0999998 0.0999998 0.114285 0.117143 0.12 0.122857
-0.125714 0.142857 0.142857 0.142857 0.142857 0.157143 0.16 0.162857
-0.165714 0.168571 0.171428 0.174285 0.177143 0.18 0.182857 0.2 0.2
-0.2 0.2 0.2 0.214285 0.217143 0.22 0.222857 0.225714 -2.47732e-08 -0.00285716
--0.0057143 -0.00857144 -0.0114286 -0.0714285 -0.0742856 -0.0771428
--0.0799999 -0.082857 -0.157143 -0.16 -0.162857 -0.165714 -0.168571
--0.2 -0.2 -0.2 -0.2 -0.2 -0.2 -0.2 -0.2 -0.2 -0.2 -0.2 -0.2 -0.2 -0.2
--0.2 -0.2 -0.197143 -0.194285 -0.191428 -0.188571 -0.185714 -0.185714
--0.185714 -0.185714 -0.185714 -0.185714 -0.185714 -0.185714 -0.185714
--0.185714 -0.171428 -0.171428 -0.171428 -0.171428 -0.171428 -0.171428
--0.168571 -0.165714 -0.162857 -0.16 -0.157143 -0.157143 -0.157143 -0.157143
--0.157143 -0.142857 -0.142857 -0.142857 -0.142857 -0.142857 -0.128571
--0.127143 -0.125714 -0.124286 -0.122857 0.0571428 0.0599999 0.062857
-0.0657142 0.0685713 0.157143 0.16 0.162857 0.165714 0.168571 0.2 0.2
-0.2 0.2 0.2 0.2 0.2 0.2 0.2 0.2 0.2 0.2 0.2 0.2 0.2 0.214285 0.214285
-0.214285 0.214285 0.214285 0.214285 0.214285 0.214285 0.214285 0.214285
-0.0285714 0.0285714 0.0285714 0.0285714 0.0285714 -0.82857 -0.831427
--0.834284 -0.837141 -0.839998 -0.842856 -0.842856 -0.842856 -0.842856
--0.842856 -0.842856 0.0428571 0.0428571 0.0428571 0.0428571 0.0428571
-0.0428571 0.0428571 0.0428571 0.0428571 0.0428571 0.0428571 0.0428571
-0.0428571 0.0428571 0.0428571 0.0428571 0.0428571 0.0428571 0.0428571
-0.0428571 0.0285714 0.0285714 0.0285714 0.0285714 0.0285714 0.122041
-0.121633 0.121224 0.120816 0.120408 0.12 0.119592 0.119184 0.118775
-0.118367 0.117959 0.117551 0.117143 0.116735 0.116326 0.115918 0.11551
-0.115102 0.114694 0.114286 0.113571 0.112857 0.112143 0.111428 0.110714
-0.11 0.109285 0.108571 0.107857 0.107143 0.106428 0.105714 0.105 0.104285
-0.103571 0.102857 0.102143 0.101428 0.100714 0.0999998 0.0992855 0.0985712
-0.0978569 0.0971426 0.0964283 0.095714 0.0949998 0.0942855 0.0935712
-0.0928569 0.0921426 0.0914283 0.090714 0.0899997 0.0892855 0.0885712
-0.0878569 0.0871426 0.0864283 0.085714 0.085306 0.0848978 0.0844896
-0.0840815 0.0836733 0.0832651 0.082857 0.0824488 0.0820406 0.0816325
-0.0812243 0.0808161 0.080408 0.0799998 0.0795916 0.0791835 0.0787753
-0.0783671 0.077959 0.0775508 0.0771426 0.0767345 0.0763263 0.0759182
-0.07551 0.0751018 0.0746937 0.0742855 0.0738773 0.0734692 0.073061
-0.0726528 0.0722447 0.0718365 0.0714283 0.0710202 0.070612 0.0702038
-0.0697957 0.0693875 0.0689793 0.0685712 0.068163 0.0677548 0.0673467
-0.0669385 0.0665304 0.0661222 0.065714 0.0653059 0.0648977 0.0644895
-0.0640814 0.0636732 0.063265 0.0628569 0.0624487 0.0620405 0.0616324
-0.0612242 0.0608161 0.0604079 0.0599997 0.0595916 0.0591834 0.0587753
-0.0583671 0.0579589 0.0575508 0.0571426 0.0567346 0.0563264 0.0559182
-0.0555101 0.0551019 0.0546938 0.0542856 0.0538774 0.0534693 0.0530611
-0.052653 0.0522448 0.0518366 0.0514285 0.0510203 0.0506121 0.050204
-0.0497958 0.0493877 0.0489795 0.0485713 0.0481632 0.047755 0.0473469
-0.0469387 0.0465305 0.0461224 0.0457142 0.045306 0.0448979 0.0444897
-0.0440816 0.0436734 0.0432652 0.0428571 0.0424489 0.0420408 0.0416326
-0.0412244 0.0408163 0.0404081 0.04 0.0395918 0.0391836 0.0387755 0.0383673
-0.0379591 0.037551 0.0371428 0.0367347 0.0363265 0.0359183 0.0355102
-0.035102 0.0346939 0.0342857 0.0338775 0.0334694 0.0330612 0.032653
-0.0322449 0.0318367 0.0314286 0.0310204 0.0306122 0.0302041 0.0297959
-0.0293877 0.0289796 0.0285714 0.0285713 0.0285713 0.0285713 0.0285713
-0.0285713 0.0285713 0.0285713 0.0285713 0.0285713 0.0285713 0.0285713
-0.0285713 0.0285713 0.0285713 0.0285713 0.0285713 0.0285713 0.0285713
-0.0285713 0.0285713 0.0285713 0.0285713 0.0285713 0.0285713 0.0285713
-0.0285713 0.0285713 0.0285713 0.0285713 0.0285713 0.0285713 0.0285713
-0.0285713 0.0285713 0.0285713 0.0285713 0.0285713 0.0285713 0.0285713
-0.0285713 0.0285713 0.0285713 0.0285713 0.0285713 0.0285713 0.0285713
-0.0285713 0.0285713 0.0285713 0.0285713 0.0285713 0.0285713 0.0285713
-0.0285713 0.0285713 0.0285713 0.0285713 0.0285713 0.0285713 0.0285713
-0.0285713 0.0285713 0.0285713 0.0285713 0.0285713 0.0285713 0.0285713
-0.0285713 0.0285713 0.0285713 0.0292856 0.0299999 0.0307142 0.0314285
-0.0321428 0.032857 0.0335713 0.0342856 0.0349999 0.0357142 0.0364285
-0.0371427 0.037857 0.0385713 0.0392856 0.0399999 0.0407142 0.0414285
-0.0421427 0.042857 0.0435713 0.0442856 0.0449999 0.0457142 0.0464284
-0.0471427 0.047857 0.0485713 0.0492856 0.0499999 0.0507141 0.0514284
-0.0521427 0.052857 0.0535713 0.0542856 0.0549998 0.0557141 0.0564284
-0.0571427 0.0571427 0.0571427 0.0571427 0.0571427 0.0571427 0.0585713
-0.0599999 0.0614284 0.062857 0.0642856 0.0657141 0.0671427 0.0685713
-0.0699998 0.0714284 0.0785713 0.0857141 0.092857 0.0999998 0.0999998
-0.0999998 0.0999998 0.0999998 0.0999998 0.102857 0.105714 0.108571
-0.111428 0.114286 0.117143 0.12 0.122857 0.125714 0.128571 0.13 0.131428
-0.132857 0.134285 0.135714 0.137143 0.138571 0.14 0.141428 0.142857
-0.16 0.162857 0.165714 0.168571 0.171428 0.185714 0.185714 0.185714
-0.185714 0.185714 0.614285 0.614285 0.614285 0.642856 0.645713 0.64857
-0.651427 0.654285 0.714284;
-#X coords 0 1 998 -1 200 140 1;
-#X restore 415 187 graph;
-#X obj 423 470 tabread4~ shape;
-#X obj 395 479 -~ 0;
-#X obj 417 408 % 20;
-#X obj 465 388 sel 0 12;
-#X obj 455 430 *~ 6;
-#X obj 460 610 sig~ 1.5;
-#X connect 0 0 5 0;
-#X connect 1 0 0 0;
-#X connect 3 0 4 0;
-#X connect 6 0 7 0;
-#X connect 7 0 8 0;
-#X connect 7 0 10 1;
-#X connect 7 1 8 1;
-#X connect 8 0 9 1;
-#X connect 9 0 10 0;
-#X connect 10 0 15 0;
-#X connect 11 0 16 0;
-#X connect 12 0 14 0;
-#X connect 13 0 12 0;
-#X connect 16 0 9 0;
-#X connect 18 0 20 0;
-#X connect 19 0 24 0;
-#X connect 20 0 19 0;
-#X connect 20 1 21 0;
-#X connect 21 0 22 1;
-#X connect 22 0 23 0;
-#X connect 22 0 25 1;
-#X connect 23 0 22 1;
-#X connect 24 0 25 0;
-#X connect 24 1 22 0;
-#X connect 25 0 26 0;
-#X connect 27 0 58 0;
-#X connect 29 0 30 0;
-#X connect 30 0 33 0;
-#X connect 31 0 28 0;
-#X connect 31 0 42 0;
-#X connect 33 0 49 0;
-#X connect 34 0 36 0;
-#X connect 35 0 3 0;
-#X connect 36 0 32 1;
-#X connect 36 0 32 0;
-#X connect 36 0 56 0;
-#X connect 37 0 36 1;
-#X connect 38 0 37 0;
-#X connect 39 0 40 0;
-#X connect 40 0 28 0;
-#X connect 40 0 34 0;
-#X connect 42 0 41 0;
-#X connect 43 0 40 0;
-#X connect 43 0 36 2;
-#X connect 44 0 38 0;
-#X connect 45 0 46 0;
-#X connect 46 0 44 0;
-#X connect 47 0 49 0;
-#X connect 48 0 47 0;
-#X connect 49 0 27 0;
-#X connect 50 0 51 0;
-#X connect 51 0 52 0;
-#X connect 52 0 48 0;
-#X connect 52 1 48 0;
-#X connect 53 0 60 0;
-#X connect 54 0 62 0;
-#X connect 55 0 54 0;
-#X connect 56 0 31 0;
-#X connect 58 0 59 0;
-#X connect 59 0 31 0;
-#X connect 59 0 34 0;
-#X connect 60 0 61 0;
-#X connect 61 0 55 0;
-#X connect 61 1 55 0;
-#X connect 62 0 49 0;
-#X connect 63 0 36 2;
diff --git a/tracker/tracker.c b/tracker/tracker.c
index cc6e7fa..9477246 100644
--- a/tracker/tracker.c
+++ b/tracker/tracker.c
@@ -26,6 +26,7 @@
/* ------------------------------------------------------------------------ */
#include <stdlib.h>
+#include <string.h>
#include "tracker.h"
t_widgetbehavior tracker_widgetbehavior;
@@ -94,7 +95,7 @@ static void tracker_draw_update_single(t_tracker* x, int r, int c) {
static void tracker_draw_update_cursor_pos(t_tracker* x) {
t_canvas* canvas = glist_getcanvas(x->x_glist);
- if(x->x_cursor_pos >= 0) {
+ if(x->x_cursor_pos >= 0 && x->b_cursor) {
sys_vgui(".x%x.c coords %xCURSOR %d %d %d %d\n", canvas, x, text_xpix(&x->x_obj, x->x_glist)+MARGIN_X-1, text_ypix(&x->x_obj, x->x_glist)+x->x_cursor_pos*x->x_cell_height+MARGIN_Y-1, text_xpix(&x->x_obj, x->x_glist)+x->x_columns*x->x_cell_width+MARGIN_X+1, text_ypix(&x->x_obj, x->x_glist)+(x->x_cursor_pos+1)*x->x_cell_height+MARGIN_Y+1);
} else {
sys_vgui(".x%x.c coords %xCURSOR %d %d %d %d\n", canvas, x, 0, 0, 0, 0);
@@ -154,21 +155,28 @@ static void tracker_getrect(t_gobj* z, t_glist* owner, int* xp1, int* yp1, int*
static void tracker_save(t_gobj* z, t_binbuf* b) {
t_tracker* x = (t_tracker*)z;
- int ei,gi;
- binbuf_addv(b, "ssiisii", gensym("#X"), gensym("obj"),
+ binbuf_addv(b, "ssiis", gensym("#X"), gensym("obj"),
(t_int)x->x_obj.te_xpix, (t_int)x->x_obj.te_ypix,
- gensym("tracker"), x->x_columns, x->x_rows);
-
- /* save data: */
- int tmp;
- for (ei = 0; ei < x->x_rows; ei++) {
- for (gi = 0; gi < x->x_columns; gi++) {
- tmp = (int)x->x_data[ei][gi];
- binbuf_addv(b, "i", tmp);
+ gensym("tracker"));
+
+ if(x->b_save_data) {
+ int ei,gi;
+ binbuf_addv(b, "sii", gensym("-data"), x->x_columns, x->x_rows);
+ /* save data: */
+ for (ei = 0; ei < x->x_rows; ei++) {
+ for (gi = 0; gi < x->x_columns; gi++) {
+ binbuf_addv(b, "i", (int)x->x_data[ei][gi]);
+ }
}
+ } else {
+ binbuf_addv(b, "sisi",
+ gensym("-rows"), x->x_rows,
+ gensym("-cols"), x->x_columns
+ );
}
+
binbuf_addv(b, ";");
}
@@ -176,13 +184,15 @@ static void tracker_properties(t_gobj* z, t_glist* owner) {
char buf[800];
t_tracker* x = (t_tracker*)z;
- sprintf(buf, "pdtk_tracker_dialog %%s %d %d\n",
- (int)x->x_columns, (int)x->x_rows);
+ sprintf(buf, "pdtk_tracker_dialog %%s %d %d %d\n",
+ (int)x->x_columns, (int)x->x_rows,
+ (int)x->b_save_data
+ );
//post("buf=%s", buf);
gfxstub_new(&x->x_obj.ob_pd, x, buf);
}
-static void tracker_dialog(t_tracker* x, t_symbol* s, int argc, t_atom* argv) {
+/*static void tracker_dialog(t_tracker* x, t_symbol* s, int argc, t_atom* argv) {
t_canvas* canvas = glist_getcanvas(x->x_glist);
int ei;
if(!x) {
@@ -200,18 +210,11 @@ static void tracker_dialog(t_tracker* x, t_symbol* s, int argc, t_atom* argv) {
tracker_draw_erase(x, x->x_glist);
- /*
- x->x_columns = argv[0].a_w.w_float;
- if(x->x_columns <= 0) x->x_columns = 100;
- x->x_rows = argv[1].a_w.w_float;
- if(x->x_rows <= 0) x->x_rows = 100;
- */
-
tracker_resize(x, (int)argv[1].a_w.w_float, (int)argv[0].a_w.w_float);
tracker_draw_new(x, x->x_glist);
canvas_fixlinesfor(canvas, (t_text*)x);
-}
+}*/
static void tracker_select(t_gobj* z, t_glist* glist, int selected) {
t_tracker* x = (t_tracker*)z;
@@ -221,7 +224,7 @@ static void tracker_select(t_gobj* z, t_glist* glist, int selected) {
}
static void tracker_activate(t_gobj* z, t_glist* glist, int state) {
- post("tracker: activate(%d)", state);
+ //post("tracker: activate(%d)", state);
}
static void tracker_vis(t_gobj* z, t_glist* glist, int vis) {
@@ -270,13 +273,15 @@ static void tracker_key(void* z, t_floatarg fkey) {
tracker_draw_update_single(x, x->x_active_row, x->x_active_column);
}
} else if(k == '\n') {
- n = atoi(x->x_buf);
- if(x->x_active_row >= 0 && x->x_active_column >= 0) {
- int oldr,oldc;
- tracker_setitem(x, x->x_active_row, x->x_active_column, n);
- tracker_reset_buffer(x);
- tracker_draw_update_single(x, x->x_active_row, x->x_active_column);
- //tracker_select_item(x, -1, -1);
+ if(x->x_buf[0]) {
+ n = atoi(x->x_buf);
+ if(x->x_active_row >= 0 && x->x_active_column >= 0) {
+ int oldr,oldc;
+ tracker_setitem(x, x->x_active_row, x->x_active_column, n);
+ tracker_reset_buffer(x);
+ tracker_draw_update_single(x, x->x_active_row, x->x_active_column);
+ //tracker_select_item(x, -1, -1);
+ }
}
} else if(k == '\x7f' || k == 8) {
if(x->x_active_row >= 0 && x->x_active_column >= 0) {
@@ -377,12 +382,12 @@ static void tracker_update(t_tracker* x, t_symbol* s, int argc, t_atom* argv) {
}
static void tracker_resize(t_tracker* x, int newrows, int newcols) {
- int ei,ej;
-
- t_float** oldbuf = x->x_data;
int oldrows = x->x_rows;
int oldcols = x->x_columns;
+ if(oldrows == newrows && oldcols == newcols) return;
+ int ei,ej;
+ t_float** oldbuf = x->x_data;
x->x_data = (t_float**)getbytes(newrows*sizeof(t_float*));
for(ei = 0; ei < newrows; ei++) {
x->x_data[ei] = (t_float*)getbytes(newcols*sizeof(t_float));
@@ -400,6 +405,14 @@ static void tracker_resize(t_tracker* x, int newrows, int newcols) {
x->x_columns = newcols;
}
+static void tracker_gresize(t_tracker* x, t_floatarg newrows, t_floatarg newcols) {
+ t_canvas* canvas = glist_getcanvas(x->x_glist);
+ tracker_draw_erase(x, x->x_glist);
+ tracker_resize(x, (int)newrows, (int)newcols);
+ tracker_draw_new(x, x->x_glist);
+ canvas_fixlinesfor(canvas, (t_text*)x);
+}
+
static void tracker_free(t_tracker* x) {
int ei;
for(ei = 0; ei < x->x_rows; ei++) {
@@ -430,28 +443,86 @@ static t_tracker* tracker_new(t_symbol* s, int argc, t_atom* argv) {
x->x_rows = 1;
x->x_ndigits = 3;
x->x_cursor_pos = -1;
+ x->b_cursor = 0;
+ x->b_save_data = 0;
- int cols,rows;
+ int cols = 0, rows = 0;
+ int got_data = 0;
if(argc == 0) {
// set default values
cols = 10;
rows = 10;
+ tracker_resize(x, rows, cols);
+ x->b_save_data = 1;
} else {
- if(argc <= 2) {
- post("tracker: error: wrong # of arguments (<2)");
+ //if(argc <= 2) {
+ // post("tracker: error: wrong # of arguments (<2)");
+ // return NULL;
+ //}
+ #define ARG_CHECK_LOOP_BEGIN while(ei < argc) { if(0) {}
+ #define ARG_CHECK_LOOP_END }
+ #define MATCH_ARG(sz) else if(argv[ei].a_type == A_SYMBOL && \
+ strcmp(sz, argv[ei].a_w.w_symbol->s_name) == 0)
+ #define MATCH_ARG_T(sz,t) else if(argv[ei].a_type == A_SYMBOL && \
+ strcmp(sz, argv[ei].a_w.w_symbol->s_name) == 0 && (ei + 1) < \
+ argc && argv[ei+1].a_type == t)
+ #define MATCH_FAILED else
+ ei = 0;
+ /*----------------*/ARG_CHECK_LOOP_BEGIN
+ MATCH_ARG_T("-rows", A_FLOAT) {
+ ei++;
+ rows = (int)argv[ei++].a_w.w_float;
+ }
+ MATCH_ARG_T("-cols", A_FLOAT) {
+ ei++;
+ cols = (int)argv[ei++].a_w.w_float;
+ }
+ MATCH_ARG_T("-bg", A_FLOAT) { ei++; ei++; }
+ MATCH_ARG_T("-bg", A_SYMBOL) { ei++; ei++; }
+ MATCH_ARG_T("-fg", A_FLOAT) { ei++; ei++; }
+ MATCH_ARG_T("-fg", A_SYMBOL) { ei++; ei++; }
+ MATCH_ARG_T("-sl", A_FLOAT) { ei++; ei++; }
+ MATCH_ARG_T("-sl", A_SYMBOL) { ei++; ei++; }
+ MATCH_ARG_T("-bd", A_FLOAT) { ei++; ei++; }
+ MATCH_ARG_T("-bd", A_SYMBOL) { ei++; ei++; }
+ MATCH_ARG("-data") {
+ ei++;
+ if((argc - ei) < 2) {
+ post("tracker: too few arguments to option -data");
+ post("tracker: expeting: -data <rows> <cols> #rows*cols ...");
+ return NULL;
+ }
+ cols = argv[ei++].a_w.w_float;
+ rows = argv[ei++].a_w.w_float;
+ if((argc - ei) < (rows * cols)) {
+ post("tracker: too few arguments to option -data");
+ post("tracker: expeting: -data %d %d followed by %d floats",
+ rows, cols, rows * cols);
+ return NULL;
+ }
+ tracker_resize(x, rows, cols);
+ int j;
+ for(j = 0; j < (rows * cols); j++) {
+ x->x_data[j / cols][j % cols] = argv[ei++].a_w.w_float;
+ }
+ got_data = 1;
+ x->b_save_data = 1;
+ }
+ MATCH_FAILED {
+ post("tracker: argument error: w_float=%f, w_symbol=%s",
+ argv[ei].a_w.w_float, argv[ei].a_w.w_symbol->s_name);
return NULL;
}
- cols = argv[0].a_w.w_float;
- rows = argv[1].a_w.w_float;
+ /*----------------*/ARG_CHECK_LOOP_END
}
- tracker_resize(x, rows, cols);
+ if(!got_data) tracker_resize(x, rows, cols);
- if(argc == (2+cols*rows)) {
+ /*if(argc == (2+cols*rows)) {
// restore saved data
for(ei = 2; ei < argc; ei++) {
x->x_data[(ei-2)/cols][(ei-2)%cols] = argv[ei].a_w.w_float;
}
- }
+ }*/
x->x_glist = (t_glist*)canvas_getcurrent();
/* calculate font metrics */
@@ -464,7 +535,56 @@ static t_tracker* tracker_new(t_symbol* s, int argc, t_atom* argv) {
return x;
}
-static void tracker_getrow(t_tracker* x, t_float row) {
+static void tracker_file_load(t_tracker* x, t_symbol* f) {
+ void* binbuf = binbuf_new();
+ t_canvas* canvas = glist_getcanvas(x->x_glist);
+ if(binbuf_read_via_canvas(binbuf, f->s_name, canvas, 0))
+ error("tracker: %s: read failed", f->s_name);
+
+ int argc = binbuf_getnatom(binbuf);
+ t_atom* argv = binbuf_getvec(binbuf);
+
+ if(argc < 2) {
+ error("tracker: empty or invalid file");
+ }
+
+ int j = 0;
+ int rows = (int)argv[j++].a_w.w_float,
+ cols = (int)argv[j++].a_w.w_float;
+ tracker_gresize(x, rows, cols);
+
+ int r,c;
+ for(r = 0; r < x->x_rows; r++) {
+ for(c = 0; c < x->x_columns; c++) {
+ //x->x_data[r][c] = argv[2+r*cols+c].a_w.w_float;
+ x->x_data[r][c] = argv[j++].a_w.w_float;
+ }
+ }
+ tracker_gresize(x, rows, cols);
+
+ binbuf_free(binbuf);
+}
+
+static void tracker_file_save(t_tracker* x, t_symbol* f) {
+ void* binbuf = binbuf_new();
+ t_canvas* canvas = glist_getcanvas(x->x_glist);
+ char buf[MAXPDSTRING];
+ canvas_makefilename(canvas, f->s_name, buf, MAXPDSTRING);
+
+ int r,c;
+ binbuf_addv(binbuf, "ii", x->x_rows, x->x_columns);
+ for(r = 0; r < x->x_rows; r++) {
+ for(c = 0; c < x->x_columns; c++) {
+ binbuf_addv(binbuf, "i", (int)x->x_data[r][c]);
+ }
+ }
+
+ if(binbuf_write(binbuf, buf, "", 0))
+ error("%s: write failed", f->s_name);
+ binbuf_free(binbuf);
+}
+
+static void tracker_getrow(t_tracker* x, t_floatarg row) {
int ei,introw;
introw = (int)row;
@@ -478,13 +598,22 @@ static void tracker_getrow(t_tracker* x, t_float row) {
outlet_list(x->outlet0, &s_list, x->x_columns, atombuf);
freebytes(atombuf, sizeof(t_atom)*x->x_columns);
- if(1) {
+ if(x->b_cursor) {
x->x_cursor_pos = ((t_int)row) % x->x_rows;
if(x->x_cursor_pos < 0) x->x_cursor_pos = 0;
tracker_draw_update_cursor_pos(x);
}
}
+static void tracker_set_saveflag(t_tracker* x, t_floatarg b) {
+ x->b_save_data = (int)(b == 0 ? 0 : 1);
+}
+
+static void tracker_toggle_cursor(t_tracker* x, t_floatarg b) {
+ x->b_cursor = (int)(b == 0 ? 0 : 1);
+ tracker_draw_update_cursor_pos(x);
+}
+
static void tracker_setrow(t_tracker* x, t_symbol* s, int argc, t_atom* argv) {
if(argc < 2) {
post("tracker: setrow: too few arguments");
@@ -560,12 +689,17 @@ keyname_sym = gensym("#keyname");
0
);
class_addlist(tracker_class, tracker_list);
+ class_addmethod(tracker_class, (t_method)tracker_toggle_cursor, gensym("trackrow"), A_FLOAT, 0);
class_addmethod(tracker_class, (t_method)tracker_update, gensym("update"), A_GIMME, 0);
- class_addmethod(tracker_class, (t_method)tracker_dialog, gensym("dialog"), A_GIMME, 0);
+ //class_addmethod(tracker_class, (t_method)tracker_dialog, gensym("dialog"), A_GIMME, 0);
class_addmethod(tracker_class, (t_method)tracker_setrow, gensym("setrow"), A_GIMME, 0);
class_addmethod(tracker_class, (t_method)tracker_getrow, gensym("getrow"), A_FLOAT, 0);
class_addmethod(tracker_class, (t_method)tracker_setitem, gensym("set"), A_FLOAT, A_FLOAT, A_FLOAT, 0);
class_addmethod(tracker_class, (t_method)tracker_getitem, gensym("get"), A_FLOAT, A_FLOAT, 0);
+ class_addmethod(tracker_class, (t_method)tracker_gresize, gensym("resize"), A_FLOAT, A_FLOAT, 0);
+ class_addmethod(tracker_class, (t_method)tracker_set_saveflag, gensym("set_saveflag"), A_FLOAT, 0);
+ class_addmethod(tracker_class, (t_method)tracker_file_load, gensym("load"), A_SYMBOL, 0);
+ class_addmethod(tracker_class, (t_method)tracker_file_save, gensym("save"), A_SYMBOL, 0);
tracker_widgetbehavior.w_getrectfn = tracker_getrect;
tracker_widgetbehavior.w_displacefn = tracker_displace;
diff --git a/tracker/tracker.h b/tracker/tracker.h
index 7df761c..36f9ba6 100644
--- a/tracker/tracker.h
+++ b/tracker/tracker.h
@@ -27,6 +27,8 @@ typedef struct _tracker
t_int x_active_column; // selected item col
t_int x_ndigits; // cell width (+1 of margin added automatically)
t_int x_cursor_pos; // visual cursor position (row indicator)
+ t_int b_cursor; // track cursor?
+ t_int b_save_data; // save data?
char x_buf[MAX_BUF+1]; // edit buffer
t_int x_cell_width; // cell width in pixels (auto computed)
t_int x_cell_height; // cell height in pixels (auto computed)
diff --git a/tracker/tracker.tk b/tracker/tracker.tk
index 9d2a844..cd21b9f 100644
--- a/tracker/tracker.tk
+++ b/tracker/tracker.tk
@@ -1,76 +1,91 @@
proc tracker_apply {id} {
# strip "." from the TK id to make a variable name suffix
- set vid [string trimleft $id .]
+ set vid [string trimleft $id .]
# for each variable, make a local variable to hold its name...
- set var_graph_width [concat graph_width_$vid]
- global $var_graph_width
- set var_graph_height [concat graph_height_$vid]
- global $var_graph_height
+ set var_graph_width [concat graph_width_$vid]
+ global $var_graph_width
+ set var_graph_height [concat graph_height_$vid]
+ global $var_graph_height
+ set var_saveflag [concat saveflag_$vid]
+ global $var_saveflag
- set cmd [concat $id dialog \
- [eval concat $$var_graph_width] \
- [eval concat $$var_graph_height] \
- \;]
- #puts stderr $cmd
- pd $cmd
+ set cmd [concat $id resize \
+ [eval concat $$var_graph_height] \
+ [eval concat $$var_graph_width] \
+ \;]
+ pd $cmd
+
+ set cmd [concat $id set_saveflag \
+ [eval concat $$var_saveflag] \
+ \;]
+ pd $cmd
}
proc tracker_cancel {id} {
- set cmd [concat $id cancel \;]
- #puts stderr $cmd
- pd $cmd
+ set cmd [concat $id cancel \;]
+ #puts stderr $cmd
+ pd $cmd
}
proc tracker_ok {id} {
- tracker_apply $id
- tracker_cancel $id
+ tracker_apply $id
+ tracker_cancel $id
}
-proc pdtk_tracker_dialog {id width height} {
- set vid [string trimleft $id .]
+proc pdtk_tracker_dialog {id width height saveflag} {
+ set vid [string trimleft $id .]
- set var_graph_width [concat graph_width_$vid]
- global $var_graph_width
- set var_graph_height [concat graph_height_$vid]
- global $var_graph_height
+ set var_graph_width [concat graph_width_$vid]
+ global $var_graph_width
+ set var_graph_height [concat graph_height_$vid]
+ global $var_graph_height
+ set var_saveflag [concat saveflag_$vid]
+ global $var_saveflag
- set $var_graph_width $width
- set $var_graph_height $height
+ set $var_graph_width $width
+ set $var_graph_height $height
+ set $var_saveflag $saveflag
- toplevel $id
- wm title $id {tracker}
- wm protocol $id WM_DELETE_WINDOW [concat tracker_cancel $id]
+ toplevel $id
+ wm title $id {tracker}
+ wm protocol $id WM_DELETE_WINDOW [concat tracker_cancel $id]
- label $id.label -text {GRID PROPERTIES}
- pack $id.label -side top
+ label $id.label -text {GRID PROPERTIES}
+ pack $id.label -side top
- frame $id.buttonframe
- pack $id.buttonframe -side bottom -fill x -pady 2m
- button $id.buttonframe.cancel -text {Cancel}\
- -command "tracker_cancel $id"
- button $id.buttonframe.apply -text {Apply}\
- -command "tracker_apply $id"
- button $id.buttonframe.ok -text {OK}\
- -command "tracker_ok $id"
- pack $id.buttonframe.cancel -side left -expand 1
- pack $id.buttonframe.apply -side left -expand 1
- pack $id.buttonframe.ok -side left -expand 1
+ frame $id.buttonframe
+ pack $id.buttonframe -side bottom -fill x -pady 2m
+ button $id.buttonframe.cancel -text {Cancel}\
+ -command "tracker_cancel $id"
+ button $id.buttonframe.apply -text {Apply}\
+ -command "tracker_apply $id"
+ button $id.buttonframe.ok -text {OK}\
+ -command "tracker_ok $id"
+ pack $id.buttonframe.cancel -side left -expand 1
+ pack $id.buttonframe.apply -side left -expand 1
+ pack $id.buttonframe.ok -side left -expand 1
- frame $id.1rangef
- pack $id.1rangef -side top
- label $id.1rangef.lwidth -text "Width :"
- #entry $id.1rangef.width -textvar $var_graph_width -width 7
- spinbox $id.1rangef.width -textvariable $var_graph_width -width 7 -from 1 -to 99 -increment 1
- pack $id.1rangef.lwidth $id.1rangef.width -side left
+ frame $id.1rangef
+ pack $id.1rangef -side top
+ label $id.1rangef.lwidth -text "Width :"
+ #entry $id.1rangef.width -textvar $var_graph_width -width 7
+ spinbox $id.1rangef.width -textvariable $var_graph_width -width 7 -from 1 -to 99 -increment 1
+ pack $id.1rangef.lwidth $id.1rangef.width -side left
- frame $id.2rangef
- pack $id.2rangef -side top
- label $id.2rangef.lheight -text "Height :"
- #entry $id.2rangef.height -textvar $var_graph_height -width 7
- spinbox $id.2rangef.height -textvariable $var_graph_height -width 7 -from 1 -to 99 -increment 1
- pack $id.2rangef.lheight $id.2rangef.height -side left
+ frame $id.2rangef
+ pack $id.2rangef -side top
+ label $id.2rangef.lheight -text "Height :"
+ #entry $id.2rangef.height -textvar $var_graph_height -width 7
+ spinbox $id.2rangef.height -textvariable $var_graph_height -width 7 -from 1 -to 99 -increment 1
+ pack $id.2rangef.lheight $id.2rangef.height -side left
+
+ frame $id.3rangef
+ pack $id.3rangef -side top
+ label $id.3rangef.lsaveflag -text ""
+ checkbutton $id.3rangef.saveflag -variable $var_saveflag -text "save contents"
+ pack $id.3rangef.lsaveflag $id.3rangef.saveflag -side left
- bind $id.1rangef.width <KeyPress-Return> [concat tracker_ok $id]
- bind $id.2rangef.height <KeyPress-Return> [concat tracker_ok $id]
- focus $id.1rangef.width
+ bind $id.1rangef.width <KeyPress-Return> [concat tracker_ok $id]
+ bind $id.2rangef.height <KeyPress-Return> [concat tracker_ok $id]
+ focus $id.1rangef.width
}