#N canvas 375 55 624 683 10;
#N canvas 0 0 450 300 (subpatch) 0;
#X array E01-signal 882 float 0;
#X coords 0 5 882 -5 200 130 1;
#X restore 381 61 graph;
#X obj 21 304 hip~ 5;
#N canvas 0 0 450 300 (subpatch) 0;
#X array E01-spectrum 128 float 0;
#X coords 0 4300 127 -40 257 130 1;
#X restore 235 246 graph;
#X text 115 243 <-- click to graph;
#N canvas 45 83 558 569 fft 0;
#X obj 19 62 inlet~;
#X obj 85 214 inlet;
#X obj 19 92 rfft~;
#X obj 19 125 *~;
#X obj 50 125 *~;
#X obj 19 155 sqrt~;
#X obj 85 248 tabwrite~ E01-spectrum;
#X obj 332 109 block~ 4096 1;
#X obj 19 181 biquad~ 0 0 0 0 1;
#X text 83 93 Fourier series;
#X text 88 146 magnitude;
#X text 86 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 62 signal to analyze;
#X text 182 166 delay two samples;
#X text 181 182 for better graphing;
#X obj 90 425 samplerate~;
#X obj 90 402 bng 18 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
-1;
#X floatatom 90 472 5 0 0 0 - - -, f 5;
#X obj 90 448 / 256;
#X obj 90 378 loadbang;
#X floatatom 90 541 5 0 0 0 - - -, f 5;
#X obj 98 494 s fundamental;
#X obj 90 517 ftom;
#X text 146 540 <-just out of curiosity \, here's the pitch;
#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 text 135 216 "bang" into this inlet to graph it;
#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 8 0;
#X connect 8 0 6 0;
#X connect 16 0 19 0;
#X connect 17 0 16 0;
#X connect 18 0 22 0;
#X connect 18 0 23 0;
#X connect 19 0 18 0;
#X connect 20 0 17 0;
#X connect 23 0 21 0;
#X restore 32 279 pd fft;
#X text 401 193 ---- 0.02 seconds ----;
#X obj 92 244 bng 18 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
-1;
#X obj 21 332 output~;
#X obj 92 279 tabwrite~ E01-signal;
#X text 266 379 1;
#X text 300 379 2;
#X text 332 379 3;
#X text 364 379 4;
#X text 397 379 5;
#X text 427 379 6;
#X text 458 379 7;
#X text 234 379 0;
#X text 295 398 -- partial number --;
#X text 583 117 0;
#X obj 23 42 r fundamental;
#X obj 23 111 osc~;
#X obj 37 136 tgl 18 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
;
#X obj 22 161 *~;
#X obj 66 111 osc~;
#X obj 80 136 tgl 18 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
;
#X obj 65 161 *~;
#X obj 109 111 osc~;
#X obj 123 136 tgl 18 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
1;
#X obj 108 161 *~;
#X obj 109 88 * 2;
#X obj 152 111 osc~;
#X obj 166 136 tgl 18 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
1;
#X obj 151 161 *~;
#X obj 195 111 osc~;
#X obj 209 136 tgl 18 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
1;
#X obj 194 161 *~;
#X obj 238 111 osc~;
#X obj 252 136 tgl 18 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
1;
#X obj 237 161 *~;
#X obj 23 88 * 0;
#X obj 66 88 * 1;
#X obj 152 88 * 3;
#X obj 195 88 * 4;
#X obj 238 88 * 5;
#X text 277 136 <-- On/Off;
#X text 311 152 for each;
#X text 313 168 partial;
#X text 455 31 WAVEFORM;
#X text 328 224 SPECTRUM;
#X text 19 425 The 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 it).;
#X text 18 522 The partials are numbered 0 through 5 \, where 0 means
DC \, or zero 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.;
#X text 495 364 0;
#X text 493 243 1;
#X text 494 302 0.5;
#X text 18 586 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.;
#X obj 22 222 *~ 1;
#X text 583 57 5;
#X text 584 177 -5;
#X text 62 221 sum;
#X text 18 672 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.;
#X obj 1 1 cnv 15 445 20 empty \$0-pddp.cnv.header graphing_spectra_of_audio_signals
20 10 1 18 -261139 -33289 0;
#X obj 407 2 pddp/pddplink http://puredata.info/dev/pddp -text pddp
;
#X obj 1 727 cnv 15 445 20 empty \$0-pddp.cnv.footer empty 20 12 0
14 -233017 -33289 0;
#N canvas 44 246 494 284 META 0;
#X text 12 125 WEBSITE http://crca.ucsd.edu/~msp/;
#X text 12 105 AUTHOR Miller Puckette;
#X text 12 85 LIBRARY PDDP;
#X text 12 5 GENRE tutorial;
#X text 12 45 LICENSE SIBSD;
#X text 12 145 HELP_PATCH_AUTHORS Updated for release 0.37. Jonathan
Wilkes revised the patch to conform to the PDDP template for Pd version
0.42.;
#X text 12 25 KEYWORDS signal;
#X text 12 65 DESCRIPTION graphing spectra of audio signals;
#X restore 392 729 pd META;
#N canvas 13 202 428 190 References 0;
#X obj 1 1 cnv 15 425 20 empty \$0-pddp.cnv.subheading empty 3 12 0
14 -261139 -33289 0;
#X text 7 2 spectrum- Related Help Documents;
#X text 19 37 links:;
#X restore 103 729 pd References;
#X obj 6 729 pddp/pddplink ../5.reference/pddp/help.pd -text help;
#X connect 1 0 7 0;
#X connect 1 0 7 1;
#X connect 6 0 4 1;
#X connect 6 0 8 0;
#X connect 19 0 39 0;
#X connect 19 0 40 0;
#X connect 19 0 29 0;
#X connect 19 0 41 0;
#X connect 19 0 42 0;
#X connect 19 0 43 0;
#X connect 20 0 22 0;
#X connect 21 0 22 1;
#X connect 22 0 55 0;
#X connect 23 0 25 0;
#X connect 24 0 25 1;
#X connect 25 0 55 0;
#X connect 26 0 28 0;
#X connect 27 0 28 1;
#X connect 28 0 55 0;
#X connect 29 0 26 0;
#X connect 30 0 32 0;
#X connect 31 0 32 1;
#X connect 32 0 55 0;
#X connect 33 0 35 0;
#X connect 34 0 35 1;
#X connect 35 0 55 0;
#X connect 36 0 38 0;
#X connect 37 0 38 1;
#X connect 38 0 55 0;
#X connect 39 0 20 0;
#X connect 40 0 23 0;
#X connect 41 0 30 0;
#X connect 42 0 33 0;
#X connect 43 0 36 0;
#X connect 55 0 4 0;
#X connect 55 0 1 0;
#X connect 55 0 8 0;
