#N canvas 442 172 1028 827 10;
#X obj 22 65 inlet~;
#N canvas 680 234 821 693 fft-analysis 0;
#X obj 49 526 *~;
#X obj 16 526 *~;
#X obj 16 548 -~;
#X obj 165 524 *~;
#X obj 134 524 *~;
#X obj 134 546 +~;
#X obj 109 193 *~;
#X obj 78 193 *~;
#X obj 50 193 *~;
#X obj 19 193 *~;
#X obj 19 218 +~;
#X obj 76 393 *~;
#X obj 18 671 *~;
#X obj 166 473 rfft~;
#X obj 108 161 rfft~;
#X obj 17 613 rifft~;
#X obj 20 730 outlet~;
#X obj 46 393 *~;
#X obj 46 415 +~;
#X obj 116 229 -~;
#X obj 19 476 *~;
#X obj 52 477 *~;
#X obj 366 669 block~;
#X obj 21 364 +~ 1e-015;
#X obj 17 647 *~;
#X obj 50 647 tabreceive~ \$0-hann;
#X obj 124 698 expr 2/(3*$f1);
#X obj 44 440 q8_rsqrt~;
#N canvas 659 155 1006 754 read-windows 0;
#X obj 33 665 *~;
#X obj 248 682 *~;
#X obj 36 696 outlet~;
#X obj 248 707 outlet~;
#X obj 266 622 tabreceive~ \$0-hann;
#X obj 270 133 r \$0-transpo;
#X obj 107 246 bang~;
#X obj 38 291 phasor~;
#X msg 108 271 0;
#X obj 40 458 vd~ \$0-del;
#X obj 42 346 *~;
#X obj 25 202 r \$0-freq;
#X obj 25 229 * 4;
#X obj 34 630 z~;
#X obj 52 556 r \$0-window-size;
#X obj 52 582 / 4;
#X obj 271 157 expr pow(2 \, $f1/12);
#X obj 278 228 - 1;
#X obj 316 188 r \$0-window-size;
#X obj 315 213 / 44.1;
#X obj 290 268 *;
#X obj 314 240 t b f;
#X obj 290 290 / 4;
#X text 417 160 factor for modulating the delay line;
#X obj 180 376 tabread4~ \$0-table;
#X obj 197 259 *;
#X obj 198 227 t b f;
#X obj 185 176 loadbang;
#X msg 186 201 1;
#X obj 180 314 *~;
#X obj 194 589 *~;
#X obj 252 430 r \$0-freeze;
#X obj 248 489 != 0;
#X obj 136 502 line~;
#X obj 214 400 tabread4~ \$0-table;
#X obj 249 594 *~;
#X obj 209 287 / 4;
#X text 62 629 1/4 window behind;
#X obj 37 427 clip~ 0 250;
#X obj 41 489 *~;
#X obj 134 447 == 0;
#X obj 249 539 line~;
#X obj 134 473 pack;
#X obj 248 512 pack;
#X obj 91 581 / 44.1;
#X obj 251 461 pipe;
#X text 291 512 cross-fade live-input and frozen sound;
#X obj 26 264 *;
#X obj 41 396 +~ 1;
#X obj 114 177 moses 0;
#X obj 59 239 t b f;
#X obj 92 332 abs;
#X msg 114 207 1;
#X msg 149 216 -1;
#X obj 191 145 sel 1 0;
#X obj 292 460 / 44.1;
#X obj 118 151 spigot;
#X obj 156 122 == 0;
#X obj 248 94 t f f;
#X text 39 48 phasor~ running from 0 to 1 (or backwards) for each window
\, modulating a delay line depending on window size and transposition
factor.;
#X text 344 483 (table is filled in sync with second tabread4~ object)
;
#X text 348 381 1/4 scaled window ahead;
#X text 347 460 delay by 1/4 scaled window);
#X connect 0 0 2 0;
#X connect 1 0 3 0;
#X connect 4 0 1 1;
#X connect 4 0 0 1;
#X connect 5 0 16 0;
#X connect 6 0 8 0;
#X connect 7 0 29 0;
#X connect 7 0 10 0;
#X connect 8 0 7 1;
#X connect 9 0 39 0;
#X connect 10 0 48 0;
#X connect 11 0 12 0;
#X connect 12 0 47 0;
#X connect 13 0 0 0;
#X connect 14 0 15 0;
#X connect 14 0 44 0;
#X connect 15 0 13 1;
#X connect 16 0 17 0;
#X connect 16 0 25 0;
#X connect 17 0 20 0;
#X connect 17 0 56 0;
#X connect 18 0 19 0;
#X connect 18 0 26 0;
#X connect 19 0 21 0;
#X connect 20 0 22 0;
#X connect 21 0 20 0;
#X connect 21 1 20 1;
#X connect 22 0 51 0;
#X connect 24 0 30 0;
#X connect 25 0 29 1;
#X connect 25 0 36 0;
#X connect 26 0 25 0;
#X connect 26 1 25 1;
#X connect 27 0 28 0;
#X connect 28 0 25 0;
#X connect 29 0 24 0;
#X connect 29 0 34 0;
#X connect 30 0 0 0;
#X connect 31 0 45 0;
#X connect 32 0 43 0;
#X connect 33 0 39 1;
#X connect 34 0 35 0;
#X connect 35 0 1 0;
#X connect 36 0 34 1;
#X connect 36 0 55 0;
#X connect 38 0 9 0;
#X connect 39 0 13 0;
#X connect 39 0 1 0;
#X connect 40 0 42 0;
#X connect 41 0 30 1;
#X connect 41 0 35 1;
#X connect 42 0 33 0;
#X connect 43 0 41 0;
#X connect 44 0 43 1;
#X connect 44 0 42 1;
#X connect 45 0 40 0;
#X connect 45 0 32 0;
#X connect 45 0 58 0;
#X connect 47 0 7 0;
#X connect 48 0 38 0;
#X connect 49 0 52 0;
#X connect 49 1 53 0;
#X connect 50 0 47 0;
#X connect 50 1 47 1;
#X connect 51 0 10 1;
#X connect 52 0 50 0;
#X connect 53 0 50 0;
#X connect 54 0 52 0;
#X connect 54 1 17 0;
#X connect 55 0 45 1;
#X connect 56 0 49 0;
#X connect 57 0 56 1;
#X connect 58 0 54 0;
#X connect 58 1 57 0;
#X restore 109 133 pd read-windows;
#X text 255 13 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-020;
#X obj 73 119 *~;
#X obj 19 118 *~;
#X obj 29 245 lrshift~ 1;
#X obj 24 269 lrshift~ -1;
#X obj 133 256 lrshift~ 1;
#X obj 125 280 lrshift~ -1;
#X obj 35 300 *~;
#X obj 150 331 *~;
#X obj 19 325 +~;
#X obj 119 357 +~;
#X text 247 66 divide by the magnitude to make a unit-magnitude complex
amplitude (phase only). The 1e-020 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 250 367 Normalize again \, this time taking care to salt each
channel with 1e-015 so that we get a unit complex number even if everything
was zero heretofore.;
#X text 289 450 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 245 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 325 580 'set' message to block;
#X text 329 596 allows variable size;
#X text 245 124 Read two windows \, one 1/4 length behind the other
\, of the input sound \, with Hann window function (see inside).;
#X obj 20 8 tabreceive~ \$0-prev-real;
#X obj 73 29 tabreceive~ \$0-prev-imag;
#X obj 135 592 tabsend~ \$0-prev-imag;
#X obj 134 615 tabsend~ \$0-prev-real;
#X obj 366 620 r \$0-window-size;
#X obj 172 303 r \$0-lock;
#X obj 125 671 r \$0-window-size;
#X obj 21 -20 inlet~;
#X text 75 -18 dummy inlet;
#X msg 366 644 set \$1 4 1;
#X connect 0 0 2 1;
#X connect 1 0 2 0;
#X connect 2 0 56 0;
#X connect 2 0 15 0;
#X connect 3 0 5 1;
#X connect 4 0 5 0;
#X connect 5 0 55 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 38 0;
#X connect 10 0 37 0;
#X connect 10 0 43 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 24 0;
#X connect 17 0 18 0;
#X connect 18 0 27 0;
#X connect 19 0 39 0;
#X connect 19 0 40 0;
#X connect 19 0 44 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 23 0 17 1;
#X connect 23 0 17 0;
#X connect 23 0 20 0;
#X connect 24 0 12 0;
#X connect 25 0 24 1;
#X connect 26 0 12 1;
#X connect 27 0 20 1;
#X connect 27 0 21 1;
#X connect 28 0 14 0;
#X connect 28 1 13 0;
#X connect 30 0 32 1;
#X connect 31 0 32 0;
#X connect 32 0 34 0;
#X connect 33 0 35 1;
#X connect 33 0 36 1;
#X connect 34 0 33 0;
#X connect 35 0 8 0;
#X connect 35 0 7 0;
#X connect 36 0 9 0;
#X connect 36 0 6 0;
#X connect 37 0 41 0;
#X connect 38 0 41 0;
#X connect 39 0 42 0;
#X connect 40 0 42 0;
#X connect 41 0 43 1;
#X connect 42 0 44 1;
#X connect 43 0 23 0;
#X connect 44 0 11 0;
#X connect 44 0 11 1;
#X connect 44 0 21 0;
#X connect 53 0 31 1;
#X connect 53 0 31 0;
#X connect 53 0 36 0;
#X connect 54 0 30 1;
#X connect 54 0 30 0;
#X connect 54 0 35 0;
#X connect 57 0 62 0;
#X connect 58 0 41 1;
#X connect 58 0 42 1;
#X connect 59 0 26 0;
#X connect 62 0 22 0;
#X restore 23 156 pd fft-analysis;
#N canvas 663 129 565 454 hann-window 0;
#N canvas 0 50 450 300 (subpatch) 0;
#X array \$0-hann 1024 float 0;
#X coords 0 1 1023 0 300 100 1;
#X restore 243 330 graph;
#X obj 85 255 osc~;
#X obj 85 280 *~ -0.5;
#X obj 85 304 +~ 0.5;
#X obj 38 337 tabwrite~ \$0-hann;
#X msg 108 115 resize \$1;
#X obj 108 139 s \$0-hann;
#X msg 89 220 0;
#X obj 37 221 t f b;
#X obj 36 88 r \$0-window-size;
#X obj 37 162 samplerate~;
#X obj 38 114 t b f f;
#X obj 38 188 /;
#X obj 156 224 s \$0-freq;
#X text 34 56 calculate Hann window table (variable window size);
#X connect 1 0 2 0;
#X connect 2 0 3 0;
#X connect 3 0 4 0;
#X connect 5 0 6 0;
#X connect 7 0 1 1;
#X connect 8 0 1 0;
#X connect 8 1 4 0;
#X connect 8 1 7 0;
#X connect 9 0 11 0;
#X connect 10 0 12 0;
#X connect 11 0 10 0;
#X connect 11 1 12 1;
#X connect 11 2 5 0;
#X connect 12 0 8 0;
#X connect 12 0 13 0;
#X restore 545 68 pd hann-window;
#N canvas 260 50 647 768 phase-tables 0;
#N canvas 0 50 450 300 (subpatch) 0;
#X array \$0-prev-imag 4096 float 0;
#X coords 0 1000 4096 -1000 400 300 1;
#X restore 169 326 graph;
#N canvas 0 50 450 300 (subpatch) 0;
#X array \$0-prev-real 4096 float 0;
#X coords 0 500 4096 -500 400 300 1;
#X restore 170 17 graph;
#X restore 545 97 pd phase-tables;
#X obj 524 235 s \$0-window-size;
#X obj 103 82 s \$0-transpo;
#X obj 151 183 s \$0-lock;
#X obj 106 23 inlet;
#X obj 150 155 clip 0 1;
#X obj 750 247 print ERROR;
#X obj 446 98 sel 0;
#X msg 429 121 1024;
#X obj 333 0 loadbang;
#X obj 22 218 outlet~;
#X text 57 434 messages:;
#X text 57 322 arguments:;
#X text 56 371 inlets:;
#X msg 750 221 unvalid window size!;
#X obj 443 68 \$1;
#N canvas 1122 307 450 550 delay-line 0;
#X obj 24 133 inlet~;
#X obj -5 330 outlet~;
#X obj 147 127 r \$0-freeze;
#X text 57 332 dummy outlet for sorting the delay line;
#X obj 185 258 tabwrite~ \$0-table;
#X obj 26 291 delwrite~ \$0-del 1000;
#X obj 153 178 sel 0;
#X obj 185 202 bang;
#X obj 190 291 table \$0-table 44100;
#X connect 0 0 1 0;
#X connect 0 0 5 0;
#X connect 0 0 4 0;
#X connect 2 0 6 0;
#X connect 6 1 7 0;
#X connect 7 0 4 0;
#X restore 23 122 pd delay-line;
#X obj 262 113 s \$0-freeze;
#X text 56 515 locking (0-1): amount of phase locking. While the default
value 1 usually gives the most present sound \, lower values might
be adequate in some occasions.;
#X msg 326 50 0;
#X text 60 282 a live pitch shifter based on miller puckette's phase
vocoder (audio example I07.phase.vocoder);
#X text 58 344 1) window size (1024);
#X msg 171 119 1;
#X msg 161 20 0;
#X obj 106 48 route float locking set freeze;
#X text 56 387 1) <signal>: input signal;
#X text 59 408 2) <float>: pitch shift (half steps);
#X text 56 643 NB: Upwards pitch shifting is limited by the buffer
size (1000ms = ca. 3 1/2 octaves at window size 4096).;
#X text 57 454 set (256 \, 512 \, 1024 \, 2048 \, 4096 \, 8192 \, 16384
\, 32768): fft window size. A higher window size increases latency
but will give better results \, especially for synthesizing low frequencies.
;
#X text 54 560 freeze (0/1): 0 = off \, 1 = on. Everytime you send
a 1 (or another non-zero number) \, the live-input is stopped and frozen
at the current position. Set phase locking low to achieve a smoother
result. Small windows sound rather robotic \, middle and large windows
will work best. Try very large windows for special effects!;
#X obj 432 146 t f f;
#X obj 430 168 pack f f;
#X obj 438 191 route 256 512 1024 2048 4096 8192 16384 32768;
#X connect 0 0 19 0;
#X connect 1 0 13 0;
#X connect 7 0 27 0;
#X connect 8 0 6 0;
#X connect 10 0 11 0;
#X connect 10 1 33 0;
#X connect 11 0 33 0;
#X connect 12 0 18 0;
#X connect 12 0 22 0;
#X connect 12 0 25 0;
#X connect 12 0 26 0;
#X connect 17 0 9 0;
#X connect 18 0 10 0;
#X connect 19 0 1 0;
#X connect 22 0 20 0;
#X connect 25 0 6 0;
#X connect 26 0 5 0;
#X connect 27 0 5 0;
#X connect 27 1 8 0;
#X connect 27 2 33 0;
#X connect 27 3 20 0;
#X connect 33 0 34 0;
#X connect 33 1 34 1;
#X connect 34 0 35 0;
#X connect 35 0 4 0;
#X connect 35 1 4 0;
#X connect 35 2 4 0;
#X connect 35 3 4 0;
#X connect 35 4 4 0;
#X connect 35 5 4 0;
#X connect 35 6 4 0;
#X connect 35 7 4 0;
#X connect 35 8 17 0;
