#N canvas 400 82 777 632 12;
#X declare -stdpath ./;
#N canvas 0 0 450 300 (subpatch) 0;
#X array F05-signal 882 float 0;
#X coords 0 1 882 -1 255 130 1;
#X restore 453 310 graph;
#N canvas 0 0 450 300 (subpatch) 0;
#X array F05-spectrum 256 float 0;
#X coords 0 0.51 255 -0.008 256 130 1;
#X restore 453 91 graph;
#X text 519 446 ---- 0.02 seconds ----;
#X text 449 224 0;
#X text 715 211 0;
#X text 712 88 0.5;
#X floatatom 89 187 5 0 200 0 - - - 0;
#N canvas 669 117 574 518 pulse-train 0;
#X obj 229 289 line~;
#X obj 99 368 cos~;
#X obj 229 265 pack 0 50;
#X obj 99 246 -~ 0.5;
#X obj 99 300 *~;
#X obj 183 183 / 10;
#X obj 183 207 moses 0;
#X msg 183 231 0;
#X obj 99 344 clip~ -0.5 0.5;
#X obj 229 313 +~ 1;
#X obj 99 392 +~ 1;
#X obj 183 159 inlet;
#X obj 99 460 outlet~;
#X obj 99 416 *~ 0.5;
#X text 57 23 This is a modified version of the pulse train generator from two examples back.;
#X text 56 72 We have to add 1/2 and wrap so that the center of the pulse comes at phase zero (previously it was 1/2 cycle out of phase). This wasn't a problem before but now we have to be in phase with the oscillator we're multiplying with.;
#X text 262 160 otherwise it's the same as before.;
#X obj 99 202 phasor~;
#X obj 99 175 r freq;
#X connect 0 0 9 0;
#X connect 1 0 10 0;
#X connect 2 0 0 0;
#X connect 3 0 4 0;
#X connect 4 0 8 0;
#X connect 5 0 6 0;
#X connect 6 0 7 0;
#X connect 6 1 2 0;
#X connect 7 0 2 0;
#X connect 8 0 1 0;
#X connect 9 0 4 1;
#X connect 10 0 13 0;
#X connect 11 0 5 0;
#X connect 13 0 12 0;
#X connect 17 0 3 0;
#X connect 18 0 17 0;
#X restore 89 212 pd pulse-train;
#X obj 89 355 *~;
#X text 189 270 multiple of fundamental;
#X obj 89 422 output~;
#X obj 136 362 bng 19 250 50 0 empty empty empty 0 -6 0 8 #dfdfdf #000000 #000000;
#X obj 177 388 tgl 19 0 empty empty empty 0 -6 0 8 #dfdfdf #000000 #000000 0 1;
#X text 481 224 2;
#X text 513 224 4;
#X text 545 224 6;
#X text 577 224 8;
#X text 610 224 10;
#X text 642 224 12;
#X text 673 224 14;
#X text 710 307 1;
#X text 710 426 -1;
#X text 156 326 modulating oscillator;
#X text 53 62 Now we take a pulse train and ring modulate it \, which effectively aliases the spectrum so that it is centered at any desired partial number. The "bandwidth" control still affects the shape of the peak \, independently of where it is centered. This generates a formant centered at the given partial., f 50;
#X floatatom 107 257 6 0 100 0 - - - 0;
#X obj 107 323 osc~;
#X obj 107 295 *;
#X obj 141 295 r freq;
#X text 166 513 This patch is limited to making formants centered on harmonics. The center frequency thus can't be moved smoothly up and down at will (try shift-clicking on modulation frequency to make fractions). Next we'll look at two techniques for sliding a formant frequency without losing harmonicity., f 68;
#X text 201 227 generator from before;
#X text 158 362 <-- graph once;
#X text 198 387 <-- repeatedly;
#X text 131 187 <-- bandwidth;
#X text 202 211 <-- pulse train;
#X text 161 256 <-- modulation frequency as;
#N canvas 715 281 537 493 fft 0;
#X obj 43 105 inlet~;
#X obj 142 264 inlet;
#X obj 63 136 rfft~;
#X obj 63 169 *~;
#X obj 95 169 *~;
#X obj 63 199 sqrt~;
#X obj 63 225 biquad~ 0 0 0 0 1;
#X text 127 137 Fourier series;
#X text 132 190 magnitude;
#X text 130 175 calculate;
#X text 60 26 This subpatch computes the spectrum of the incoming signal with a (rectangular windowed) FFT. FFTs aren't properly introduced until much later.;
#X text 105 104 signal to analyze;
#X text 194 216 delay two samples;
#X text 192 234 for better graphing;
#X obj 178 328 metro 500;
#X obj 178 292 inlet;
#X text 231 290 toggle to graph repeatedly, f 15;
#X text 185 264 bang to graph once;
#X obj 63 249 /~ 4096;
#X obj 366 153 block~ 4096;
#X text 368 126 Window size;
#X obj 142 360 b;
#X obj 143 396 tabwrite~ F05-spectrum;
#X obj 43 422 tabwrite~ F05-signal;
#X connect 0 0 2 0;
#X connect 0 0 23 0;
#X connect 1 0 21 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 6 0;
#X connect 6 0 18 0;
#X connect 14 0 21 0;
#X connect 15 0 14 0;
#X connect 18 0 22 0;
#X connect 21 0 22 0;
#X connect 21 0 23 0;
#X restore 117 388 pd fft;
#X text 477 252 ------ partial number ------;
#X obj 30 20 cnv 5 5 25 empty empty Ring\ Modulated\ Pulse\ Trains 15 13 0 16 #dfdfdf #202020 0;
#N canvas 264 120 348 434 init 0;
#X obj 118 193 samplerate~;
#X floatatom 118 249 9 0 0 0 - - - 0;
#X obj 83 336 declare -stdpath ./;
#X obj 118 221 / 256;
#X obj 118 277 s freq;
#X text 26 48 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 27 17 This subpatch initializes the patch.;
#X obj 118 154 loadbang;
#X connect 0 0 3 0;
#X connect 1 0 4 0;
#X connect 3 0 1 0;
#X connect 7 0 0 0;
#X restore 250 439 pd init;
#X connect 6 0 7 0;
#X connect 7 0 8 0;
#X connect 8 0 35 0;
#X connect 8 0 10 0;
#X connect 11 0 35 1;
#X connect 12 0 35 2;
#X connect 24 0 26 0;
#X connect 25 0 8 1;
#X connect 26 0 25 0;
#X connect 27 0 26 1;
