#N canvas 444 62 733 767 12;
#X declare -stdpath ./;
#N canvas 0 0 450 300 (subpatch) 0;
#X array E01-signal 882 float 0;
#X coords 0 6 882 -6 247 147 1 0 0;
#X restore 424 49 graph;
#N canvas 0 0 450 300 (subpatch) 0;
#X array E01-spectrum 90 float 0;
#X coords 0 4300 89 -40 255 130 1 0 0;
#X restore 419 290 graph;
#N canvas 310 109 526 363 fft 0;
#X obj 163 92 inlet~;
#X obj 298 92 inlet;
#X obj 163 122 rfft~;
#X obj 163 155 *~;
#X obj 195 155 *~;
#X obj 163 185 sqrt~;
#X obj 298 301 tabwrite~ E01-spectrum;
#X obj 163 222 biquad~ 0 0 0 0 1;
#X text 53 122 Fourier series;
#X text 36 10 This subpatch computes the spectrum of the incoming signal with a (rectangular windowed) FFT. FFTs aren't properly introduced until much later., f 66;
#X text 31 93 signal to analyze;
#X text 355 87 "bang" into this inlet to graph it, f 18;
#X obj 354 214 block~ 4096;
#X text 79 214 delay two samples for better graphing, f 10;
#X text 86 162 calculate magnitude, f 9;
#X text 351 174 FFT Window size of 4096, f 12;
#X connect 0 0 2 0;
#X connect 1 0 6 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 6 0;
#X restore 138 348 pd fft;
#X text 479 207 ---- 0.02 seconds ----;
#X obj 198 313 bng 19 250 50 0 empty empty empty 0 -6 0 8 #dfdfdf #000000 #000000;
#X obj 126 393 output~;
#X obj 198 348 tabwrite~ E01-signal;
#X text 465 423 1;
#X text 511 423 2;
#X text 556 423 3;
#X text 602 423 4;
#X text 648 423 5;
#X text 420 423 0;
#X text 680 114 0;
#X obj 40 156 osc~;
#X obj 40 210 *~;
#X obj 83 156 osc~;
#X obj 83 210 *~;
#X obj 126 156 osc~;
#X obj 126 210 *~;
#X obj 169 156 osc~;
#X obj 169 210 *~;
#X obj 212 156 osc~;
#X obj 212 210 *~;
#X obj 255 156 osc~;
#X obj 255 210 *~;
#X text 554 17 WAVEFORM;
#X text 679 408 0;
#X text 677 287 1;
#X text 678 346 0.5;
#X text 38 638 The upper graph is just the (time domain) waveform \, about four periods long. The lower graph is the magnitude spectrum. Its peaks are the magnitudes of the partials. Note that a DC signal of amplitude one is considered a partial of magnitude 1 \, but the other partials \, which have peak amplitudes of 1 (and RMS 0.707) \, have peak magnitudes of only 0.5 in the spectrum., f 95;
#X obj 126 267 *~ 1;
#X text 92 267 sum;
#X text 38 704 Here we're introducing a new feature: multiple signals connected to a signal inlet (as in the [*~ 1]) are added. This is the most convenient way to sum the six partials., f 95;
#X obj 58 185 tgl 18 0 empty empty empty 0 -6 0 8 #dfdfdf #000000 #000000 0 1;
#X obj 101 185 tgl 18 0 empty empty empty 0 -6 0 8 #dfdfdf #000000 #000000 0 1;
#X obj 144 185 tgl 18 0 empty empty empty 0 -6 0 8 #dfdfdf #000000 #000000 0 1;
#X obj 187 185 tgl 18 0 empty empty empty 0 -6 0 8 #dfdfdf #000000 #000000 0 1;
#X obj 230 185 tgl 18 0 empty empty empty 0 -6 0 8 #dfdfdf #000000 #000000 0 1;
#X obj 273 185 tgl 18 0 empty empty empty 0 -6 0 8 #dfdfdf #000000 #000000 0 1;
#X text 679 46 6;
#X text 675 185 -6;
#X obj 40 129 * 0;
#X obj 83 129 * 1;
#X obj 126 129 * 2;
#X obj 169 129 * 3;
#X obj 212 129 * 4;
#X obj 255 129 * 5;
#X text 297 185 <--;
#X text 323 185 On/Off for each partial, f 8;
#X text 545 262 SPECTRAL ANALYSIS;
#X text 456 452 ------ partial number ------;
#X obj 29 18 cnv 5 5 25 empty empty Graphing\ Spectra\ of\ Audio\ Signals 15 13 0 16 #dfdfdf #202020 0;
#N canvas 257 117 386 482 init 0;
#X obj 84 196 samplerate~;
#X obj 84 170 bng 18 250 50 0 empty empty empty 0 -6 0 8 #dfdfdf #000000 #000000;
#X floatatom 84 248 8 0 0 0 - - - 0;
#X obj 84 221 / 256;
#X obj 84 146 loadbang;
#X floatatom 84 330 9 0 0 0 - - - 0;
#X obj 92 276 s fundamental;
#X obj 84 303 ftom;
#X text 44 54 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., f 42;
#X text 161 330 <-- just out of curiosity \, here's the pitch, f 18;
#X obj 109 423 declare -stdpath ./;
#X text 198 275 <-- send to number box, f 11;
#X text 43 16 This subpatch initializes the patch.;
#X connect 0 0 3 0;
#X connect 1 0 0 0;
#X connect 2 0 6 0;
#X connect 2 0 7 0;
#X connect 3 0 2 0;
#X connect 4 0 1 0;
#X connect 7 0 5 0;
#X restore 316 127 pd init;
#X floatatom 126 90 8 0 0 0 - - - 0;
#X obj 198 260 tgl 19 0 empty empty empty 0 -10 0 12 #dfdfdf #000000 #000000 0 1;
#X text 223 259 <-- graph repeatedly;
#X text 221 313 <-- graph once;
#X text 38 493 This next series of patches demonstrates various kinds of modulation: AM \, waveshaping \, and FM. We will need a tool for graphing spectra which is introduced here. In this patch the signal to be analyzed is a simple sum of up to six partials of a fundamental frequency \, which is 172 Hz (close to F below middle C \, if your sample rate happens to be 44100 Hz). The fundamental is chosen to agree with the analysis patch ([pd FFT]) and is computed within [pd init]., f 95;
#X text 38 572 The partials are the multipliers in the [*] objects and go from 0 through 5 \, where 0 means DC (or 0 Hz frequency) \, 1 is the fundamental \, and so on. The toggle switches allow you to turn them on and off separately. You have to press the "click to graph" button to update the two graphs or use the toggle button to graph repeatedly., f 95;
#X obj 198 285 metro 500;
#X obj 126 63 r fundamental;
#X connect 4 0 2 1;
#X connect 4 0 6 0;
#X connect 14 0 15 0;
#X connect 15 0 31 0;
#X connect 16 0 17 0;
#X connect 17 0 31 0;
#X connect 18 0 19 0;
#X connect 19 0 31 0;
#X connect 20 0 21 0;
#X connect 21 0 31 0;
#X connect 22 0 23 0;
#X connect 23 0 31 0;
#X connect 24 0 25 0;
#X connect 25 0 31 0;
#X connect 31 0 2 0;
#X connect 31 0 6 0;
#X connect 31 0 5 0;
#X connect 34 0 15 1;
#X connect 35 0 17 1;
#X connect 36 0 19 1;
#X connect 37 0 21 1;
#X connect 38 0 23 1;
#X connect 39 0 25 1;
#X connect 42 0 14 0;
#X connect 43 0 16 0;
#X connect 44 0 18 0;
#X connect 45 0 20 0;
#X connect 46 0 22 0;
#X connect 47 0 24 0;
#X connect 54 0 42 0;
#X connect 54 0 43 0;
#X connect 54 0 44 0;
#X connect 54 0 45 0;
#X connect 54 0 46 0;
#X connect 54 0 47 0;
#X connect 55 0 60 0;
#X connect 60 0 4 0;
#X connect 61 0 54 0;
