#N canvas 281 223 567 589 12; #N canvas 228 148 651 544 fft-analysis 0; #X obj 15 164 *~; #X obj 14 99 inlet~; #X obj 15 218 rfft~; #X obj 36 140 tabreceive~ \$0-hann; #X obj 14 306 *~; #X obj 56 306 *~; #X obj 15 356 sqrt~; #X obj 14 498 tabwrite~ \$0-magnitude; #X obj 23 386 loadbang; #X obj 23 470 metro 250; #X obj 23 449 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1 1 ; #X msg 31 411 \; pd dsp 1; #X obj 15 8 block~ 512; #X text 225 131 tabreceive~ outputs array contents \,; #X text 225 149 constantly \, every block. Here it's; #X text 223 169 used to get the Hann window to; #X text 225 187 multiply by the input.; #X text 120 7 block~ object does no computation but declares this; #X text 120 24 window to be operating at a different block size from ; #X text 122 58 Fourier transform.; #X text 121 40 the parent window. This determines the size of the; #X text 76 99 The inlet~ automatically re-blocks to the new block size. ; #X obj 15 332 +~; #X text 94 308 Take the magnitude by squaring real and imaginary part \, adding and taking square root.; #X text 110 424 periodically graph the output. It appears every 512 samples (about 12 milliseconds) but we only update the graph 4 times per second. The graph is back on the main (parent) window.; #X text 82 215 forward real FFT. Like "fft~" \, but only one inlet (for the real part) and only the first half of the output signals are used. (The others are determined by symmetry: they're complex conjugates of the first half \, in reverse order.) This takes 1/2 the CPU time of "fft".; #X connect 0 0 2 0; #X connect 1 0 0 0; #X connect 2 0 4 0; #X connect 2 0 4 1; #X connect 2 1 5 0; #X connect 2 1 5 1; #X connect 3 0 0 1; #X connect 4 0 22 0; #X connect 5 0 22 1; #X connect 6 0 7 0; #X connect 8 0 10 0; #X connect 8 0 11 0; #X connect 9 0 7 0; #X connect 10 0 9 0; #X connect 22 0 6 0; #X restore 26 289 pd fft-analysis; #N canvas 0 0 450 300 graph1 0; #X array \$0-magnitude 256 float 0; #X coords 0 256 255 0 256 100 1; #X restore 287 208 graph; #X text 110 6 WINDOWING AND BLOCKING FOURIER TRANSFORMS; #X obj 25 264 osc~; #X floatatom 25 218 5 0 0 0 - - -; #X obj 25 240 * 10; #X text 305 559 updated for Pd version 0.39; #X text 349 183 magnitude; #X text 284 311 0; #X text 522 311 255; #X text 273 297 0; #X text 255 253 128; #X text 254 203 256; #N canvas 0 0 450 300 graph1 0; #X array \$0-hann 512 float 1; #A 0 0 3.76403e-05 0.000150591 0.000338793 0.000602275 0.000940949 0.00135478 0.00184369 0.00240764 0.00304651 0.00376022 0.00454867 0.00541174 0.0063493 0.00736117 0.00844723 0.00960734 0.0108413 0.0121489 0.01353 0.0149843 0.0165117 0.0181119 0.0197847 0.0215298 0.0233469 0.0252359 0.0271963 0.0292279 0.0313304 0.0335035 0.0357469 0.0380601 0.040443 0.042895 0.0454159 0.0480052 0.0506626 0.0533877 0.05618 0.0590392 0.0619648 0.0649563 0.0680134 0.0711355 0.0743222 0.077573 0.0808874 0.0842649 0.0877051 0.0912073 0.0947711 0.0983959 0.102081 0.105826 0.109631 0.113494 0.117416 0.121395 0.125431 0.129524 0.133672 0.137876 0.142134 0.146446 0.150811 0.155229 0.159699 0.16422 0.168792 0.173413 0.178084 0.182803 0.18757 0.192384 0.197244 0.20215 0.2071 0.212095 0.217133 0.222214 0.227337 0.2325 0.237704 0.242948 0.24823 0.25355 0.258907 0.264301 0.26973 0.275194 0.280691 0.286222 0.291785 0.297379 0.303003 0.308658 0.314341 0.320052 0.32579 0.331555 0.337344 0.343159 0.348997 0.354857 0.36074 0.366643 0.372567 0.37851 0.384471 0.390449 0.396444 0.402454 0.40848 0.414519 0.420571 0.426634 0.432709 0.438794 0.444889 0.450991 0.457101 0.463218 0.469339 0.475466 0.481596 0.487729 0.493864 0.5 0.506136 0.512271 0.518404 0.524534 0.53066 0.536782 0.542899 0.549009 0.555111 0.561205 0.56729 0.573365 0.579429 0.585481 0.59152 0.597545 0.603556 0.609551 0.615529 0.62149 0.627433 0.633357 0.63926 0.645143 0.651003 0.656841 0.662656 0.668445 0.67421 0.679948 0.685659 0.691342 0.696997 0.702621 0.708215 0.713778 0.719309 0.724806 0.73027 0.735699 0.741092 0.74645 0.75177 0.757052 0.762295 0.767499 0.772663 0.777786 0.782867 0.787905 0.7929 0.79785 0.802756 0.807616 0.81243 0.817197 0.821916 0.826587 0.831209 0.83578 0.840301 0.844771 0.849189 0.853554 0.857866 0.862124 0.866328 0.870476 0.874569 0.878605 0.882584 0.886506 0.890369 0.894174 0.897919 0.901605 0.905229 0.908793 0.912295 0.915736 0.919113 0.922428 0.925678 0.928865 0.931987 0.935044 0.938036 0.940961 0.94382 0.946613 0.949338 0.951995 0.954585 0.957106 0.959558 0.96194 0.964254 0.966497 0.96867 0.970773 0.972804 0.974765 0.976654 0.978471 0.980216 0.981889 0.983489 0.985016 0.98647 0.987852 0.989159 0.990393 0.991553 0.992639 0.993651 0.994589 0.995452 0.99624 0.996954 0.997593 0.998156 0.998645 0.999059 0.999398 0.999661 0.999849 0.999962 1 0.999962 0.999849 0.999661 0.999398 0.999059 0.998645 0.998156 0.997592 0.996953 0.996239 0.995451 0.994588 0.99365 0.992638 0.991552 0.990392 0.989158 0.987851 0.986469 0.985015 0.983488 0.981887 0.980215 0.978469 0.976652 0.974763 0.972803 0.970771 0.968669 0.966495 0.964252 0.961939 0.959556 0.957104 0.954583 0.951993 0.949336 0.946611 0.943819 0.940959 0.938034 0.935042 0.931985 0.928863 0.925676 0.922425 0.919111 0.915733 0.912293 0.908791 0.905227 0.901602 0.897917 0.894171 0.890367 0.886503 0.882582 0.878602 0.874566 0.870473 0.866325 0.862121 0.857863 0.853551 0.849186 0.844768 0.840298 0.835777 0.831205 0.826584 0.821913 0.817194 0.812427 0.807613 0.802753 0.797847 0.792896 0.787901 0.782863 0.777782 0.77266 0.767496 0.762292 0.757048 0.751766 0.746446 0.741089 0.735695 0.730266 0.724802 0.719305 0.713774 0.708211 0.702617 0.696993 0.691338 0.685655 0.679944 0.674206 0.668441 0.662652 0.656837 0.650999 0.645139 0.639256 0.633353 0.627429 0.621486 0.615525 0.609547 0.603552 0.597541 0.591516 0.585477 0.579425 0.573361 0.567286 0.561201 0.555107 0.549004 0.542895 0.536778 0.530656 0.52453 0.518399 0.512266 0.506132 0.499996 0.49386 0.487725 0.481592 0.475462 0.469335 0.463213 0.457097 0.450987 0.444885 0.43879 0.432705 0.42663 0.420566 0.414515 0.408476 0.40245 0.39644 0.390445 0.384466 0.378505 0.372563 0.366639 0.360736 0.354853 0.348993 0.343155 0.33734 0.331551 0.325786 0.320048 0.314337 0.308654 0.303 0.297375 0.291781 0.286218 0.280687 0.27519 0.269726 0.264297 0.258904 0.253547 0.248226 0.242944 0.237701 0.232497 0.227333 0.222211 0.21713 0.212092 0.207097 0.202146 0.19724 0.19238 0.187566 0.182799 0.17808 0.17341 0.168788 0.164217 0.159696 0.155226 0.150808 0.146443 0.142131 0.137873 0.133669 0.129521 0.125428 0.121392 0.117413 0.113491 0.109628 0.105823 0.102078 0.0983929 0.0947681 0.0912044 0.0877022 0.0842621 0.0808846 0.0775702 0.0743194 0.0711327 0.0680107 0.0649537 0.0619622 0.0590366 0.0561775 0.0533853 0.0506602 0.0480029 0.0454136 0.0428928 0.0404408 0.038058 0.0357448 0.0335015 0.0313284 0.029226 0.0271944 0.025234 0.0233452 0.0215281 0.019783 0.0181104 0.0165102 0.0149829 0.0135286 0.0121476 0.01084 0.00960615 0.0084461 0.0073601 0.00634828 0.00541082 0.00454783 0.00375944 0.00304583 0.00240701 0.00184315 0.00135431 0.000940561 0.000601947 0.000338584 0.000150442 3.75807e-05 ; #X coords 0 1 511 0 200 120 1; #X restore 278 401 graph; #X msg 156 415 0; #X obj 50 464 osc~; #X obj 50 416 samplerate~; #X obj 50 487 *~ -0.5; #X obj 50 510 +~ 0.5; #X obj 42 535 tabwrite~ \$0-hann; #X text 264 393 1; #X text 257 511 0; #X text 273 524 0; #X obj 50 440 / 512; #X obj 42 393 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 -1; #X text 321 373 Hann window; #X text 98 462 period 512; #X text 40 368 recalculate Hann; #X text 75 383 window table; #X text 100 233 tens of Hz.; #X text 80 215 <- frequency \,; #X text 98 270 click here and; #X text 170 286 <- see; #X text 21 32 In this example we use a sub-patch ("pd fft-analysis") to re-block the Fourier transform to 512 points. The signal is multiplied by the Hann window function (which is just a raised cosine.) The magnitude \, which is computed in the sub-patch \, is graphed below in this window. The point at 255 corresponds to just below the Nyquist frequency. Phase isn't shown \, and unlike the previous patch we don't control the initial phase of the oscillator. (For fun \, try drawing other window functions with the mouse...); #X text 459 527 511; #X connect 3 0 0 0; #X connect 4 0 5 0; #X connect 5 0 3 0; #X connect 14 0 15 1; #X connect 15 0 17 0; #X connect 16 0 23 0; #X connect 17 0 18 0; #X connect 18 0 19 0; #X connect 23 0 15 0; #X connect 24 0 16 0; #X connect 24 0 14 0; #X connect 24 0 19 0;