#N canvas 681 156 802 585 12;
#X declare -stdpath ./;
#X floatatom 468 293 0 0 0 0 - - - 0;
#N canvas 2689 55 791 659 fft 0;
#X obj 98 224 *~;
#X obj 66 224 *~;
#X obj 66 167 *~;
#X obj 66 139 inlet~;
#X obj 66 194 rfft~;
#X obj 66 324 *~;
#X obj 66 435 rifft~;
#X obj 102 168 tabreceive~ \$0-hann;
#X obj 66 267 q8_sqrt~;
#X obj 366 217 samplerate~;
#X obj 357 183 bang~;
#X obj 366 242 t f b, f 6;
#X obj 163 35 loadbang;
#X obj 352 66 r window-size;
#X obj 352 112 block~;
#X obj 366 266 osc~;
#X msg 405 266 0;
#X obj 66 466 *~;
#X obj 102 467 tabreceive~ \$0-hann;
#X obj 66 496 outlet~;
#X obj 112 384 r window-size;
#X obj 66 410 /~ 1000;
#X msg 352 88 set \$1 2;
#X obj 429 322 r \$0-start;
#X obj 357 377 spigot;
#X msg 429 349 1;
#X msg 396 349 0;
#X obj 357 594 outlet;
#X obj 393 439 r window-size;
#X obj 393 509 t f b;
#X obj 425 532 samplerate~;
#X obj 393 532 /;
#X obj 393 555 * 1000;
#X obj 357 561 del;
#X obj 393 463 / 2;
#X obj 393 486 - 1;
#X msg 163 61 \; pd dsp 1 \; window-size 1024 \; pitch 48 \; specshift
0;
#X text 135 267 magnitude of FT;
#X text 77 346 align partials to middle of window;
#X text 98 329 alternate every other sign to;
#X text 412 181 control computations to do every frame;
#X text 454 211 set sample rate of the oscillator to;
#X text 456 226 Nyquist (here we're operating at twice;
#X text 458 242 the global "samplerate~" because of;
#X text 457 259 the overlap-2 blocking.) Also set phase;
#X text 457 275 to zero at beginning of frame.;
#X text 465 341 When analysis starts \, set a delay to, f 37;
#X text 465 358 one frame minus a sample (i.e. \, just, f 37;
#X text 465 375 one 64-sample block before the next, f 37;
#X text 465 392 frame) which is synchronized with the;
#X text 465 409 first frame emerging from outlet~ at, f 37;
#X text 542 427 left. In the parent window;
#X text 542 445 this is used to start, f 26;
#X text 542 463 recording synchronously., f 26;
#X text 65 519 output phase-aligned frames;
#X text 412 594 output a bang to start recording;
#X connect 0 0 8 0;
#X connect 1 0 8 0;
#X connect 2 0 4 0;
#X connect 3 0 2 0;
#X connect 4 0 1 0;
#X connect 4 0 1 1;
#X connect 4 1 0 0;
#X connect 4 1 0 1;
#X connect 5 0 21 0;
#X connect 6 0 17 0;
#X connect 7 0 2 1;
#X connect 8 0 5 0;
#X connect 9 0 11 0;
#X connect 10 0 9 0;
#X connect 10 0 24 0;
#X connect 11 0 15 0;
#X connect 11 1 16 0;
#X connect 12 0 36 0;
#X connect 13 0 22 0;
#X connect 15 0 5 1;
#X connect 16 0 15 1;
#X connect 17 0 19 0;
#X connect 18 0 17 1;
#X connect 20 0 21 1;
#X connect 21 0 6 0;
#X connect 22 0 14 0;
#X connect 23 0 25 0;
#X connect 24 0 26 0;
#X connect 24 0 33 0;
#X connect 25 0 24 1;
#X connect 26 0 24 1;
#X connect 28 0 34 0;
#X connect 29 0 31 0;
#X connect 29 1 30 0;
#X connect 30 0 31 1;
#X connect 31 0 32 0;
#X connect 32 0 33 1;
#X connect 33 0 27 0;
#X connect 34 0 35 0;
#X connect 35 0 29 0;
#X restore 99 454 pd fft;
#X floatatom 641 353 0 0 120 0 - pitch-set - 0;
#X floatatom 638 296 0 0 0 0 - specshift-set - 0;
#X obj 638 319 s specshift;
#X obj 468 400 s loco;
#X obj 641 376 s pitch;
#X obj 468 316 pack 0 100;
#X obj 428 480 output~;
#X text 61 22 PHASE BASHING;
#X text 554 494 updated for Pd version 0.39;
#X floatatom 260 347 5 0 0 0 - #0-samp-msec - 0;
#X text 258 365 sample length \, msec;
#X msg 259 249 ../sound/bell.aiff;
#X msg 265 271 ../sound/voice.wav;
#X msg 271 293 ../sound/voice2.wav;
#X text 262 227 change input sound;
#X obj 259 322 s read-sample;
#N canvas 784 65 488 425 test-signal 0;
#X obj 50 247 line~;
#X obj 50 167 f;
#X obj 50 379 outlet~;
#X msg 50 221 0 \, \$1 \$2;
#X obj 50 195 pack 0 0;
#X obj 152 164 /;
#X obj 195 163 * 0.001;
#X obj 50 275 tabread4~ \$0-sample;
#X obj 227 289 adc~ 1;
#X obj 317 62 inlet;
#X obj 349 173 samplerate~;
#X obj 152 77 r \$0-samplength;
#X obj 163 108 r \$0-insamprate;
#X obj 49 60 inlet;
#X obj 349 197 s \$0-insamprate;
#X obj 227 324 *~;
#X obj 281 267 del;
#X obj 317 146 t b b;
#X msg 317 300 1;
#X msg 281 296 0;
#X obj 50 343 hip~ 5;
#X obj 50 314 +~;
#X obj 143 227 s \$0-start;
#X text 35 27 play sample once;
#X obj 163 137 t b f;
#X connect 0 0 7 0;
#X connect 1 0 4 0;
#X connect 3 0 0 0;
#X connect 4 0 3 0;
#X connect 5 0 4 1;
#X connect 5 0 16 1;
#X connect 6 0 5 1;
#X connect 7 0 21 0;
#X connect 8 0 15 0;
#X connect 9 0 17 0;
#X connect 10 0 14 0;
#X connect 11 0 1 1;
#X connect 11 0 5 0;
#X connect 12 0 24 0;
#X connect 13 0 1 0;
#X connect 13 0 22 0;
#X connect 15 0 21 1;
#X connect 16 0 19 0;
#X connect 17 0 18 0;
#X connect 17 0 16 0;
#X connect 17 0 22 0;
#X connect 17 1 10 0;
#X connect 18 0 15 1;
#X connect 19 0 15 1;
#X connect 20 0 2 0;
#X connect 21 0 20 0;
#X connect 24 0 5 0;
#X connect 24 1 6 0;
#X restore 99 426 pd test-signal;
#X obj 194 407 bng 15 250 50 0 empty empty empty 0 -6 0 8 #fcfcfc #000000
#000000;
#N canvas 0 110 565 454 hann-window 0;
#N canvas 0 0 450 300 (subpatch) 0;
#X array \$0-hann 1024 float 0;
#X coords 0 1 1023 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 272 413 pd hann-window;
#X msg 79 235 512;
#X msg 85 256 1024;
#X msg 91 278 2048;
#X obj 79 325 s window-size;
#X msg 96 300 4096;
#N canvas 653 60 717 500 insample 0;
#N canvas 0 0 450 300 (subpatch) 0;
#X array \$0-sample 62079 float 0;
#X coords 0 1 62078 -1 400 150 1;
#X restore 264 29 graph;
#X obj 35 39 r read-sample;
#X obj 35 94 unpack s f;
#X obj 35 204 soundfiler;
#X text 134 399 read a sample;
#X obj 54 398 loadbang;
#X obj 35 120 t s b;
#X obj 88 125 symbol \$0-sample;
#X obj 35 155 pack s s;
#X msg 35 180 read -resize \$1 \$2;
#X obj 35 67 t a b;
#X obj 45 231 s \$0-samplength;
#X obj 132 94 s \$0-insamprate;
#X obj 35 298 /;
#X obj 35 322 * 1000;
#X obj 35 346 s \$0-samp-msec;
#X obj 53 272 r \$0-insamprate;
#X msg 54 422 \; read-sample ../sound/voice.wav;
#N canvas 0 0 450 300 (subpatch) 0;
#X array \$0-nophase 62079 float 0;
#X coords 0 1 62078 -1 400 150 1;
#X restore 263 214 graph;
#X msg 381 408 resize \$1;
#X obj 381 384 r \$0-samplength;
#X obj 381 433 s \$0-nophase;
#X obj 132 66 f 44100;
#X connect 1 0 10 0;
#X connect 2 0 6 0;
#X connect 2 1 12 0;
#X connect 3 0 11 0;
#X connect 3 0 13 0;
#X connect 5 0 17 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 2 0;
#X connect 10 1 22 0;
#X connect 13 0 14 0;
#X connect 14 0 15 0;
#X connect 16 0 13 1;
#X connect 19 0 21 0;
#X connect 20 0 19 0;
#X connect 22 0 12 0;
#X restore 272 436 pd insample;
#X obj 99 406 bng 15 250 50 0 empty empty empty 0 -6 0 8 #fcfcfc #000000
#000000;
#X text 108 369 ---analyze---;
#X text 92 388 sample;
#X obj 138 486 tabwrite~ \$0-nophase;
#X obj 41 497 output~;
#X msg 476 341 0 \, 400 4000;
#X msg 481 368 0 \, 400 10000;
#X text 55 55 This patch takes an incoming sound \, does an overlap-2
FFT analysis of it \, and bashes the phases of the spectra so that
when regenerated the components will all have zero phase at the middle
of each window. You can use the windows as waveforms and cross-fade
them at will without getting phase modulation. This might be useful
for making synthetic instruments that mimic the spectral variation
of recorded sounds., f 46;
#X text 459 271 (hundredths of sec);
#X text 462 255 location in sample;
#X text 563 334 normal speed, f 6;
#X text 574 367 slow;
#X text 509 228 ------ playback -------;
#N canvas 2782 23 940 931 playback 0;
#X obj 167 633 r invblk;
#X obj 68 660 *~;
#X obj 129 658 clip~ 1 1000;
#X floatatom 154 143 0 0 0 0 - - - 0;
#X floatatom 589 48 0 0 0 0 - - - 0;
#X obj 488 636 *~;
#X obj 634 606 samphold~;
#X obj 721 606 samphold~;
#X obj 529 606 samphold~;
#X obj 473 748 clip~ -0.5 0.5;
#X obj 473 771 cos~;
#X obj 651 694 +~;
#X obj 652 773 -~;
#X obj 634 800 *~;
#X obj 662 825 +~;
#X obj 644 849 *~;
#X obj 86 589 *~;
#X obj 254 569 samphold~;
#X obj 362 596 samphold~;
#X obj 589 462 phasor~;
#X obj 254 325 wrap~;
#X obj 589 23 r pitch;
#X obj 589 97 mtof;
#X obj 362 268 line~;
#X obj 362 368 -~;
#X text 124 96 spectral stretch;
#X obj 129 542 samphold~;
#X obj 695 349 t b f, f 8;
#X obj 730 374 /;
#X obj 695 371 1;
#X obj 68 685 clip~ -0.5 0.5;
#X obj 68 707 cos~;
#X obj 279 633 +~;
#X obj 272 712 -~;
#X obj 254 735 *~;
#X obj 291 760 +~;
#X text 428 246 samples;
#X text 428 231 period in;
#X text 260 589 weight for;
#X text 260 604 next block;
#X obj 589 529 wrap~;
#X obj 730 399 s invblk;
#X obj 569 693 r invblk;
#X obj 695 273 r window-size;
#X obj 154 119 r specshift;
#X obj 272 76 r loco;
#X obj 473 718 *~;
#X obj 529 718 clip~ 1 1000;
#X obj 589 72 - 12;
#X obj 154 190 + 69;
#X obj 154 213 mtof;
#X obj 154 236 / 440;
#X obj 129 328 *~ 1;
#X obj 589 504 +~ 0.5;
#X obj 129 633 *~ 1;
#X obj 529 693 *~ 1;
#X obj 473 793 +~ 1;
#X obj 68 730 +~ 1;
#X obj 362 449 *~ 1;
#X obj 272 660 +~ 0;
#X obj 652 723 +~ 0;
#X obj 68 541 -~ 0.5;
#X obj 473 606 -~ 0.5;
#X obj 273 880 outlet~;
#X obj 272 686 tabread4~ \$0-nophase;
#X obj 309 712 tabread4~ \$0-nophase;
#X obj 652 747 tabread4~ \$0-nophase;
#X obj 687 772 tabread4~ \$0-nophase;
#X obj 362 391 +~ 0.5;
#X text 136 564 grain size;
#X text 389 368 integer part of loc;
#X text 416 392 middle of block;
#X text 309 430 convert to samples, f 10;
#X text 654 454 run two copies 180 degrees out of phase, f 20;
#X obj 273 785 *~;
#X obj 273 826 +~;
#X obj 709 323 s blksize;
#X obj 683 696 r blksize;
#X obj 317 661 r blksize;
#X obj 403 419 r blksize;
#X obj 695 297 / 2;
#X obj 426 209 /;
#X obj 426 182 samplerate~;
#X obj 426 159 t b f;
#X obj 154 166 * 0.125;
#X text 325 65 read location in sec/100, f 13;
#X obj 304 192 samplerate~;
#X obj 272 145 / 100;
#X obj 272 169 t f b;
#X obj 272 192 *;
#X obj 305 217 r blksize;
#X obj 272 217 /;
#X text 207 181 read location \, blocks, f 9;
#X msg 658 135 set \$1;
#X obj 784 111 r pitch;
#X msg 784 135 set \$1;
#X obj 658 111 r specshift;
#X text 760 374 1/(block size);
#X obj 658 159 s specshift-set;
#X obj 784 159 s pitch-set;
#X text 117 28 OVERLAPPED \, WINDOWED SAMPLE PLAYBACK;
#X text 655 70 - with controls for pitch \, location \, and spectral
shift, f 28;
#X text 682 218 analysis overlap was 2 so our block size is (window
size)/2, f 20;
#X obj 272 102 unpack float float;
#X text 32 759 window shaped by raised cos, f 13;
#X text 19 574 offset into ==> sample, f 9;
#X text 386 615 middle of block, f 8;
#X text 325 733 weighted sum of 2 windows, f 12;
#X text 172 316 fractional part of loc, f 11;
#X text 78 255 grain size in samples, f 10;
#X connect 0 0 54 1;
#X connect 1 0 30 0;
#X connect 2 0 1 1;
#X connect 3 0 84 0;
#X connect 4 0 48 0;
#X connect 5 0 11 0;
#X connect 6 0 13 0;
#X connect 7 0 11 1;
#X connect 8 0 5 1;
#X connect 8 0 55 0;
#X connect 9 0 10 0;
#X connect 10 0 56 0;
#X connect 11 0 60 0;
#X connect 11 0 67 0;
#X connect 12 0 13 1;
#X connect 13 0 14 0;
#X connect 14 0 15 1;
#X connect 15 0 75 1;
#X connect 16 0 32 0;
#X connect 17 0 34 0;
#X connect 18 0 32 1;
#X connect 19 0 26 1;
#X connect 19 0 18 1;
#X connect 19 0 17 1;
#X connect 19 0 53 0;
#X connect 19 0 61 0;
#X connect 20 0 24 1;
#X connect 20 0 17 0;
#X connect 20 0 6 0;
#X connect 21 0 4 0;
#X connect 22 0 19 0;
#X connect 22 0 83 0;
#X connect 23 0 20 0;
#X connect 23 0 24 0;
#X connect 24 0 68 0;
#X connect 26 0 16 1;
#X connect 26 0 54 0;
#X connect 27 0 29 0;
#X connect 27 1 28 1;
#X connect 28 0 41 0;
#X connect 29 0 28 0;
#X connect 30 0 31 0;
#X connect 31 0 57 0;
#X connect 32 0 59 0;
#X connect 32 0 65 0;
#X connect 33 0 34 1;
#X connect 34 0 35 0;
#X connect 35 0 74 1;
#X connect 40 0 8 1;
#X connect 40 0 6 1;
#X connect 40 0 7 1;
#X connect 40 0 62 0;
#X connect 42 0 55 1;
#X connect 43 0 80 0;
#X connect 44 0 3 0;
#X connect 45 0 103 0;
#X connect 46 0 9 0;
#X connect 47 0 46 1;
#X connect 48 0 22 0;
#X connect 49 0 50 0;
#X connect 50 0 51 0;
#X connect 51 0 52 1;
#X connect 52 0 26 0;
#X connect 52 0 8 0;
#X connect 53 0 40 0;
#X connect 54 0 2 0;
#X connect 55 0 47 0;
#X connect 56 0 15 0;
#X connect 57 0 74 0;
#X connect 58 0 18 0;
#X connect 58 0 7 0;
#X connect 59 0 64 0;
#X connect 60 0 66 0;
#X connect 61 0 16 0;
#X connect 61 0 1 0;
#X connect 62 0 5 0;
#X connect 62 0 46 0;
#X connect 64 0 33 0;
#X connect 65 0 33 1;
#X connect 65 0 35 1;
#X connect 66 0 12 0;
#X connect 67 0 12 1;
#X connect 67 0 14 1;
#X connect 68 0 58 0;
#X connect 74 0 75 0;
#X connect 75 0 63 0;
#X connect 77 0 60 1;
#X connect 78 0 59 1;
#X connect 79 0 58 1;
#X connect 80 0 76 0;
#X connect 80 0 27 0;
#X connect 81 0 52 0;
#X connect 82 0 81 0;
#X connect 83 0 82 0;
#X connect 83 1 81 1;
#X connect 84 0 49 0;
#X connect 86 0 89 1;
#X connect 87 0 88 0;
#X connect 88 0 89 0;
#X connect 88 1 86 0;
#X connect 89 0 91 0;
#X connect 90 0 91 1;
#X connect 91 0 23 0;
#X connect 93 0 98 0;
#X connect 94 0 95 0;
#X connect 95 0 99 0;
#X connect 96 0 93 0;
#X connect 103 0 87 0;
#X connect 103 1 23 1;
#X restore 428 442 pd playback;
#X text 620 256 spectral shift;
#X text 618 272 (hundredths of;
#X text 681 289 octave);
#X text 181 387 live;
#X text 400 58 You can save the analyses and needn't be running the
FFT patch to do the resynthesis. You can read a sample \, select window
size \, and press "sample" to analyze it \, or else analyze a "live"
input. You'll hear the phase-bashed sample as the analysis runs. You
can regenerate the sound with specified pitch \, sample location \,
and spectral shift \, using the "playback" controls., f 44;
#X text 137 242 analysis;
#X text 134 228 (redo;
#X text 137 258 after;
#X text 138 273 changing;
#X text 138 289 window;
#X text 139 303 size);
#X obj 578 17 declare -stdpath ./;
#X connect 0 0 7 0;
#X connect 1 0 30 0;
#X connect 1 0 31 0;
#X connect 1 0 31 1;
#X connect 1 1 30 0;
#X connect 2 0 6 0;
#X connect 3 0 4 0;
#X connect 7 0 5 0;
#X connect 13 0 17 0;
#X connect 14 0 17 0;
#X connect 15 0 17 0;
#X connect 18 0 1 0;
#X connect 19 0 18 1;
#X connect 21 0 24 0;
#X connect 22 0 24 0;
#X connect 23 0 24 0;
#X connect 25 0 24 0;
#X connect 27 0 18 0;
#X connect 32 0 5 0;
#X connect 33 0 5 0;
#X connect 40 0 8 0;
#X connect 40 0 8 1;
