#N canvas 164 25 744 599 12;
#X floatatom 494 315 5 0 0 0 - transpo-set -;
#X floatatom 167 383 3 0 0 0 - speed-set -;
#X floatatom 55 385 7 0 0 0 - location-set -;
#N canvas 199 40 821 693 fft-analysis 0;
#X obj 51 477 *~;
#X obj 18 477 *~;
#X obj 18 499 -~;
#X obj 167 475 *~;
#X obj 136 475 *~;
#X obj 136 497 +~;
#X obj 109 193 *~;
#X obj 78 193 *~;
#X obj 50 193 *~;
#X obj 19 193 *~;
#X obj 19 218 +~;
#X obj 127 379 *~;
#X obj 20 622 *~;
#X obj 238 430 rfft~;
#X obj 108 161 rfft~;
#X obj 19 564 rifft~;
#X obj 21 646 outlet~;
#X obj 97 379 *~;
#X obj 97 401 +~;
#X obj 124 218 -~;
#X obj 18 431 *~;
#X obj 51 432 *~;
#X obj 127 622 r window-size;
#X obj 426 595 r window-size;
#X obj 426 644 block~;
#X obj 19 349 +~ 1e-15;
#X obj 19 598 *~;
#X obj 52 598 tabreceive~ \$0-hann;
#X obj 127 643 expr 2/(3*$f1);
#X obj 591 563 loadbang;
#X msg 591 589 \; pd dsp 1 \; window-size 2048 \; transpo 0 \; rewind
bang;
#X msg 426 619 set \$1 4;
#X obj 97 425 q8_rsqrt~;
#N canvas 139 105 1006 799 read-windows 0;
#X obj 18 693 *~;
#X obj 364 448 r window-size;
#X obj 156 300 f;
#X obj 102 91 r window-size;
#X obj 102 139 /;
#X obj 195 695 *~;
#X obj 156 255 bang~;
#X obj 17 551 line~;
#X obj 102 164 * 1000;
#X obj 288 224 r speed;
#X obj 178 276 r location;
#X obj 198 302 +;
#X obj 288 272 *;
#X obj 183 470 +;
#X obj 143 446 t f f;
#X msg 17 523 \$1 \, \$2 \$3;
#X obj 17 496 pack 0 0 0;
#X obj 178 371 / 1000;
#X obj 156 394 *;
#X text 188 394 reading location (samples);
#X obj 51 597 / 4;
#X obj 288 245 * 0.01;
#X floatatom 364 498 7 0 0 0 - - -;
#X obj 364 474 *;
#X obj 502 347 r transpo;
#X obj 502 369 * 0.01;
#X obj 504 390 + 69;
#X obj 505 411 mtof;
#X obj 505 433 / 440;
#X obj 399 474 t b f;
#X obj 19 719 outlet~;
#X obj 195 720 outlet~;
#X obj 218 664 tabreceive~ \$0-hann;
#X obj 803 386 r location;
#X msg 803 409 0;
#X obj 803 432 s speed;
#X obj 768 508 r speed;
#X msg 768 532 set \$1;
#X obj 768 557 s speed-set;
#X text 432 498 stretched window size (samples);
#X obj 877 507 r transpo;
#X msg 877 533 set \$1;
#X obj 877 558 s transpo-set;
#X obj 808 94 r location;
#X msg 826 278 set \$1;
#X obj 808 140 t b f;
#X obj 826 257 f;
#X obj 754 171 int;
#X obj 754 203 sel 0;
#X msg 813 174 1;
#X msg 813 197 0;
#X obj 754 228 del 300;
#X obj 826 302 s location-set;
#X obj 17 637 tabread4~ \$0-sample;
#X obj 194 637 tabread4~ \$0-sample;
#X obj 178 347 r \$0-insamprate;
#X obj 528 586 r rewind;
#X msg 528 744 \; location \$1;
#X floatatom 111 187 5 0 0 0 - - -;
#X obj 102 115 t f b;
#X obj 142 139 samplerate~;
#X obj 102 208 / 4;
#X obj 233 306 s see-loc;
#X obj 817 116 r see-loc;
#X obj 193 420 / 2;
#X obj 156 420 -;
#X text 229 417 back up 1/2 window;
#X obj 16 597 -~;
#X text 43 6 Read two windows out of the recorded sample \, one 1/4
ahead of the other. The mid point of the front window is specified
by "location". If "speed" is nonzero \, "location" automatically precesses.
;
#X obj 528 720 * -0.5;
#X text 91 587 "back" window 1/4 cycle behind "front" one;
#X text 137 205 computation period (msec) for overlap of 4;
#X text 164 186 msec in a window;
#X obj 528 666 /;
#X obj 528 691 * 1000;
#X obj 528 642 t f b;
#X obj 568 666 samplerate~;
#X obj 528 619 f;
#X msg 845 711 \; rewind bang \; speed \$1;
#X obj 845 684 r auto;
#X obj 730 685 r no-detune;
#X msg 730 707 \; detune 0;
#X text 321 280 loop to precess the location according;
#X text 320 296 to the "speed" parameter.;
#X text 611 31 if location changes \, update number box;
#X text 610 50 in main window via "location-set" \, but;
#X text 613 69 taking care to limit frequency of updates.;
#X text 756 462 reflect control changes;
#X text 756 479 in main window.;
#X text 754 344 setting location by hand;
#X text 752 362 sets speed to zero.;
#X text 760 653 misc controls;
#X text 496 527 "rewind" control takes us;
#X text 499 545 to a location depending on;
#X text 499 564 stretched window size.;
#X obj 593 457 t b f;
#X obj 617 395 samplerate~;
#X obj 593 348 r \$0-insamprate;
#X obj 593 418 /;
#X obj 505 455 * 1;
#X text 494 312 desired transposition and sample;
#X text 494 329 rate correction for soundfile;
#X obj 593 370 t f b;
#X connect 0 0 30 0;
#X connect 1 0 23 0;
#X connect 2 0 11 0;
#X connect 2 0 18 0;
#X connect 3 0 59 0;
#X connect 4 0 8 0;
#X connect 5 0 31 0;
#X connect 6 0 2 0;
#X connect 7 0 67 0;
#X connect 7 0 54 0;
#X connect 8 0 58 0;
#X connect 8 0 61 0;
#X connect 9 0 21 0;
#X connect 10 0 2 1;
#X connect 11 0 2 1;
#X connect 11 0 62 0;
#X connect 12 0 11 1;
#X connect 13 0 16 1;
#X connect 14 0 16 0;
#X connect 14 1 13 0;
#X connect 15 0 7 0;
#X connect 16 0 15 0;
#X connect 17 0 18 1;
#X connect 18 0 65 0;
#X connect 20 0 67 1;
#X connect 21 0 12 0;
#X connect 22 0 20 0;
#X connect 22 0 13 1;
#X connect 22 0 64 0;
#X connect 22 0 77 1;
#X connect 23 0 22 0;
#X connect 24 0 25 0;
#X connect 25 0 26 0;
#X connect 26 0 27 0;
#X connect 27 0 28 0;
#X connect 28 0 99 0;
#X connect 29 0 23 0;
#X connect 29 1 23 1;
#X connect 32 0 5 1;
#X connect 32 0 0 1;
#X connect 33 0 34 0;
#X connect 34 0 35 0;
#X connect 36 0 37 0;
#X connect 37 0 38 0;
#X connect 40 0 41 0;
#X connect 41 0 42 0;
#X connect 43 0 45 0;
#X connect 44 0 52 0;
#X connect 45 0 47 0;
#X connect 45 1 46 1;
#X connect 46 0 44 0;
#X connect 47 0 48 0;
#X connect 48 0 49 0;
#X connect 48 0 51 0;
#X connect 49 0 47 1;
#X connect 50 0 47 1;
#X connect 51 0 50 0;
#X connect 51 0 46 0;
#X connect 53 0 0 0;
#X connect 54 0 5 0;
#X connect 55 0 17 0;
#X connect 56 0 77 0;
#X connect 59 0 4 0;
#X connect 59 1 60 0;
#X connect 60 0 4 1;
#X connect 61 0 16 2;
#X connect 61 0 12 1;
#X connect 63 0 45 0;
#X connect 64 0 65 1;
#X connect 65 0 14 0;
#X connect 67 0 53 0;
#X connect 69 0 57 0;
#X connect 73 0 74 0;
#X connect 74 0 69 0;
#X connect 75 0 73 0;
#X connect 75 1 76 0;
#X connect 76 0 73 1;
#X connect 77 0 75 0;
#X connect 79 0 78 0;
#X connect 80 0 81 0;
#X connect 95 0 99 0;
#X connect 95 1 99 1;
#X connect 96 0 98 1;
#X connect 97 0 102 0;
#X connect 98 0 95 0;
#X connect 99 0 29 0;
#X connect 102 0 98 0;
#X connect 102 1 96 0;
#X restore 109 133 pd read-windows;
#X obj 137 543 tabsend~ prev-imag;
#X obj 136 567 tabsend~ prev-real;
#X obj 20 8 tabreceive~ prev-real;
#X obj 73 29 tabreceive~ prev-imag;
#X text 272 5 recall previous output amplitude. Its phase will be added
to the phase difference we measure from two windows in the the recorded
sound.;
#X obj 121 69 *~;
#X obj 89 69 *~;
#X obj 89 91 +~;
#X obj 159 94 q8_rsqrt~;
#X obj 159 71 +~ 1e-20;
#X obj 73 119 *~;
#X obj 19 118 *~;
#X obj 181 290 r lock;
#X obj 29 245 lrshift~ 1;
#X obj 24 269 lrshift~ -1;
#X obj 141 245 lrshift~ 1;
#X obj 133 269 lrshift~ -1;
#X obj 35 300 *~;
#X obj 159 312 *~;
#X obj 19 325 +~;
#X obj 125 331 +~;
#X text 247 66 divide by the magnitude to make a unit-magnitude complex
amplitude (phase only). The 1e-20 is to prevent overflows. q8_rsqrt~
is reciprocal square root.;
#X text 247 165 Take FT of the window in back. Multiply its conjugate
by the normalized previous output. The result has the magnitude of
the input sound and phase (previous output phase) minus (back window
phase).;
#X text 249 370 Normalize again \, this time taking care to salt each
channel with 1e-15 so that we get a unit complex number even if everything
was zero heretofore.;
#X text 288 427 Now take the FT of the forward window and multiply
it by the unit complex number from above. The magnitude will be that
of the forward window and the phase will be the previous output phase
plus the phase difference between the two analysis windows -- except
that if "lock" is on \, they will be modified to agree progressively
better with the inter-channel phase relationships of the input.;
#X text 249 242 If "lock" is on \, encourage neighboring channels to
stay in phase by adding the two neighboring complex amplitudes. The
result will tend toward the channel with the strongest amplitude. If
the phase relationships between channels in the output and those in
the input are in parallel \, then neighboring channels of the quotient
will all have the same phase and this will not change any phases. (lrshift
shifts the signal to the left or right depending on its argument.)
;
#X text 387 560 'set' message to block;
#X text 390 577 allows variable size;
#X text 259 126 Read two windows \, one 1/4 length behind the other
\, of the input sound \, with Hann window function (see inside).;
#X connect 0 0 2 1;
#X connect 1 0 2 0;
#X connect 2 0 35 0;
#X connect 2 0 15 0;
#X connect 3 0 5 1;
#X connect 4 0 5 0;
#X connect 5 0 34 0;
#X connect 5 0 15 1;
#X connect 6 0 19 1;
#X connect 7 0 19 0;
#X connect 8 0 10 1;
#X connect 9 0 10 0;
#X connect 10 0 48 0;
#X connect 10 0 47 0;
#X connect 10 0 53 0;
#X connect 11 0 18 1;
#X connect 12 0 16 0;
#X connect 13 0 1 1;
#X connect 13 0 3 1;
#X connect 13 1 0 1;
#X connect 13 1 4 1;
#X connect 14 0 9 1;
#X connect 14 0 7 1;
#X connect 14 1 6 1;
#X connect 14 1 8 1;
#X connect 15 0 26 0;
#X connect 17 0 18 0;
#X connect 18 0 32 0;
#X connect 19 0 49 0;
#X connect 19 0 50 0;
#X connect 19 0 54 0;
#X connect 20 0 1 0;
#X connect 20 0 4 0;
#X connect 21 0 0 0;
#X connect 21 0 3 0;
#X connect 22 0 28 0;
#X connect 23 0 31 0;
#X connect 25 0 17 1;
#X connect 25 0 17 0;
#X connect 25 0 20 0;
#X connect 26 0 12 0;
#X connect 27 0 26 1;
#X connect 28 0 12 1;
#X connect 29 0 30 0;
#X connect 31 0 24 0;
#X connect 32 0 20 1;
#X connect 32 0 21 1;
#X connect 33 0 14 0;
#X connect 33 1 13 0;
#X connect 36 0 40 1;
#X connect 36 0 40 0;
#X connect 36 0 45 0;
#X connect 37 0 39 1;
#X connect 37 0 39 0;
#X connect 37 0 44 0;
#X connect 39 0 41 1;
#X connect 40 0 41 0;
#X connect 41 0 43 0;
#X connect 42 0 44 1;
#X connect 42 0 45 1;
#X connect 43 0 42 0;
#X connect 44 0 8 0;
#X connect 44 0 7 0;
#X connect 45 0 9 0;
#X connect 45 0 6 0;
#X connect 46 0 51 1;
#X connect 46 0 52 1;
#X connect 47 0 51 0;
#X connect 48 0 51 0;
#X connect 49 0 52 0;
#X connect 50 0 52 0;
#X connect 51 0 53 1;
#X connect 52 0 54 1;
#X connect 53 0 25 0;
#X connect 54 0 11 0;
#X connect 54 0 11 1;
#X connect 54 0 21 0;
#X restore 55 480 pd fft-analysis;
#N canvas 260 23 647 768 phase-tables 0;
#N canvas 0 0 450 300 (subpatch) 0;
#X array prev-imag 4096 float 0;
#X coords 0 1000 4096 -1000 400 300 1;
#X restore 169 326 graph;
#N canvas 0 0 450 300 (subpatch) 0;
#X array prev-real 4096 float 0;
#X coords 0 500 4096 -500 400 300 1;
#X restore 170 17 graph;
#X restore 440 504 pd phase-tables;
#X obj 494 338 s transpo;
#X text 164 364 hundredths;
#X text 493 294 in cents;
#X text 389 359 normal;
#X obj 56 517 output~;
#N canvas 0 110 565 454 hann-window 0;
#N canvas 0 0 450 300 (subpatch) 0;
#X array \$0-hann 4096 float 0;
#X coords 0 1 4095 0 300 100 1;
#X restore 82 311 graph;
#X obj 378 165 osc~;
#X obj 378 190 *~ -0.5;
#X obj 378 214 +~ 0.5;
#X obj 331 247 tabwrite~ \$0-hann;
#X obj 37 88 r window-size;
#X obj 38 173 /;
#X obj 127 142 samplerate~;
#X obj 38 251 s window-sec;
#X obj 177 204 swap;
#X obj 177 228 /;
#X obj 177 252 s window-hz;
#X obj 49 201 * 1000;
#X obj 49 228 s window-msec;
#X obj 38 115 t f b f;
#X msg 173 92 resize \$1;
#X obj 173 116 s \$0-hann;
#X obj 330 105 r window-hz;
#X msg 382 130 0;
#X obj 330 131 t f b;
#X text 15 8 calculate Hann window table (variable window size) and
constants window-hz (fundamental frequency of analysis) \, window-sec
and window-msec (analysis window size in seconds and msec).;
#X connect 1 0 2 0;
#X connect 2 0 3 0;
#X connect 3 0 4 0;
#X connect 5 0 14 0;
#X connect 6 0 8 0;
#X connect 6 0 12 0;
#X connect 7 0 6 1;
#X connect 7 0 9 1;
#X connect 9 0 10 0;
#X connect 9 1 10 1;
#X connect 10 0 11 0;
#X connect 12 0 13 0;
#X connect 14 0 6 0;
#X connect 14 0 9 0;
#X connect 14 1 7 0;
#X connect 14 2 15 0;
#X connect 15 0 16 0;
#X connect 17 0 19 0;
#X connect 18 0 1 1;
#X connect 19 0 1 0;
#X connect 19 1 4 0;
#X connect 19 1 18 0;
#X restore 440 528 pd hann-window;
#N canvas 388 86 694 447 insample 0;
#N canvas 0 0 450 300 (subpatch) 0;
#X array \$0-sample 82301 float 0;
#X coords 0 1 82300 -1 400 150 1;
#X restore 281 135 graph;
#X obj 28 133 r read-sample;
#X obj 28 184 unpack s f;
#X obj 28 294 soundfiler;
#X text 365 360 read a sample;
#X obj 285 359 loadbang;
#X obj 28 210 t s b;
#X obj 84 209 symbol \$0-sample;
#X obj 28 245 pack s s;
#X msg 28 270 read -resize \$1 \$2;
#X obj 83 156 44100;
#X obj 28 157 t a b;
#X obj 38 318 s \$0-samplength;
#X obj 125 184 s \$0-insamprate;
#X obj 28 357 /;
#X obj 28 381 * 1000;
#X obj 28 404 s \$0-samp-msec;
#X obj 66 357 r \$0-insamprate;
#X obj 37 68 hip~ 5;
#X obj 37 44 adc~ 1;
#X obj 29 9 inlet;
#X obj 99 44 samplerate~;
#X obj 29 93 tabwrite~ \$0-sample;
#X obj 99 68 s \$0-insamprate;
#X msg 285 383 \; read-sample ../sound/voice.wav;
#X obj 276 20 inlet;
#X obj 276 42 openpanel;
#X obj 276 67 s read-sample;
#X connect 1 0 11 0;
#X connect 2 0 6 0;
#X connect 2 1 13 0;
#X connect 3 0 12 0;
#X connect 3 0 14 0;
#X connect 5 0 24 0;
#X connect 6 0 8 0;
#X connect 6 1 7 0;
#X connect 7 0 8 1;
#X connect 8 0 9 0;
#X connect 9 0 3 0;
#X connect 10 0 13 0;
#X connect 11 0 2 0;
#X connect 11 1 10 0;
#X connect 14 0 15 0;
#X connect 15 0 16 0;
#X connect 17 0 14 1;
#X connect 18 0 22 0;
#X connect 19 0 18 0;
#X connect 20 0 21 0;
#X connect 20 0 22 0;
#X connect 21 0 23 0;
#X connect 25 0 26 0;
#X connect 26 0 27 0;
#X restore 441 480 pd insample;
#X floatatom 552 480 5 0 0 0 - #0-samp-msec -;
#X msg 229 486 ../sound/bell.aiff;
#X msg 229 511 ../sound/voice.wav;
#X msg 229 536 ../sound/voice2.wav;
#X obj 229 562 s read-sample;
#X obj 441 439 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
-1;
#X text 460 438 <- record;
#X obj 493 387 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
1;
#X obj 55 407 s location;
#X obj 167 407 s speed;
#X obj 262 386 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
-1;
#X obj 262 408 s rewind;
#X msg 345 336 200;
#X msg 345 358 100;
#X text 386 335 contract;
#X text 390 380 expand;
#X obj 493 407 s lock;
#X text 494 277 detune;
#X text 55 330 location;
#X text 52 346 (stops;
#X text 57 361 motion);
#X text 165 348 motion in;
#X text 232 464 read input sound;
#X text 103 7 PHASE VOCODER FOR TIME STETCHING AND CONTRACTION;
#X text 604 479 length \, msec;
#X floatatom 607 419 5 0 0 0 - window-size -;
#X msg 607 307 512;
#X msg 607 329 1024;
#X msg 607 351 2048;
#X msg 607 373 4096;
#X obj 607 395 s window-size;
#X text 607 274 window size \,;
#X text 607 289 samples;
#X text 648 306 <- set;
#X text 100 306 ------- location controls -------;
#X text 660 419 (check);
#X obj 345 407 s auto;
#X text 23 35 This patch takes a sound \, analyzes windows in it both
for channel magnitude and for phase precession in each channel (compared
to another operlapping window). The real-time output recreates the
same magnitudes and phase precession \, althought the phases themselves
are in general different. You can control either the location or its
motion (setting location stops motion \, while setting a non-zero motion
causes the location to change automatically). "Rewind" goes back to
the beginning. You can use different window sizes (use the message
boxes - the number box is for readout). The "lock" feature forces phase
coherency between neighboring channels \, which makes a more present
sound but can add artifacts to the sound. Look in "pd fft-analysis"
to see the workings.;
#X text 483 568 updated for Pd version 0.39;
#X obj 551 316 bng 15 250 50 0 no-detune empty empty 0 -6 0 8 -262144
-1 -1;
#X obj 535 460 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
-1;
#X text 466 458 file ->;
#X msg 345 380 20;
#X connect 0 0 5 0;
#X connect 1 0 21 0;
#X connect 2 0 20 0;
#X connect 3 0 9 0;
#X connect 3 0 9 1;
#X connect 13 0 16 0;
#X connect 14 0 16 0;
#X connect 15 0 16 0;
#X connect 17 0 11 0;
#X connect 19 0 28 0;
#X connect 22 0 23 0;
#X connect 24 0 48 0;
#X connect 25 0 48 0;
#X connect 38 0 42 0;
#X connect 39 0 42 0;
#X connect 40 0 42 0;
#X connect 41 0 42 0;
#X connect 52 0 11 1;
#X connect 54 0 48 0;
