#N canvas 441 74 551 460 12;
#X declare -stdpath ./;
#N canvas 359 23 837 719 fft 0;
#X obj 63 584 *~;
#X obj 288 539 *~;
#X obj 259 538 *~;
#X obj 351 540 *~;
#X obj 319 539 *~;
#X obj 319 567 +~;
#X obj 259 568 -~;
#X obj 457 470 *~;
#X obj 183 260 *~;
#X obj 151 260 *~;
#X obj 151 285 +~;
#X obj 275 149 *~;
#X obj 243 149 *~;
#X obj 507 384 *~;
#X obj 475 384 *~;
#X obj 168 123 *~;
#X obj 63 681 outlet~;
#X obj 63 559 *~;
#X obj 168 190 rfft~;
#X obj 63 535 rifft~;
#X obj 475 412 rsqrt~;
#X obj 243 173 +~;
#X obj 397 470 *~;
#X obj 101 583 sig~ 0.0002;
#N canvas 167 161 699 396 decision 0;
#X obj 49 101 inlet~;
#X obj 50 341 outlet~;
#X obj 50 183 -~;
#X obj 50 226 clip~ 0 1;
#X obj 50 204 *~ 1e+20;
#X obj 196 98 inlet~;
#X text 137 213 stronger than;
#X text 139 228 old one;
#X obj 274 202 -~;
#X obj 288 177 lrshift~ 1;
#X obj 274 250 clip~ 0 1;
#X obj 274 228 *~ 1e+20;
#X obj 450 202 -~;
#X obj 450 250 clip~ 0 1;
#X obj 450 228 *~ 1e+20;
#X obj 464 177 lrshift~ -1;
#X obj 50 283 *~;
#X obj 50 312 *~;
#X text 135 199 1 if new signal;
#X text 55 73 new;
#X text 203 70 old;
#X text 51 12 Choose whether to replace the "old" signal with the "new" one. The "new" one must be stronger than the old one and also must be stronger than its two neighboring channels;
#X text 267 283 1 if we're louder than neighbor;
#X connect 0 0 2 0;
#X connect 0 0 9 0;
#X connect 0 0 8 0;
#X connect 0 0 12 0;
#X connect 0 0 15 0;
#X connect 2 0 4 0;
#X connect 3 0 16 0;
#X connect 4 0 3 0;
#X connect 5 0 2 1;
#X connect 8 0 11 0;
#X connect 9 0 8 1;
#X connect 10 0 16 1;
#X connect 11 0 10 0;
#X connect 12 0 14 0;
#X connect 13 0 17 1;
#X connect 14 0 13 0;
#X connect 15 0 12 1;
#X connect 16 0 17 0;
#X connect 17 0 1 0;
#X restore 151 312 pd decision;
#X obj 475 434 *~;
#N canvas 352 333 393 308 divide-by-prev 0;
#X obj 204 88 inlet~;
#X obj 266 90 inlet~;
#X obj 204 240 outlet~;
#X obj 267 240 outlet~;
#X obj 70 240 outlet~;
#X obj 138 240 outlet~;
#X obj 171 169 *~;
#X obj 138 169 *~;
#X obj 103 170 *~;
#X obj 70 170 *~;
#X obj 70 198 +~;
#X obj 138 197 -~;
#X obj 89 34 r~ \$0-last-real;
#X obj 121 61 r~ \$0-last-imag;
#X connect 0 0 2 0;
#X connect 0 0 9 0;
#X connect 0 0 6 0;
#X connect 1 0 3 0;
#X connect 1 0 8 0;
#X connect 1 0 7 0;
#X connect 6 0 11 1;
#X connect 7 0 11 0;
#X connect 8 0 10 1;
#X connect 9 0 10 0;
#X connect 10 0 4 0;
#X connect 11 0 5 0;
#X connect 12 0 9 1;
#X connect 12 0 7 1;
#X connect 13 0 8 1;
#X connect 13 0 6 1;
#X restore 500 279 pd divide-by-prev;
#N canvas 650 183 602 327 switch 0;
#X obj 61 160 inlet~;
#X obj 149 96 inlet~;
#X obj 211 97 inlet~;
#X obj 315 94 inlet~;
#X obj 375 94 inlet~;
#X obj 409 182 -~;
#X obj 380 228 +~;
#X obj 414 226 *~;
#X obj 292 179 -~;
#X obj 262 225 +~;
#X obj 296 225 *~;
#X obj 261 275 outlet~;
#X obj 380 271 outlet~;
#X text 88 25 switch between two pairs of inputs. If first inlet is one \, take the left-hand pair \, otherwise the right-hand one.;
#X text 57 137 switch;
#X text 134 73 pass this if one;
#X text 311 74 pass this if zero;
#X connect 0 0 10 1;
#X connect 0 0 7 1;
#X connect 1 0 8 0;
#X connect 2 0 5 0;
#X connect 3 0 9 0;
#X connect 3 0 8 1;
#X connect 4 0 6 0;
#X connect 4 0 5 1;
#X connect 5 0 7 0;
#X connect 6 0 12 0;
#X connect 7 0 6 1;
#X connect 8 0 10 0;
#X connect 9 0 11 0;
#X connect 10 0 9 1;
#X restore 277 369 pd switch;
#X obj 548 357 r revtime;
#X obj 99 560 tabreceive~ \$0-hann;
#X obj 186 83 tabreceive~ \$0-hann, f 11;
#X msg 558 380 set \$1;
#X obj 558 404 s revtime-set;
#X obj 681 141 loadbang;
#X obj 681 50 r window-size;
#X msg 681 72 set \$1 4;
#X obj 681 94 block~;
#X obj 548 428 expr 1 - 0.2/max(0.2 \, $f1);
#X text 438 39 previous output amplitude \, encoding both magnitude and phase, f 19;
#X text 435 136 previous phase increment (unit-magnitude complex number), f 31;
#X obj 442 199 +~ 1e-15;
#X obj 322 81 +~ 1e-15;
#X text 124 683 IFFT and output;
#X text 491 457 normalize increments between 0 and 1 according to revtime., f 29;
#X text 352 564 propagate amplitudes by multiplying in the increments \, which advance the phase and drop magnitude according to revtime., f 40;
#X text 31 289 choose whether to punch in new (amplitude \, increment) pair, f 16;
#N canvas 650 183 602 327 switch 0;
#X obj 61 160 inlet~;
#X obj 149 96 inlet~;
#X obj 211 97 inlet~;
#X obj 315 94 inlet~;
#X obj 375 94 inlet~;
#X obj 409 182 -~;
#X obj 380 228 +~;
#X obj 414 226 *~;
#X obj 292 179 -~;
#X obj 262 225 +~;
#X obj 296 225 *~;
#X obj 261 275 outlet~;
#X obj 380 271 outlet~;
#X text 88 25 switch between two pairs of inputs. If first inlet is one \, take the left-hand pair \, otherwise the right-hand one.;
#X text 57 137 switch;
#X text 134 73 pass this if one;
#X text 311 74 pass this if zero;
#X connect 0 0 10 1;
#X connect 0 0 7 1;
#X connect 1 0 8 0;
#X connect 2 0 5 0;
#X connect 3 0 9 0;
#X connect 3 0 8 1;
#X connect 4 0 6 0;
#X connect 4 0 5 1;
#X connect 5 0 7 0;
#X connect 6 0 12 0;
#X connect 7 0 6 1;
#X connect 8 0 10 0;
#X connect 9 0 11 0;
#X connect 10 0 9 1;
#X restore 397 353 pd switch;
#X msg 681 167 \; window-size 4096 \; revtime 20;
#X obj 322 55 r~ \$0-amp-real;
#X obj 337 107 r~ \$0-amp-imag;
#X obj 442 174 r~ \$0-inc-real;
#X obj 459 226 r~ \$0-inc-imag;
#X obj 616 304 s~ \$0-last-imag;
#X obj 577 327 s~ \$0-last-real;
#X obj 259 650 s~ \$0-amp-real;
#X obj 319 621 s~ \$0-amp-imag;
#X obj 168 14 inlet~;
#X obj 397 536 s~ \$0-inc-real;
#X obj 457 510 s~ \$0-inc-imag;
#X connect 0 0 16 0;
#X connect 1 0 6 1;
#X connect 2 0 6 0;
#X connect 3 0 5 1;
#X connect 4 0 5 0;
#X connect 5 0 55 0;
#X connect 6 0 54 0;
#X connect 7 0 1 0;
#X connect 7 0 3 0;
#X connect 7 0 58 0;
#X connect 8 0 10 1;
#X connect 9 0 10 0;
#X connect 10 0 24 0;
#X connect 11 0 21 1;
#X connect 12 0 21 0;
#X connect 13 0 20 0;
#X connect 14 0 20 0;
#X connect 15 0 18 0;
#X connect 17 0 0 0;
#X connect 18 0 9 0;
#X connect 18 0 9 1;
#X connect 18 0 26 0;
#X connect 18 0 27 1;
#X connect 18 1 8 0;
#X connect 18 1 8 1;
#X connect 18 1 26 1;
#X connect 18 1 27 2;
#X connect 19 0 17 0;
#X connect 20 0 25 0;
#X connect 21 0 24 1;
#X connect 22 0 2 0;
#X connect 22 0 4 0;
#X connect 22 0 57 0;
#X connect 23 0 0 1;
#X connect 24 0 27 0;
#X connect 24 0 46 0;
#X connect 25 0 22 1;
#X connect 25 0 7 1;
#X connect 26 0 46 1;
#X connect 26 1 46 2;
#X connect 26 2 53 0;
#X connect 26 3 52 0;
#X connect 27 0 19 0;
#X connect 27 0 3 1;
#X connect 27 0 2 1;
#X connect 27 1 19 1;
#X connect 27 1 1 1;
#X connect 27 1 4 1;
#X connect 28 0 31 0;
#X connect 28 0 37 0;
#X connect 29 0 17 1;
#X connect 30 0 15 1;
#X connect 31 0 32 0;
#X connect 33 0 47 0;
#X connect 34 0 35 0;
#X connect 35 0 36 0;
#X connect 37 0 25 1;
#X connect 40 0 46 3;
#X connect 41 0 12 0;
#X connect 41 0 12 1;
#X connect 41 0 27 3;
#X connect 46 0 14 0;
#X connect 46 0 14 1;
#X connect 46 0 22 0;
#X connect 46 1 13 0;
#X connect 46 1 13 1;
#X connect 46 1 7 0;
#X connect 48 0 41 0;
#X connect 49 0 11 0;
#X connect 49 0 11 1;
#X connect 49 0 27 4;
#X connect 50 0 40 0;
#X connect 51 0 46 4;
#X connect 56 0 15 0;
#X restore 184 326 pd fft;
#X floatatom 368 255 4 0 1000 0 - revtime-set - 0;
#X floatatom 59 262 6 0 0 0 - - - 0;
#X text 38 11 PIANO REVERB;
#X text 406 255 reverb time;
#X obj 184 361 output~;
#X obj 59 361 output~;
#X text 25 45 This is a phase vocoder acting as a reverberator. The sound is more coherent (less "whispered") than a real room or a standard delay-based reverberator., f 70;
#X text 25 99 The technique is to "punch" the incoming sound into channels where (1) there's a peak \, and (2) the incoming sound drowns out whatever might already be there. If the sound already in any channel is louder than the input the input for that channel is ignored., f 70;
#N canvas 464 229 262 333 test-sound 0;
#X obj 46 25 inlet;
#X obj 46 145 osc~;
#X obj 115 201 line~;
#X floatatom 46 86 0 0 0 0 - - - 0;
#X obj 46 59 mtof;
#X obj 46 170 cos~;
#X obj 46 194 hip~ 20;
#X obj 46 117 t f b;
#X obj 115 91 bng 15 250 50 0 empty empty empty 0 -6 0 8 #fcfcfc #000000 #000000;
#X obj 160 172 pack 0 30;
#X obj 160 117 del 20;
#X obj 115 144 pack 1 20;
#X obj 46 236 *~;
#X obj 46 272 outlet~;
#X connect 0 0 4 0;
#X connect 1 0 5 0;
#X connect 2 0 12 1;
#X connect 3 0 7 0;
#X connect 4 0 3 0;
#X connect 5 0 6 0;
#X connect 6 0 12 0;
#X connect 7 0 1 0;
#X connect 7 1 8 0;
#X connect 8 0 10 0;
#X connect 8 0 11 0;
#X connect 9 0 2 0;
#X connect 10 0 9 0;
#X connect 11 0 2 0;
#X connect 12 0 13 0;
#X restore 59 289 pd test-sound;
#X obj 368 287 s revtime;
#X text 25 170 For each window \, the amplitude in each channel is propagated by a constant phase increment and multiplied downward by a gain that determines the "reverb time"., f 70;
#N canvas 635 123 602 538 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 148 395 graph;
#X obj 365 185 osc~;
#X obj 365 210 *~ -0.5;
#X obj 365 234 +~ 0.5;
#X obj 348 277 tabwrite~ \$0-hann;
#X obj 124 114 r window-size;
#X obj 195 238 /;
#X obj 213 206 samplerate~;
#X obj 195 316 s window-sec;
#X obj 105 252 swap;
#X obj 105 276 /;
#X obj 105 300 s window-hz;
#X obj 206 266 * 1000;
#X obj 206 293 s window-msec;
#X obj 124 149 t f b f;
#X msg 213 156 resize \$1;
#X obj 213 180 s \$0-hann;
#X obj 317 123 r window-hz;
#X msg 390 155 0;
#X obj 317 151 t f b;
#X text 94 21 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)., f 56;
#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 366 317 pd hann-window;
#X text 76 425 reverb in;
#X text 184 425 reverb out;
#X obj 336 14 declare -stdpath ./;
#X text 330 399 Updated for Pd version 0.54;
#X obj 59 230 bng 19 250 50 0 empty empty empty 0 -10 0 12 #dfdfdf #000000 #000000;
#X text 109 261 short tone pitch;
#X connect 0 0 5 0;
#X connect 1 0 10 0;
#X connect 2 0 9 0;
#X connect 9 0 6 0;
#X connect 9 0 0 0;
#X connect 17 0 2 0;
