#N canvas 368 38 736 636 12;
#X declare -stdpath ./;
#N canvas 92 488 1216 368 trace-list 1;
#X coords 0 92 1 91.75 0 0 0;
#X restore 567 541 pd trace-list;
#N canvas 375 90 539 284 trace-template 0;
#X text 68 167 This template describes a pitch/amplitude trace. The array "partial" holds the actual points. In this template \, y is always 0 and x is the starting location in pixels. There are 5 pixels per point.;
#X obj 72 32 struct trace-template float x float y float voiceno array partial point-template;
#X obj 72 124 plot partial 0 1 0 0 5;
#X obj 72 93 r vis;
#X connect 3 0 2 0;
#X restore 553 459 pd trace-template;
#N canvas 311 238 528 190 point-template 0;
#X text 64 65 This template describes a single point on a pitch trace (cf. trace-template w describes the trace itself.);
#X text 64 98 "y" is the field that is shown on the graph \; it's - 4 * pitch. You also get an "amp" field in dB \, which you can't see as a plot (yet).;
#X obj 113 29 struct point-template float y float amp;
#X restore 553 480 pd point-template;
#X text 93 22 SINUSOID TRACKING;
#X text 559 434 templates:;
#X text 576 515 display:;
#X obj 319 74 bng 20 250 50 0 empty empty empty 17 7 0 10 #dfdfdf #000000 #000000;
#X obj 538 121 bng 20 250 50 0 empty empty 2nd 28 10 0 20 #dfdfdf #000000 #000000;
#X obj 319 494 output~;
#X obj 22 126 openpanel;
#X obj 22 74 bng 20 250 50 0 empty empty 1st 28 10 0 20 #dfdfdf #000000 #000000;
#N canvas 230 244 864 264 sample 0;
#X obj 26 17 inlet;
#X obj 68 143 r window-size;
#X obj 26 141 -;
#N canvas 441 320 449 241 record 0;
#X obj 37 37 inlet;
#X obj 53 145 adc~ 1;
#X text 191 91 (set array size to 3 seconds);
#X msg 52 77 \; resize-sample 3000 \; pd dsp 1;
#X obj 37 182 tabwrite~ \$0-sample;
#X connect 0 0 3 0;
#X connect 0 0 4 0;
#X connect 1 0 4 0;
#X restore 122 66 pd record;
#X obj 72 17 inlet;
#X obj 122 16 inlet;
#X obj 216 17 inlet;
#N canvas 258 200 300 381 load 0;
#X obj 55 34 inlet;
#X obj 55 256 soundfiler;
#X msg 109 144 \; pd dsp 1;
#X obj 109 34 inlet;
#X msg 109 99 symbol ../sound/\$1;
#X obj 109 69 symbol;
#X obj 55 292 outlet;
#X obj 55 195 list append \$0-sample;
#X msg 55 227 read -resize \$1 \$2;
#X connect 0 0 2 0;
#X connect 0 0 7 0;
#X connect 1 0 6 0;
#X connect 3 0 5 0;
#X connect 4 0 2 0;
#X connect 4 0 7 0;
#X connect 5 0 4 0;
#X connect 7 0 8 0;
#X connect 8 0 1 0;
#X restore 26 66 pd load;
#N canvas 362 36 579 430 synthesis 0;
#X obj 68 113 osc~ 110;
#X obj 68 165 *~;
#X obj 68 209 +~ 0.2;
#X obj 68 241 cos~;
#X obj 68 284 *~;
#X obj 199 31 inlet;
#X obj 134 188 vline~;
#X obj 308 188 vline~;
#X text 251 277 This creates a waveshaping synthesis sample., f 26;
#X msg 317 86 \; resize-sample 2500 \; pd dsp 1 \, fast-forward 2500;
#X msg 134 148 0 \, 2 500 \, 0.05 1500 500;
#X obj 199 365 tabwrite~ \$0-sample;
#X msg 308 148 0 \, 1 100 \, 0 2400 250;
#X connect 0 0 1 0;
#X connect 1 0 2 0;
#X connect 2 0 3 0;
#X connect 3 0 4 0;
#X connect 4 0 11 0;
#X connect 5 0 10 0;
#X connect 5 0 12 0;
#X connect 5 0 9 0;
#X connect 5 0 11 0;
#X connect 6 0 1 1;
#X connect 7 0 4 1;
#X connect 10 0 6 0;
#X connect 12 0 7 0;
#X restore 216 66 pd synthesis;
#X obj 26 176 s sample-size;
#X obj 351 69 cnv 19 451 88 empty empty empty 20 12 0 12 #ffffff #404040 0;
#N canvas 179 166 287 327 resize-sample 0;
#X obj 83 18 r resize-sample;
#X obj 115 106 samplerate~;
#X obj 83 111 *;
#X obj 83 78 t f b;
#X obj 97 205 s \$0-sample;
#X msg 97 171 resize \$1;
#X obj 83 249 outlet;
#X obj 83 47 / 1000;
#X connect 0 0 7 0;
#X connect 1 0 2 1;
#X connect 2 0 5 0;
#X connect 2 0 6 0;
#X connect 3 0 2 0;
#X connect 3 1 1 0;
#X connect 5 0 4 0;
#X connect 7 0 3 0;
#X restore 40 108 pd resize-sample;
#X obj 351 69 cnv 19 451 88 empty empty empty 20 12 0 12 #e0e0e0 #404040 0;
#N canvas 0 50 450 300 (subpatch) 0;
#X array \$0-sample 169735 float 2;
#A color 0;
#A width 2;
#X coords 0 1 169735 -1 453 90 1 0 0;
#X restore 350 68 graph;
#X connect 0 0 7 0;
#X connect 1 0 2 1;
#X connect 2 0 9 0;
#X connect 4 0 7 1;
#X connect 5 0 3 0;
#X connect 6 0 8 0;
#X connect 7 0 2 0;
#X connect 11 0 2 0;
#X coords 0 -1 1 1 453 108 2 350 50;
#X restore 22 176 pd sample;
#X msg 186 151 voice2.wav;
#X msg 179 128 voice.wav;
#X msg 170 105 bell.aiff;
#X text 111 126 choose:;
#X text 12 50 browse:;
#X floatatom 612 196 4 1 50 1 nvoice nvoice-set - 16;
#X text 601 162 clear;
#N canvas 105 23 1209 549 make-trace 0;
#X obj 859 358 setsize trace-template partial, f 14;
#X obj 227 252 pointer;
#X floatatom 162 312 6 0 0 0 - - - 0;
#X floatatom 227 308 6 0 0 0 - - - 0;
#X obj 457 189 pointer;
#X msg 475 158 next;
#X obj 490 328 getsize trace-template partial;
#X obj 227 281 get point-template y;
#X obj 67 252 set point-template y;
#X obj 227 190 element trace-template partial;
#X obj 162 342 setsize trace-template partial;
#X obj 320 474 set trace-template x;
#X obj 267 402 set trace-template y;
#X obj 509 253 get trace-template x y;
#X msg 457 127 traverse pd-trace-list \, next;
#X obj 243 221 bng 19 250 50 0 empty empty empty 0 -10 0 12 #dfdfdf #000000 #000000;
#X floatatom 67 228 6 0 0 0 - - - 0;
#X floatatom 227 161 6 0 0 0 - - - 0;
#X floatatom 660 283 6 0 0 0 - - - 0;
#X floatatom 509 283 6 0 0 0 - - - 0;
#X floatatom 490 362 6 0 0 0 - - - 0;
#X floatatom 320 449 6 0 0 0 - - - 0;
#X floatatom 267 376 6 0 0 0 - - - 0;
#X obj 945 219 pointer;
#X msg 945 194 traverse pd-trace-list \, bang;
#X obj 743 97 bng 19 250 50 0 empty empty empty 0 -10 0 12 #dfdfdf #000000 #000000;
#X obj 743 125 trigger bang bang;
#X obj 859 158 random 100;
#X obj 859 184 + 15;
#X floatatom 859 211 5 0 0 0 - - - 0;
#X floatatom 743 213 5 0 0 0 - - - 0;
#X msg 859 330 15;
#X obj 945 49 bng 19 250 50 0 empty empty empty 0 -10 0 12 #dfdfdf #000000 #000000;
#X text 968 46 <-- click here first;
#X obj 743 153 random 300;
#X obj 743 179 + 50;
#X obj 935 444 element trace-template partial;
#X obj 773 348 until;
#X msg 821 348 0;
#X obj 784 382 f;
#X obj 818 388 + 1;
#X obj 773 320 f 15;
#X obj 784 412 t b f;
#X obj 784 501 set point-template amp;
#X obj 773 261 append trace-template x y;
#X floatatom 52 166 6 0 0 0 - - - 0;
#X obj 52 190 set point-template amp;
#X text 770 95 <- random x/y values;
#X obj 773 291 trigger bang bang pointer;
#X obj 784 444 random 50;
#X obj 784 470 + 50;
#X text 301 41 This subpatch creates tracks manually or randomly;
#X connect 1 0 7 0;
#X connect 2 0 10 0;
#X connect 4 0 10 1;
#X connect 4 0 11 1;
#X connect 4 0 12 1;
#X connect 4 0 9 1;
#X connect 4 0 13 0;
#X connect 4 0 6 0;
#X connect 5 0 4 0;
#X connect 6 0 20 0;
#X connect 7 0 3 0;
#X connect 9 0 1 0;
#X connect 9 0 8 1;
#X connect 9 0 46 1;
#X connect 13 0 19 0;
#X connect 13 1 18 0;
#X connect 14 0 4 0;
#X connect 15 0 1 0;
#X connect 16 0 8 0;
#X connect 17 0 9 0;
#X connect 21 0 11 0;
#X connect 22 0 12 0;
#X connect 23 0 44 2;
#X connect 24 0 23 0;
#X connect 25 0 26 0;
#X connect 26 0 34 0;
#X connect 26 1 27 0;
#X connect 27 0 28 0;
#X connect 28 0 29 0;
#X connect 29 0 44 1;
#X connect 30 0 44 0;
#X connect 31 0 0 0;
#X connect 32 0 24 0;
#X connect 34 0 35 0;
#X connect 35 0 30 0;
#X connect 36 0 43 1;
#X connect 37 0 39 0;
#X connect 38 0 39 1;
#X connect 39 0 40 0;
#X connect 39 0 42 0;
#X connect 40 0 39 1;
#X connect 41 0 37 0;
#X connect 42 0 49 0;
#X connect 42 1 36 0;
#X connect 44 0 48 0;
#X connect 45 0 46 0;
#X connect 48 0 41 0;
#X connect 48 1 31 0;
#X connect 48 1 38 0;
#X connect 48 2 0 1;
#X connect 48 2 36 1;
#X connect 49 0 50 0;
#X connect 50 0 43 0;
#X restore 385 594 pd make-trace;
#X obj 319 427 bng 20 250 50 0 empty empty empty 0 -10 0 12 #dfdfdf #000000 #000000;
#X obj 393 427 tgl 19 0 empty empty empty 0 -10 0 12 #dfdfdf #000000 #000000 0 1;
#N canvas 359 346 376 340 original 0;
#X obj 54 243 outlet~;
#X obj 177 206 bng 19 250 50 0 empty empty empty 0 -10 0 12 #dfdfdf #000000 #000000;
#X obj 177 179 spigot;
#X obj 54 106 inlet;
#X obj 216 106 inlet;
#X text 242 147 looping;
#X obj 216 147 tgl 19 0 empty empty empty 0 -10 0 12 #dfdfdf #000000 #000000 0 1;
#X obj 54 149 tabplay~ \$0-sample;
#X text 57 54 This subpatch plays the original sample.;
#X connect 1 0 7 0;
#X connect 2 0 1 0;
#X connect 3 0 7 0;
#X connect 4 0 6 0;
#X connect 6 0 2 1;
#X connect 7 0 0 0;
#X connect 7 1 2 0;
#X restore 319 458 pd original;
#X text 439 499 play original sample., f 8;
#X text 416 427 Loop;
#X text 342 427 play;
#X text 197 575 You can also create partial traces manually or randomly here:, f 34;
#N canvas 402 41 660 679 analysis 0;
#X obj 42 34 inlet;
#X msg 123 175 0;
#X floatatom 163 176 4 0 0 0 - - - 0;
#X obj 105 206 f;
#X obj 145 205 +;
#X floatatom 105 239 8 0 0 0 - - - 0;
#X obj 42 70 t b b, f 12;
#N canvas 532 151 422 303 clear 0;
#X obj 108 184 pointer;
#X obj 108 211 s last-in-list;
#X obj 108 99 t b b;
#X msg 108 160 traverse pd-trace-list \, bang;
#X obj 108 32 inlet;
#X msg 169 78 \; tgl 0 \; pd-trace-list clear \; add-trace-clear bang \;;
#X msg 20 190 \; nframe 0 \; vis 0;
#X obj 169 32 inlet;
#X connect 0 0 1 0;
#X connect 2 0 3 0;
#X connect 2 0 6 0;
#X connect 2 1 5 0;
#X connect 3 0 0 0;
#X connect 4 0 2 0;
#X connect 7 0 5 0;
#X restore 135 109 pd clear;
#X obj 188 34 inlet;
#X obj 105 267 moses;
#X obj 42 345 until;
#X obj 85 313 b;
#X obj 307 588 clone add-trace 50;
#X obj 456 570 spigot;
#X obj 495 539 tgl 19 0 empty empty empty 0 -6 0 8 #dfdfdf #000000 #000000 0 1;
#X msg 307 259 npeak \$1;
#X obj 171 544 r nframe;
#X obj 153 576 f;
#X obj 153 600 + 1;
#X obj 153 632 s nframe;
#X obj 307 515 sigmund~ -t -npeak 50 -maxfreq 8000 tracks, f 21;
#X text 517 538 print tracks;
#X msg 85 572 \; vis 1;
#X obj 307 31 inlet;
#X obj 456 596 print tracks;
#X text 346 78 This subpatch analysizes the sample with [sigmund~] and outputs 'tracks' information. Open [clone add-trace] for more details., f 36;
#X obj 163 152 r hop;
#X obj 161 268 r sample-size;
#X obj 180 231 s osc-speed-set;
#X floatatom 161 292 8 0 0 0 - - - 0;
#X text 346 146 Note that sample rate for this patch is fixed at 48000 So run Pd at this rate and load files with this same rate., f 36;
#X floatatom 307 227 5 0 0 0 - - - 0;
#X msg 242 472 clear;
#X obj 153 326 t b f;
#X obj 85 376 t b b b;
#X obj 445 405 r window-size;
#X msg 325 418 set 2 \$1 \, bang;
#X msg 445 433 set 1 \$1 \, bang;
#X obj 325 471 list store \$0-sample 2048 0 48000;
#X obj 180 206 / 48;
#X connect 0 0 6 0;
#X connect 1 0 3 1;
#X connect 2 0 4 1;
#X connect 2 0 39 0;
#X connect 3 0 4 0;
#X connect 3 0 5 0;
#X connect 4 0 3 1;
#X connect 5 0 9 0;
#X connect 6 0 10 0;
#X connect 6 1 1 0;
#X connect 6 1 7 0;
#X connect 8 0 7 1;
#X connect 9 0 33 0;
#X connect 9 1 11 0;
#X connect 10 0 3 0;
#X connect 11 0 10 1;
#X connect 11 0 34 0;
#X connect 13 0 24 0;
#X connect 14 0 13 1;
#X connect 15 0 20 0;
#X connect 16 0 17 1;
#X connect 17 0 18 0;
#X connect 18 0 19 0;
#X connect 20 0 13 0;
#X connect 20 0 12 0;
#X connect 23 0 31 0;
#X connect 26 0 2 0;
#X connect 27 0 9 1;
#X connect 27 0 29 0;
#X connect 31 0 15 0;
#X connect 32 0 20 0;
#X connect 33 0 17 0;
#X connect 33 1 36 0;
#X connect 34 0 22 0;
#X connect 34 1 17 0;
#X connect 34 2 32 0;
#X connect 35 0 37 0;
#X connect 36 0 38 0;
#X connect 37 0 38 0;
#X connect 38 0 20 0;
#X connect 39 0 28 0;
#X restore 538 242 pd analysis;
#X text 258 15 This patch derives sinusoidal "tracks" from a sampled sound via [sigmund~] into data structures and resynthesizes it.;
#X text 51 345 The resynthesizer is limited to 50-voice polyphony (the 'nvoice' number box sets the number of voices/tracks from 1 to 50). You can check the trace-list subwindow and graphically edit the spectral analysis by clicking and dragging in the arrays or duplicating \, deleting and changing their position \, then listen to the result., f 91;
#X obj 468 130 bng 20 250 50 0 empty empty empty 17 7 0 10 #dfdfdf #000000 #000000;
#X obj 575 161 bng 20 250 50 0 empty empty empty 17 7 0 10 #dfdfdf #000000 #000000;
#X obj 133 431 tgl 19 0 empty empty empty -44 12 0 16 #dfdfdf #000000 #000000 0 1;
#X obj 133 462 metro;
#X obj 165 431 nbx 5 19 -1e+37 1e+37 0 0 osc-speed osc-speed-set empty 22 35 0 13 #dfdfdf #000000 #000000 0 256;
#X obj 58 564 output~;
#X text 67 464 Step;
#X text 14 487 Start;
#X text 96 431 Auto;
#X text 237 432 Rate;
#X obj 58 493 tgl 19 0 empty tgl empty 0 -10 0 12 #dfdfdf #000000 #000000 0 1;
#X text 21 503 Stop;
#X obj 153 493 tgl 19 0 empty empty empty 0 -10 0 12 #dfdfdf #000000 #000000 0 1;
#X text 176 494 Loop;
#N canvas 330 23 704 701 resynthesis 0;
#X msg 169 183 0;
#X obj 568 501 pointer;
#X obj 338 240 pointer;
#X msg 290 446 next;
#X msg 277 239 1;
#X msg 286 288 0;
#X obj 338 405 <;
#X obj 127 280 until;
#X obj 259 317 f;
#X obj 259 340 sel 0 1;
#X obj 374 380 r synth-index;
#X obj 338 431 sel 0 1;
#X obj 169 208 f;
#X obj 169 234 s synth-index;
#X obj 203 209 + 5;
#X obj 104 223 t b b b;
#X obj 104 319 s osc-tick;
#X msg 338 211 traverse pd-trace-list \, next, f 29;
#X obj 338 351 get trace-template x;
#X obj 338 378 f;
#X obj 361 457 t b b b;
#X obj 384 569 poly 50;
#X obj 384 502 f;
#X obj 425 492 + 1;
#X obj 425 516 mod 1e+06;
#X obj 270 521 r osc-noteoff;
#X text 174 598 message is: voice number \, on/off \, track ID \, pointer, f 25;
#X obj 338 325 trigger pointer pointer;
#X obj 361 665 outlet~;
#X obj 384 542 pack f 1;
#X obj 361 635 clone -s 1 50 osc-voice;
#X obj 54 17 inlet;
#X obj 104 17 inlet;
#X obj 249 17 inlet;
#X text 498 525 track ID;
#X text 499 509 make a;
#X obj 361 604 pack float float float pointer;
#X text 423 53 This subpatch gets recorded 'tracks' information and uses it to feed an oscillator bank in a [clone] object., f 29;
#X text 537 635 oscillator bank;
#X obj 104 134 spigot;
#X obj 404 240 t b b;
#X obj 404 286 s loop;
#X obj 258 43 r loop;
#X obj 231 71 f;
#X obj 104 170 v vis;
#X obj 104 197 sel 1;
#X text 117 513 'osc-voice' sends us a note-off when done, f 20;
#X text 10 10 start;
#X text 13 23 stop;
#X text 148 17 step;
#X text 292 17 loop;
#X msg 337 167 \; pd-trace-list sort;
#X floatatom 374 406 5 0 0 0 - - - 0;
#X obj 231 122 t b b b;
#X obj 303 123 s osc-stop;
#X obj 231 96 select 1 0, f 21;
#X connect 0 0 12 0;
#X connect 1 0 36 3;
#X connect 2 0 27 0;
#X connect 2 1 40 0;
#X connect 3 0 2 0;
#X connect 4 0 8 1;
#X connect 5 0 8 1;
#X connect 6 0 11 0;
#X connect 7 0 8 0;
#X connect 8 0 9 0;
#X connect 9 0 7 1;
#X connect 9 1 19 0;
#X connect 10 0 6 1;
#X connect 10 0 52 0;
#X connect 11 0 7 1;
#X connect 11 1 20 0;
#X connect 12 0 13 0;
#X connect 12 0 14 0;
#X connect 14 0 12 1;
#X connect 15 0 16 0;
#X connect 15 1 7 0;
#X connect 15 2 12 0;
#X connect 17 0 2 0;
#X connect 18 0 19 0;
#X connect 19 0 6 0;
#X connect 20 0 3 0;
#X connect 20 1 22 0;
#X connect 20 2 1 0;
#X connect 21 0 36 0;
#X connect 21 1 36 2;
#X connect 21 2 36 1;
#X connect 22 0 23 0;
#X connect 22 0 29 0;
#X connect 23 0 24 0;
#X connect 24 0 22 1;
#X connect 25 0 21 0;
#X connect 27 0 18 0;
#X connect 27 1 1 1;
#X connect 29 0 21 0;
#X connect 30 0 28 0;
#X connect 31 0 39 1;
#X connect 31 0 55 0;
#X connect 32 0 39 0;
#X connect 33 0 43 1;
#X connect 36 0 30 0;
#X connect 39 0 44 0;
#X connect 40 0 41 0;
#X connect 40 1 5 0;
#X connect 40 1 7 1;
#X connect 42 0 43 0;
#X connect 43 0 55 0;
#X connect 44 0 45 0;
#X connect 45 0 15 0;
#X connect 53 0 44 0;
#X connect 53 1 17 0;
#X connect 53 2 4 0;
#X connect 53 2 0 0;
#X connect 53 2 51 0;
#X connect 55 0 53 0;
#X connect 55 1 54 0;
#X restore 58 527 pd resynthesis;
#X text 606 121 - Analyze;
#X text 91 75 - browse/choose soundfile or...;
#X obj 105 462 bng 20 250 50 0 empty empty empty 0 -10 0 12 #dfdfdf #000000 #000000;
#X text 339 111 or even... synthesize;
#X text 380 131 a sample -->;
#X text 343 75 <-- record live input (3 seconds);
#N canvas 514 177 350 375 init 0;
#X obj 35 67 loadbang;
#X obj 131 212 declare -stdpath ./;
#X text 66 23 initialization;
#X msg 53 102 \; pd-trace-list clear \; nvoice-set 25 \; window-size 2048 \; hop 512;
#X obj 35 263 send pd-17.partialtracer.pd;
#X msg 35 231 vis 1;
#X obj 35 200 delay 1000;
#X connect 0 0 3 0;
#X connect 0 0 6 0;
#X connect 5 0 4 0;
#X connect 6 0 5 0;
#X restore 649 244 pd init;
#X text 51 295 To resynthesize \, activate 'start' toggle and then 'step' over and over to move to the next resynthesis frame (hit toggle again to stop). Alternatively \, you can step with [metro] at a given rate in msec. The 'loop' toggle goes back to the beginning of the sample when done., f 91;
#X connect 6 0 11 2;
#X connect 7 0 27 0;
#X connect 9 0 11 0;
#X connect 10 0 9 0;
#X connect 12 0 11 1;
#X connect 13 0 11 1;
#X connect 14 0 11 1;
#X connect 17 0 27 2;
#X connect 20 0 22 0;
#X connect 21 0 22 1;
#X connect 22 0 8 0;
#X connect 30 0 11 3;
#X connect 31 0 27 1;
#X connect 32 0 33 0;
#X connect 33 0 44 1;
#X connect 34 0 33 1;
#X connect 40 0 44 0;
#X connect 42 0 44 2;
#X connect 44 0 35 0;
#X connect 47 0 44 1;
