#N canvas 85 89 754 729 12; #N canvas 0 0 450 300 (subpatch) 0; #X array E06-signal 882 float 0; #X coords 0 1.02 882 -1.02 200 130 1; #X restore 509 46 graph; #X obj 14 265 hip~ 5; #N canvas 0 0 450 300 (subpatch) 0; #X array E06-spectrum 128 float 0; #X coords 0 4300 127 -40 257 130 1; #X restore 463 222 graph; #N canvas 45 83 558 569 fft 0; #X obj 19 61 inlet~; #X obj 208 212 inlet; #X obj 29 92 rfft~; #X obj 29 125 *~; #X obj 60 125 *~; #X obj 29 155 sqrt~; #X obj 332 109 block~ 4096 1; #X obj 29 181 biquad~ 0 0 0 0 1; #X text 93 93 Fourier series; #X text 98 146 magnitude; #X text 96 131 calculate; #X text 21 3 This subpatch computes the spectrum of the incoming signal with a (rectangular windowed) FFT. FFTs aren't properly introduced until much later.; #X text 83 61 signal to analyze; #X text 193 164 delay two samples; #X text 191 182 for better graphing; #X obj 16 425 samplerate~; #X obj 16 402 bng 18 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 -1; #X floatatom 16 472 5 0 0 0 - - -; #X obj 16 448 / 256; #X obj 16 378 loadbang; #X floatatom 16 541 5 0 0 0 - - -; #X obj 24 494 s fundamental; #X obj 16 517 ftom; #X text 14 319 At load time \, calculate a good choice of fundamental frequency for showing spectra: the 16th bin in a 4096-point spectrum \, so SR*16/4096 or SR/256.; #X floatatom 191 480 5 0 0 0 - - -; #X obj 191 456 / 4096; #X text 187 425 One bin is SR/4096:; #X obj 191 502 s freq-step; #X obj 208 295 tabwrite~ E06-spectrum; #X obj 19 295 tabwrite~ E06-signal; #X text 71 540 <-fundamental pitch; #X obj 220 257 metro 500; #X obj 220 234 inlet; #X text 273 232 toggle to graph repeatedly; #X text 262 212 bang to graph once; #X connect 0 0 2 0; #X connect 0 0 29 0; #X connect 1 0 28 0; #X connect 1 0 29 0; #X connect 2 0 3 0; #X connect 2 0 3 1; #X connect 2 1 4 0; #X connect 2 1 4 1; #X connect 3 0 5 0; #X connect 4 0 5 0; #X connect 5 0 7 0; #X connect 7 0 28 0; #X connect 15 0 18 0; #X connect 15 0 25 0; #X connect 16 0 15 0; #X connect 17 0 21 0; #X connect 17 0 22 0; #X connect 18 0 17 0; #X connect 19 0 16 0; #X connect 22 0 20 0; #X connect 24 0 27 0; #X connect 25 0 24 0; #X connect 31 0 28 0; #X connect 31 0 29 0; #X connect 32 0 31 0; #X restore 22 238 pd fft; #X text 509 178 ---- 0.02 seconds ----; #X obj 82 217 bng 18 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 -1; #X obj 14 293 output~; #X text 499 708 updated for Pd version 0.37; #X text 494 355 1; #X text 528 355 2; #X text 560 355 3; #X text 592 355 4; #X text 625 355 5; #X text 655 355 6; #X text 686 355 7; #X text 462 355 0; #X text 496 372 -- partial number --; #X text 711 100 0; #X obj 12 30 r fundamental; #X obj 12 57 osc~; #X text 573 26 WAVEFORM; #X text 557 204 SPECTRUM; #X text 723 338 0; #X text 721 217 1; #X text 722 276 0.5; #X obj 82 238 tgl 18 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1 ; #N canvas 0 0 450 300 (subpatch) 0; #X array E06-tab 1003 float 1; #A 0 1.01005 1 0.99005 0.980199 0.970446 0.960789 0.951229 0.941765 0.932394 0.923116 0.913931 0.904837 0.895834 0.88692 0.878095 0.869358 0.860708 0.852144 0.843665 0.83527 0.826959 0.818731 0.810584 0.802519 0.794534 0.786628 0.778801 0.771052 0.76338 0.755784 0.748264 0.740818 0.733447 0.726149 0.718924 0.71177 0.704688 0.697676 0.690734 0.683861 0.677057 0.67032 0.66365 0.657047 0.650509 0.644036 0.637628 0.631284 0.625002 0.618783 0.612626 0.606531 0.600496 0.594521 0.588605 0.582748 0.57695 0.571209 0.565525 0.559898 0.554327 0.548812 0.543351 0.537944 0.532592 0.527292 0.522046 0.516851 0.511709 0.506617 0.501576 0.496585 0.491644 0.486752 0.481909 0.477114 0.472367 0.467666 0.463013 0.458406 0.453845 0.449329 0.444858 0.440432 0.436049 0.431711 0.427415 0.423162 0.418952 0.414783 0.410656 0.40657 0.402524 0.398519 0.394554 0.390628 0.386741 0.382893 0.379083 0.375311 0.371577 0.367879 0.364219 0.360595 0.357007 0.353455 0.349938 0.346456 0.343008 0.339595 0.336216 0.332871 0.329559 0.32628 0.323033 0.319819 0.316637 0.313486 0.310367 0.307279 0.304221 0.301194 0.298197 0.29523 0.292293 0.289384 0.286505 0.283654 0.280832 0.278037 0.275271 0.272532 0.26982 0.267135 0.264477 0.261846 0.25924 0.256661 0.254107 0.251579 0.249075 0.246597 0.244143 0.241714 0.239309 0.236928 0.23457 0.232236 0.229925 0.227638 0.225373 0.22313 0.22091 0.218712 0.216536 0.214381 0.212248 0.210136 0.208045 0.205975 0.203926 0.201897 0.199888 0.197899 0.19593 0.19398 0.19205 0.190139 0.188247 0.186374 0.18452 0.182684 0.180866 0.179066 0.177284 0.17552 0.173774 0.172045 0.170333 0.168638 0.16696 0.165299 0.163654 0.162026 0.160414 0.158817 0.157237 0.155673 0.154124 0.15259 0.151072 0.149569 0.14808 0.146607 0.145148 0.143704 0.142274 0.140858 0.139457 0.138069 0.136695 0.135335 0.133989 0.132655 0.131336 0.130029 0.128735 0.127454 0.126186 0.12493 0.123687 0.122456 0.121238 0.120032 0.118837 0.117655 0.116484 0.115325 0.114178 0.113042 0.111917 0.110803 0.109701 0.108609 0.107528 0.106459 0.105399 0.10435 0.103312 0.102284 0.101266 0.100259 0.0992613 0.0982736 0.0972958 0.0963276 0.0953692 0.0944202 0.0934807 0.0925506 0.0916297 0.0907179 0.0898153 0.0889216 0.0880368 0.0871608 0.0862936 0.085435 0.0845849 0.0837432 0.08291 0.082085 0.0812682 0.0804596 0.079659 0.0788664 0.0780817 0.0773047 0.0765356 0.075774 0.07502 0.0742736 0.0735345 0.0728029 0.0720785 0.0713613 0.0706512 0.0699482 0.0692522 0.0685631 0.0678809 0.0672055 0.0665368 0.0658748 0.0652193 0.0645703 0.0639279 0.0632918 0.062662 0.0620385 0.0614212 0.0608101 0.060205 0.0596059 0.0590129 0.0584257 0.0578443 0.0572688 0.0566989 0.0561348 0.0555762 0.0550232 0.0544757 0.0539337 0.053397 0.0528657 0.0523397 0.0518189 0.0513033 0.0507928 0.0502874 0.0497871 0.0492917 0.0488012 0.0483156 0.0478349 0.0473589 0.0468877 0.0464212 0.0459593 0.045502 0.0450492 0.044601 0.0441572 0.0437178 0.0432828 0.0428521 0.0424257 0.0420036 0.0415857 0.0411719 0.0407622 0.0403566 0.0399551 0.0395575 0.0391639 0.0387742 0.0383884 0.0380064 0.0376283 0.0372538 0.0368832 0.0365162 0.0361528 0.0357931 0.035437 0.0350844 0.0347353 0.0343896 0.0340475 0.0337087 0.0333733 0.0330412 0.0327124 0.0323869 0.0320647 0.0317456 0.0314298 0.031117 0.0308074 0.0305009 0.0301974 0.0298969 0.0295994 0.0293049 0.0290133 0.0287246 0.0284388 0.0281559 0.0278757 0.0275983 0.0273237 0.0270518 0.0267827 0.0265162 0.0262523 0.0259911 0.0257325 0.0254765 0.025223 0.024972 0.0247235 0.0244775 0.024234 0.0239928 0.0237541 0.0235177 0.0232837 0.0230521 0.0228227 0.0225956 0.0223708 0.0221482 0.0219278 0.0217096 0.0214936 0.0212797 0.021068 0.0208584 0.0206508 0.0204453 0.0202419 0.0200405 0.0198411 0.0196437 0.0194482 0.0192547 0.0190631 0.0188734 0.0186856 0.0184997 0.0183156 0.0181334 0.017953 0.0177743 0.0175975 0.0174224 0.017249 0.0170774 0.0169075 0.0167392 0.0165727 0.0164078 0.0162445 0.0160829 0.0159229 0.0157644 0.0156076 0.0154523 0.0152985 0.0151463 0.0149956 0.0148464 0.0146986 0.0145524 0.0144076 0.0142642 0.0141223 0.0139818 0.0138427 0.0137049 0.0135686 0.0134336 0.0132999 0.0131675 0.0130365 0.0129068 0.0127784 0.0126512 0.0125254 0.0124007 0.0122773 0.0121552 0.0120342 0.0119145 0.0117959 0.0116786 0.0115624 0.0114473 0.0113334 0.0112206 0.011109 0.0109985 0.010889 0.0107807 0.0106734 0.0105672 0.0104621 0.010358 0.0102549 0.0101529 0.0100518 0.00995182 0.0098528 0.00975476 0.0096577 0.0095616 0.00946646 0.00937227 0.00927902 0.00918669 0.00909528 0.00900478 0.00891518 0.00882647 0.00873865 0.0086517 0.00856561 0.00848038 0.008396 0.00831246 0.00822975 0.00814786 0.00806679 0.00798652 0.00790705 0.00782838 0.00775048 0.00767337 0.00759701 0.00752142 0.00744658 0.00737249 0.00729913 0.0072265 0.0071546 0.00708341 0.00701293 0.00694315 0.00687406 0.00680567 0.00673795 0.0066709 0.00660453 0.00653881 0.00647375 0.00640933 0.00634556 0.00628242 0.00621991 0.00615802 0.00609675 0.00603608 0.00597602 0.00591656 0.00585769 0.0057994 0.0057417 0.00568457 0.00562801 0.00557201 0.00551657 0.00546167 0.00540733 0.00535353 0.00530026 0.00524752 0.0051953 0.00514361 0.00509243 0.00504176 0.00499159 0.00494193 0.00489275 0.00484407 0.00479587 0.00474815 0.00470091 0.00465413 0.00460782 0.00456197 0.00451658 0.00447164 0.00442715 0.0043831 0.00433948 0.00429631 0.00425356 0.00421123 0.00416933 0.00412785 0.00408677 0.00404611 0.00400585 0.00396599 0.00392653 0.00388746 0.00384878 0.00381048 0.00377257 0.00373503 0.00369786 0.00366107 0.00362464 0.00358857 0.00355287 0.00351752 0.00348252 0.00344786 0.00341356 0.00337959 0.00334597 0.00331267 0.00327971 0.00324708 0.00321477 0.00318278 0.00315111 0.00311976 0.00308871 0.00305798 0.00302755 0.00299743 0.0029676 0.00293808 0.00290884 0.0028799 0.00285124 0.00282287 0.00279478 0.00276698 0.00273944 0.00271219 0.0026852 0.00265848 0.00263203 0.00260584 0.00257991 0.00255424 0.00252883 0.00250366 0.00247875 0.00245409 0.00242967 0.00240549 0.00238156 0.00235786 0.0023344 0.00231117 0.00228818 0.00226541 0.00224287 0.00222055 0.00219846 0.00217658 0.00215492 0.00213348 0.00211225 0.00209124 0.00207043 0.00204983 0.00202943 0.00200924 0.00198925 0.00196945 0.00194986 0.00193045 0.00191125 0.00189223 0.0018734 0.00185476 0.0018363 0.00181803 0.00179994 0.00178203 0.0017643 0.00174675 0.00172937 0.00171216 0.00169512 0.00167826 0.00166156 0.00164502 0.00162866 0.00161245 0.00159641 0.00158052 0.0015648 0.00154923 0.00153381 0.00151855 0.00150344 0.00148848 0.00147367 0.00145901 0.00144449 0.00143012 0.00141589 0.0014018 0.00138785 0.00137404 0.00136037 0.00134683 0.00133343 0.00132016 0.00130703 0.00129402 0.00128115 0.0012684 0.00125578 0.00124328 0.00123091 0.00121866 0.00120654 0.00119453 0.00118265 0.00117088 0.00115923 0.00114769 0.00113627 0.00112497 0.00111377 0.00110269 0.00109172 0.00108086 0.0010701 0.00105946 0.00104891 0.00103848 0.00102814 0.00101791 0.00100779 0.000997758 0.00098783 0.000978001 0.00096827 0.000958635 0.000949097 0.000939653 0.000930303 0.000921047 0.000911882 0.000902808 0.000893825 0.000884932 0.000876127 0.000867409 0.000858778 0.000850233 0.000841773 0.000833397 0.000825105 0.000816895 0.000808767 0.000800719 0.000792752 0.000784864 0.000777055 0.000769323 0.000761668 0.000754089 0.000746586 0.000739157 0.000731803 0.000724521 0.000717312 0.000710174 0.000703108 0.000696112 0.000689185 0.000682328 0.000675539 0.000668817 0.000662162 0.000655574 0.00064905 0.000642592 0.000636198 0.000629868 0.000623601 0.000617396 0.000611253 0.000605171 0.000599149 0.000593188 0.000587285 0.000581442 0.000575656 0.000569928 0.000564257 0.000558643 0.000553084 0.000547581 0.000542133 0.000536738 0.000531398 0.00052611 0.000520875 0.000515692 0.000510561 0.000505481 0.000500451 0.000495472 0.000490542 0.000485661 0.000480829 0.000476044 0.000471307 0.000466618 0.000461975 0.000457378 0.000452827 0.000448321 0.000443861 0.000439444 0.000435072 0.000430743 0.000426456 0.000422213 0.000418012 0.000413853 0.000409735 0.000405658 0.000401622 0.000397626 0.000393669 0.000389752 0.000385874 0.000382034 0.000378233 0.00037447 0.000370744 0.000367055 0.000363402 0.000359786 0.000356206 0.000352662 0.000349153 0.000345679 0.000342239 0.000338834 0.000335463 0.000332125 0.00032882 0.000325548 0.000322309 0.000319102 0.000315927 0.000312783 0.000309671 0.00030659 0.000303539 0.000300519 0.000297529 0.000294568 0.000291637 0.000288735 0.000285862 0.000283018 0.000280202 0.000277414 0.000274654 0.000271921 0.000269215 0.000266536 0.000263884 0.000261259 0.000258659 0.000256085 0.000253537 0.000251014 0.000248517 0.000246044 0.000243596 0.000241172 0.000238772 0.000236396 0.000234044 0.000231716 0.00022941 0.000227127 0.000224867 0.00022263 0.000220415 0.000218221 0.00021605 0.0002139 0.000211772 0.000209665 0.000207579 0.000205513 0.000203468 0.000201444 0.000199439 0.000197455 0.00019549 0.000193545 0.000191619 0.000189713 0.000187825 0.000185956 0.000184106 0.000182274 0.00018046 0.000178665 0.000176887 0.000175127 0.000173384 0.000171659 0.000169951 0.00016826 0.000166586 0.000164928 0.000163287 0.000161663 0.000160054 0.000158461 0.000156885 0.000155324 0.000153778 0.000152248 0.000150733 0.000149233 0.000147748 0.000146278 0.000144823 0.000143382 0.000141955 0.000140543 0.000139144 0.00013776 0.000136389 0.000135032 0.000133688 0.000132358 0.000131041 0.000129737 0.000128446 0.000127168 0.000125903 0.00012465 0.00012341 0.000122182 0.000120966 0.000119763 0.000118571 0.000117391 0.000116223 0.000115067 0.000113922 0.000112788 0.000111666 0.000110555 0.000109455 0.000108366 0.000107287 0.00010622 0.000105163 0.000104117 0.00010308 0.000102055 0.000101039 0.000100034 9.90387e-05 9.80533e-05 9.70776e-05 9.61117e-05 9.51553e-05 9.42085e-05 9.32711e-05 9.23431e-05 9.14242e-05 9.05145e-05 8.96139e-05 8.87222e-05 8.78394e-05 8.69654e-05 8.61001e-05 8.52434e-05 8.43952e-05 8.35554e-05 8.27241e-05 8.1901e-05 8.1086e-05 8.02792e-05 7.94804e-05 7.86896e-05 7.79066e-05 7.71314e-05 7.6364e-05 7.56041e-05 7.48518e-05 7.4107e-05 7.33696e-05 7.26396e-05 7.19169e-05 7.12012e-05 7.04928e-05 6.97914e-05 6.9097e-05 6.84094e-05 6.77287e-05 6.70548e-05 6.63876e-05 6.5727e-05 6.5073e-05 6.44256e-05 6.37845e-05 6.31498e-05 6.25215e-05 6.18994e-05 6.12835e-05 6.06737e-05 6.007e-05 5.94723e-05 5.88805e-05 5.82947e-05 5.77146e-05 5.71403e-05 5.65718e-05 5.60089e-05 5.54516e-05 5.48998e-05 5.43536e-05 5.38128e-05 5.32773e-05 5.27472e-05 5.22224e-05 5.17027e-05 5.11883e-05 5.06789e-05 5.01747e-05 4.96754e-05 4.91812e-05 4.86918e-05 4.82073e-05 4.77276e-05 4.72527e-05 4.67826e-05 4.63171e-05; #A 1000 0 0 0; #X coords 0 1 1002 0 180 100 1; #X restore 254 118 graph; #N canvas 140 79 589 249 make-table 0; #X obj 164 81 t b b; #X obj 236 106 f; #X obj 274 106 + 1; #X msg 258 83 0; #X obj 164 104 until; #X obj 236 136 t f f; #X obj 164 62 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 -1; #X obj 104 164 expr exp(-($f1-1)/100); #X obj 163 132 sel 999; #X text 35 10 This patch computes a decaying exponential function \, 100 points per unit.; #X obj 137 196 tabwrite E06-tab; #X connect 0 0 4 0; #X connect 0 1 3 0; #X connect 1 0 2 0; #X connect 1 0 5 0; #X connect 1 0 8 0; #X connect 2 0 1 1; #X connect 3 0 1 1; #X connect 4 0 1 0; #X connect 5 0 7 0; #X connect 5 1 10 1; #X connect 6 0 0 0; #X connect 7 0 10 0; #X connect 8 0 4 1; #X restore 302 258 pd make-table; #X text 252 85 waveshaping function; #X text 438 210 0; #X text 437 114 1; #X obj 12 168 +~ 1; #X obj 12 146 *~ 100; #X obj 12 83 +~ 1; #X floatatom 68 53 5 0 200 0 - - -; #X obj 68 96 pack 0 50; #X obj 68 120 line~; #X text 157 69 tenths; #X obj 68 73 / 10; #X obj 12 124 *~; #X obj 13 190 tabread4~ E06-tab; #X text 711 40 1; #X text 712 160 -1; #X text 103 237 <-- repeatedly; #X text 104 217 <-- graph once; #X text 121 0 Waveshaping using an exponential function; #X text 120 53 <--index in; #X text 250 218 0; #X text 417 220 10; #X text 14 652 When the index of modulation exceeds 5 we scan past the right hand border of the table (the thousandth point \, corresponding to exp(-10). This isn't a problem because the values are all close to zero there.; #X text 14 555 Table lookup is prepared as follows. First add one to the sinusoid and adjust its amplitude according to index \; it ranges from 0 to 2*index. Then adjust for the table's input scale (100 points per unit \, so multiply by 100) and add one to skip the interpolation point at the beginning of the table.; #X text 13 398 Here we use an exponential function as a waveshaping transfer function. The theory is shown in detail in the accompanying book \, but in short \, we adjust the sinusoid so that \, as the index increases \, we scan starting from the left of the transfer function (previously the reading location grew from the center). The table contains exp(-x) with x varying from 0 to 10 When the index is zero \, the output is the constant 1 and the spectrum holds only DC. As the index grows \, the output is a sequence of steadily narrower pulses \, whose spectrum gets progressively fatter.; #X connect 1 0 6 0; #X connect 1 0 6 1; #X connect 5 0 3 1; #X connect 18 0 19 0; #X connect 19 0 33 0; #X connect 25 0 3 2; #X connect 31 0 40 0; #X connect 32 0 31 0; #X connect 33 0 39 0; #X connect 34 0 38 0; #X connect 35 0 36 0; #X connect 36 0 39 1; #X connect 38 0 35 0; #X connect 39 0 32 0; #X connect 40 0 3 0; #X connect 40 0 1 0;