I03.resynthesis.pd 5.54 KB
Newer Older
1
#N canvas 377 49 580 400 10;
Miller Puckette's avatar
Miller Puckette committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
#N canvas 265 48 643 640 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 353 *~;
#X obj 56 353 *~;
#X obj 15 8 block~ 512 4;
#X text 85 88 The inlet~ now re-uses 3/4 of the previous block \, along
with the 128 new samples.;
#X text 221 141 window function as before.;
#X obj 76 196 tabreceive~ \$0-gain;
#X obj 77 225 *~;
#X obj 16 506 *~;
#X obj 37 481 tabreceive~ \$0-hann;
#X obj 77 283 /~ 768;
#X text 98 301 divide by 3N/2 (factor of N because rfft and rifft aren't
normalized \, and 3/2 is the gain of overlap-4 reconstruction when
Hann window function is applied twice.);
#X text 120 216 Just to show we're doing something \, we multiply each
channel by a gain controlled by an array in the main window. The control
is quartic-scaled for easy editing.;
#X obj 78 251 *~;
#X text 92 357 Multiply the (complex-valued) spectrum amplitudes by
the (real-valued) gain-and-normalization-factor;
#X obj 15 399 rifft~;
#X text 89 396 Real-valued inverse Fourier transform. This uses only
the first N/@ points of its inputs \, supplying the rest by symmerty
(so it's OK that rfft~ obly puts out those N/2 points.) There's only
one outlet because the output is real-valued.;
#X obj 16 566 outlet~;
#X text 88 499 Multiply by the Hann window function again \, necessary
because the operation we performed might result in a signal that doesn't
go smoothly to zero at both ends.;
#X text 89 566 This repackages the output into 64-sample chunks for
the parent window. Since we're operating with an overlap \, the outlet~
object performs an overlapped sum of the blocks computed in this window.
;
#X text 129 8 block~ object specifies vector size of 512 and overlap
four. This window now computes blocks of 512 samples at intervals of
128 samples computed on the parent patch.;
#X connect 0 0 2 0;
#X connect 1 0 0 0;
#X connect 2 0 4 0;
#X connect 2 1 5 0;
#X connect 3 0 0 1;
#X connect 4 0 18 0;
#X connect 5 0 18 1;
#X connect 9 0 10 0;
#X connect 9 0 10 1;
#X connect 10 0 16 0;
#X connect 10 0 16 1;
#X connect 11 0 20 0;
#X connect 12 0 11 1;
#X connect 13 0 4 1;
#X connect 13 0 5 1;
#X connect 16 0 13 0;
#X connect 18 0 11 0;
60
#X restore 23 279 pd fft-analysis;
Miller Puckette's avatar
Miller Puckette committed
61
#N canvas 35 66 592 433 Hann-window 0;
62
#N canvas 0 0 450 300 (subpatch) 0;
63
#X array \$0-hann 512 float 0 black black;
Miller Puckette's avatar
Miller Puckette committed
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
#X coords 0 1 511 0 200 120 1;
#X restore 293 249 graph;
#X msg 171 263 0;
#X obj 65 312 osc~;
#X obj 65 264 samplerate~;
#X obj 65 335 *~ -0.5;
#X obj 65 358 +~ 0.5;
#X obj 57 383 tabwrite~ \$0-hann;
#X text 279 241 1;
#X text 272 359 0;
#X text 288 372 0;
#X obj 65 288 / 512;
#X obj 57 241 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
-1;
#X text 336 221 Hann window;
#X text 113 310 period 512;
#X text 90 215 recalculate Hann;
#X text 125 230 window table;
#X obj 57 146 loadbang;
#X msg 79 179 \; pd dsp 1;
#X text 40 27 The Hann window is now recomputed on 'loadbang' to make
the file smaller (it doesn't have to be saved with the array.);
#X text 474 375 511;
#X connect 1 0 2 1;
#X connect 2 0 4 0;
#X connect 3 0 10 0;
#X connect 4 0 5 0;
#X connect 5 0 6 0;
#X connect 10 0 2 0;
#X connect 11 0 3 0;
#X connect 11 0 1 0;
#X connect 11 0 6 0;
#X connect 16 0 11 0;
#X connect 16 0 17 0;
98 99 100 101
#X restore 152 340 pd Hann-window;
#X obj 24 313 output~;
#X obj 22 254 noise~;
#N canvas 0 0 450 300 (subpatch) 0;
102
#X array \$0-gain 256 float 3 black black;
Miller Puckette's avatar
Miller Puckette committed
103 104 105 106 107 108 109 110 111
#A 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
#X coords 0 1 256 -0.01 512 60 1;
112 113 114 115 116 117 118 119 120 121
#X restore 35 157 graph;
#X msg 152 293 const 0;
#X obj 152 315 s \$0-gain;
#X text 19 207 0;
#X text 19 148 1;
#X text 32 217 0;
#X text 529 220 22K;
#X text 210 293 <- reset gain;
#X text 237 137 GAIN;
#X text 19 37 Using Fourier resynthesis you can take an incoming sound
Miller Puckette's avatar
Miller Puckette committed
122 123 124 125 126
\, operate on its spectrum \, and hear the result. Here we start with
white noise and apply a frequency-dependent gain \, which works as
a graphic equalizer. There are N/2 = 256 points \, each spaced SR/512
Hz. apart (although their frequency ranges overlap). Open the "fft-analysis"
patch to see the workings.;
127 128 129 130 131 132 133
#X obj 1 1 cnv 15 445 20 empty \$0-pddp.cnv.header Fourier_resynthesis
20 10 1 18 -261139 -33289 0;
#X obj 407 2 pddp/pddplink http://puredata.info/dev/pddp -text pddp
;
#X obj 1 378 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;
134 135 136 137 138
#X text 12 105 WEBSITE http://crca.ucsd.edu/~msp/;
#X text 12 85 AUTHOR Miller Puckette;
#X text 12 65 LIBRARY PDDP;
#X text 12 25 LICENSE SIBSD;
#X text 12 125 HELP_PATCH_AUTHORS Updated for release 0.39. Jonathan
139 140
Wilkes revised the patch to conform to the PDDP template for Pd version
0.42.;
141 142
#X text 12 45 DESCRIPTION Fourier resynthesis;
#X text 12 5 KEYWORDS signal tutorial;
143 144 145 146 147 148 149 150 151 152 153 154
#X restore 392 380 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 Fourier resynthesis- Related Help Documents;
#X text 19 37 Links:;
#X restore 103 380 pd References;
#X obj 6 380 pddp/pddplink ../5.reference/pddp/help.pd -text help;
#X connect 0 0 2 0;
#X connect 0 0 2 1;
#X connect 3 0 0 0;
#X connect 5 0 6 0;