#N canvas 626 40 736 636 12;
#X declare -stdpath ./;
#N canvas 150 378 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 528 107 bng 20 250 50 0 empty empty 2nd 28 10 0 20 #dfdfdf #000000 #000000;
#X text 511 583 updated for Pd version 0.53-1;
#X obj 329 497 output~;
#X text 347 76 record live input;
#X text 359 117 or even...;
#X text 384 152 sample;
#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 190 284 835 269 sample 0;
#N canvas 0 50 450 300 (subpatch) 0;
#X array sample2 155944 float 2;
#X coords 0 1 155944 -1 453 90 1 0 0;
#X restore 350 68 graph;
#X obj 176 114 r resize-sample;
#X obj 21 130 r insamplength;
#X obj 26 17 inlet;
#X obj 63 160 r window-size;
#X obj 21 158 -;
#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~ sample2;
#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 232 315 284 293 load 0;
#X obj 55 34 inlet;
#X obj 165 252 s insamprate;
#X obj 55 226 soundfiler;
#X obj 55 252 s insamplength;
#X msg 165 226 \$1;
#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 msg 55 195 read -resize \$1 sample2;
#X connect 0 0 9 0;
#X connect 0 0 5 0;
#X connect 2 0 3 0;
#X connect 2 1 4 0;
#X connect 4 0 1 0;
#X connect 6 0 8 0;
#X connect 7 0 9 0;
#X connect 7 0 5 0;
#X connect 8 0 7 0;
#X connect 9 0 2 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 msg 308 148 0 \, 1 100 \, 0 2250 250;
#X obj 199 365 tabwrite~ sample2;
#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 12 0;
#X connect 5 0 10 0;
#X connect 5 0 11 0;
#X connect 5 0 9 0;
#X connect 5 0 12 0;
#X connect 6 0 1 1;
#X connect 7 0 4 1;
#X connect 10 0 6 0;
#X connect 11 0 7 0;
#X restore 216 66 pd synthesis;
#X msg 176 173 \; sample2 resize \$1 \; insamplength \$1;
#X obj 21 193 s sample-size;
#X obj 176 144 * 44.1;
#X connect 1 0 14 0;
#X connect 2 0 5 0;
#X connect 3 0 10 0;
#X connect 4 0 5 1;
#X connect 5 0 13 0;
#X connect 7 0 10 1;
#X connect 8 0 6 0;
#X connect 9 0 11 0;
#X connect 14 0 12 0;
#X coords 0 -1 1 1 453 108 2 350 50;
#X restore 22 176 pd sample;
#X text 359 136 synthesize -->;
#X msg 186 151 voice2.wav;
#X msg 179 128 voice.wav;
#X msg 170 105 bell.aiff;
#X text 360 93 (3 seconds);
#X text 112 126 choose:;
#X text 12 50 browse:;
#X text 91 75 - browse/choose soundfile or ->;
#X text 596 107 - analyze;
#X floatatom 602 182 4 1 50 1 nvoice nvoice-set - 16;
#X text 591 148 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 text 301 41 This subpatch cretaes tracks manually or randomly;
#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 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 21 0;
#X connect 7 0 3 0;
#X connect 9 0 1 0;
#X connect 9 0 8 1;
#X connect 9 0 47 1;
#X connect 13 0 20 0;
#X connect 13 1 19 0;
#X connect 14 0 4 0;
#X connect 16 0 1 0;
#X connect 17 0 8 0;
#X connect 18 0 9 0;
#X connect 22 0 11 0;
#X connect 23 0 12 0;
#X connect 24 0 45 2;
#X connect 25 0 24 0;
#X connect 26 0 27 0;
#X connect 27 0 35 0;
#X connect 27 1 28 0;
#X connect 28 0 29 0;
#X connect 29 0 30 0;
#X connect 30 0 45 1;
#X connect 31 0 45 0;
#X connect 32 0 0 0;
#X connect 33 0 25 0;
#X connect 35 0 36 0;
#X connect 36 0 31 0;
#X connect 37 0 44 1;
#X connect 38 0 40 0;
#X connect 39 0 40 1;
#X connect 40 0 41 0;
#X connect 40 0 43 0;
#X connect 41 0 40 1;
#X connect 42 0 38 0;
#X connect 43 0 50 0;
#X connect 43 1 37 0;
#X connect 45 0 49 0;
#X connect 46 0 47 0;
#X connect 49 0 42 0;
#X connect 49 1 32 0;
#X connect 49 1 39 0;
#X connect 49 2 0 1;
#X connect 49 2 37 1;
#X connect 50 0 51 0;
#X connect 51 0 44 0;
#X restore 364 594 pd make-trace;
#X obj 329 430 bng 19 250 50 0 empty empty empty 0 -10 0 12 #dfdfdf #000000 #000000;
#X obj 403 430 tgl 19 0 empty empty empty 0 -10 0 12 #dfdfdf #000000 #000000 0 1;
#N canvas 661 173 376 340 original 0;
#X obj 68 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 68 106 inlet;
#X obj 216 106 inlet;
#X floatatom 216 137 5 0 0 0 - - - 0;
#X text 230 178 looping.;
#X text 57 54 This subpatch plays the orignal sample.;
#X obj 68 149 tabplay~ sample2;
#X connect 1 0 8 0;
#X connect 2 0 1 0;
#X connect 3 0 8 0;
#X connect 4 0 5 0;
#X connect 5 0 2 1;
#X connect 8 0 0 0;
#X connect 8 1 2 0;
#X restore 329 461 pd original;
#X text 400 502 play original sample., f 8;
#X text 426 430 Loop;
#X text 352 430 play;
#X text 176 575 You can also create partial traces manually or randomly here:, f 34;
#N canvas 402 41 720 653 analysis 0;
#X obj 38 34 inlet;
#X msg 123 167 0;
#X floatatom 163 168 4 0 0 0 - - - 0;
#X obj 105 198 f;
#X obj 145 197 +;
#X floatatom 105 231 8 0 0 0 - - - 0;
#X obj 38 70 t b b;
#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 obj 57 244 s nframe;
#X msg 108 160 traverse pd-trace-list \, bang;
#X msg 57 214 0;
#X obj 108 52 inlet;
#X msg 169 78 \; tgl 0 \; vis 0 \; pd-trace-list clear \; add-trace-clear bang \;;
#X connect 0 0 1 0;
#X connect 2 0 4 0;
#X connect 2 0 5 0;
#X connect 2 1 7 0;
#X connect 4 0 0 0;
#X connect 5 0 3 0;
#X connect 6 0 2 0;
#X restore 135 109 pd clear;
#X obj 135 34 inlet;
#X obj 105 259 moses;
#X obj 38 337 until;
#X obj 85 305 b;
#X obj 333 588 clone add-trace 50;
#X obj 482 570 spigot;
#X obj 521 539 tgl 19 0 empty empty empty 0 -6 0 8 #dfdfdf #000000 #000000 0 1;
#X obj 206 358 s start-analysis;
#X msg 333 259 npeak \$1;
#X obj 171 474 r nframe;
#X obj 153 506 f;
#X obj 153 530 + 1;
#X obj 153 562 s nframe;
#X obj 333 515 sigmund~ -t -npeak 50 -maxfreq 8000 tracks, f 21;
#X text 543 538 print tracks;
#X msg 85 502 \; vis 1;
#X obj 333 31 inlet;
#X obj 482 596 print tracks;
#X obj 451 239 loadbang;
#X obj 460 364 declare -stdpath ./;
#X text 518 238 initialization;
#X text 372 78 This subpatch analysizes the sample with [sigmund~] and outputs 'tracks' information. Open [clone add-trace] for more details., f 36;
#X obj 163 144 r hop;
#X obj 161 260 r sample-size;
#X obj 180 198 / 44.1;
#X obj 180 223 s osc-speed-set;
#X obj 204 390 r window-size;
#X obj 179 433 pack;
#X obj 153 318 t b f b, f 8;
#X msg 348 483 list sample2 \$2 \$1 44100 0;
#X msg 451 274 \; pd-trace-list clear \; nvoice-set 25 \; window-size 2048 \; hop 512;
#X floatatom 161 284 8 0 0 0 - - - 0;
#X text 372 146 Note that sample rate for this patch is fixed at 44100 So run Pd at this rate and load files with this same rate., f 36;
#X floatatom 333 227 5 0 0 0 - - - 0;
#X obj 215 512 array define reset 2048;
#X f 12;
#X msg 343 454 list reset 2048 0 44100 0;
#X obj 85 378 t b b b b;
#X connect 0 0 6 0;
#X connect 1 0 3 1;
#X connect 2 0 4 1;
#X connect 2 0 32 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 0;
#X connect 9 0 36 0;
#X connect 9 1 11 0;
#X connect 10 0 3 0;
#X connect 11 0 10 1;
#X connect 11 0 44 0;
#X connect 13 0 25 0;
#X connect 14 0 13 1;
#X connect 16 0 21 0;
#X connect 17 0 18 1;
#X connect 18 0 19 0;
#X connect 19 0 20 0;
#X connect 21 0 13 0;
#X connect 21 0 12 0;
#X connect 24 0 41 0;
#X connect 26 0 38 0;
#X connect 30 0 2 0;
#X connect 31 0 9 1;
#X connect 31 0 39 0;
#X connect 32 0 33 0;
#X connect 34 0 35 1;
#X connect 35 0 37 0;
#X connect 36 0 18 0;
#X connect 36 1 35 0;
#X connect 36 2 15 0;
#X connect 37 0 21 0;
#X connect 41 0 16 0;
#X connect 43 0 21 0;
#X connect 44 0 23 0;
#X connect 44 1 18 0;
#X connect 44 2 43 0;
#X connect 44 3 15 0;
#X restore 528 228 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 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 beggining of the sample when done., f 91;
#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 136 bng 20 250 50 0 empty empty empty 17 7 0 10 #dfdfdf #000000 #000000;
#X obj 565 147 bng 20 250 50 0 empty empty empty 17 7 0 10 #dfdfdf #000000 #000000;
#X obj 145 431 tgl 19 0 empty empty empty -44 12 0 16 #dfdfdf #000000 #000000 0 1;
#X obj 145 462 metro;
#X obj 117 462 bng 19 250 50 0 empty empty empty 30 12 0 16 #dfdfdf #000000 #000000;
#X obj 177 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 70 564 output~;
#X text 79 464 Step;
#X text 26 487 Start;
#X text 108 431 Auto;
#X text 249 432 Rate;
#X obj 70 493 tgl 19 0 empty tgl empty 0 -10 0 12 #dfdfdf #000000 #000000 0 1;
#X text 33 503 Stop;
#X obj 165 493 tgl 19 0 empty empty empty 0 -10 0 12 #dfdfdf #000000 #000000 0 1;
#X text 188 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 70 527 pd resynthesis;
#X connect 6 0 15 2;
#X connect 7 0 35 0;
#X connect 13 0 15 0;
#X connect 14 0 13 0;
#X connect 17 0 15 1;
#X connect 18 0 15 1;
#X connect 19 0 15 1;
#X connect 25 0 35 2;
#X connect 28 0 30 0;
#X connect 29 0 30 1;
#X connect 30 0 9 0;
#X connect 30 0 9 1;
#X connect 39 0 15 3;
#X connect 40 0 35 1;
#X connect 41 0 42 0;
#X connect 42 0 54 1;
#X connect 43 0 54 1;
#X connect 44 0 42 1;
#X connect 50 0 54 0;
#X connect 52 0 54 2;
#X connect 54 0 45 0;
#X connect 54 0 45 1;
