E05.chebychev.pd 9.35 KB
Newer Older
1
#N canvas 340 28 573 523 10;
2 3 4 5 6 7 8 9 10 11 12 13
#X obj 22 282 output~;
#X obj 44 87 / 100;
#X floatatom 44 67 5 0 100 0 - - -, f 5;
#X obj 22 157 *~;
#X obj 21 42 osc~ 220;
#X obj 44 110 pack 0 50;
#X obj 44 134 line~;
#X text 96 67 <-- index in;
#X text 116 81 hundredths;
#X obj 22 182 *~ 128;
#X obj 22 230 tabread4~ E05-tab;
#N canvas 0 0 450 300 (subpatch) 0;
14
#X array E05-tab 259 float 1 black black;
Miller Puckette's avatar
Miller Puckette committed
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
#A 0 -1.20148 -1 -0.810724 -0.63326 -0.467216 -0.31221 -0.167866 -0.0338144
0.0903053 0.204849 0.310166 0.406597 0.494477 0.574137 0.645895 0.71007
0.766969 0.816895 0.860145 0.897008 0.927771 0.952708 0.972093 0.98619
0.995261 0.999557 0.999329 0.994816 0.986257 0.97388 0.957912 0.938572
0.916074 0.890625 0.86243 0.831684 0.798582 0.76331 0.726049 0.686977
0.646266 0.60408 0.560583 0.515931 0.470276 0.423765 0.37654 0.328738
0.280493 0.231934 0.183183 0.13436 0.0855808 0.0369554 -0.01141 -0.0594134
-0.106956 -0.153946 -0.200292 -0.245909 -0.290715 -0.334633 -0.377589
-0.419512 -0.460337 -0.5 -0.538443 -0.57561 -0.611449 -0.645912 -0.678953
-0.710532 -0.740609 -0.76915 -0.796122 -0.821497 -0.845248 -0.867354
-0.887794 -0.906551 -0.923612 -0.938965 -0.952601 -0.964516 -0.974704
-0.983167 -0.989906 -0.994925 -0.99823 -0.999832 -0.999741 -0.997972
-0.994539 -0.98946 -0.982757 -0.97445 -0.964564 -0.953125 -0.94016
-0.925699 -0.909772 -0.892414 -0.873658 -0.85354 -0.832098 -0.809372
-0.785401 -0.760228 -0.733895 -0.706446 -0.677928 -0.648387 -0.61787
-0.586426 -0.554105 -0.520957 -0.487033 -0.452386 -0.417069 -0.381135
-0.344638 -0.307632 -0.270174 -0.232319 -0.194122 -0.15564 -0.11693
-0.0780487 -0.039053 0 0.039053 0.0780487 0.11693 0.15564 0.194122
0.232319 0.270174 0.307632 0.344638 0.381135 0.417069 0.452386 0.487033
0.520957 0.554105 0.586426 0.61787 0.648387 0.677928 0.706446 0.733895
0.760228 0.785401 0.809372 0.832098 0.85354 0.873658 0.892414 0.909772
0.925699 0.94016 0.953125 0.964564 0.97445 0.982757 0.98946 0.994539
0.997972 0.999741 0.999832 0.99823 0.994925 0.989906 0.983167 0.974704
0.964516 0.952601 0.938965 0.923612 0.906551 0.887794 0.867354 0.845248
0.821497 0.796122 0.76915 0.740609 0.710532 0.678953 0.645912 0.611449
0.57561 0.538443 0.5 0.460337 0.419512 0.377589 0.334633 0.290715 0.245909
0.200292 0.153946 0.106956 0.0594134 0.01141 -0.0369554 -0.0855808
-0.13436 -0.183183 -0.231934 -0.280493 -0.328738 -0.37654 -0.423765
-0.470276 -0.515931 -0.560583 -0.60408 -0.646266 -0.686977 -0.726049
-0.76331 -0.798582 -0.831684 -0.86243 -0.890625 -0.916074 -0.938572
-0.957912 -0.97388 -0.986257 -0.994816 -0.999329 -0.999557 -0.995261
-0.98619 -0.972093 -0.952708 -0.927771 -0.897008 -0.860145 -0.816895
-0.766969 -0.71007 -0.645895 -0.574137 -0.494477 -0.406597 -0.310166
-0.204849 -0.0903053 0.0338144 0.167866 0.31221 0.467216 0.63326 0.810724
1 1.20148;
#X coords 0 1 258 -1 200 140 1;
51 52
#X restore 202 66 graph;
#X text 437 48 subpatch to;
Miller Puckette's avatar
Miller Puckette committed
53 54 55 56 57 58 59 60 61 62 63 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 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
#N canvas 113 0 849 700 make-table 0;
#X obj 141 304 t b b;
#X obj 213 329 f;
#X obj 251 329 + 1;
#X msg 235 306 0;
#X obj 141 327 until;
#X obj 213 359 t f f;
#X obj 114 436 tabwrite E05-tab;
#X obj 140 355 sel 258;
#X text 203 172 normalize from -1 to 1;
#X obj 141 285 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
-1;
#X obj 88 386 expr ($f1-129)/128;
#X obj 141 262 inlet;
#X obj 171 534 t b b;
#X obj 243 559 f;
#X obj 281 559 + 1;
#X msg 265 536 0;
#X obj 171 557 until;
#X obj 243 589 t f f;
#X obj 144 666 tabwrite E05-tab;
#X obj 170 585 sel 258;
#X obj 171 515 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
-1;
#X obj 118 616 expr ($f1-129)/128;
#X obj 171 492 inlet;
#X obj 444 228 t b b;
#X obj 516 253 f;
#X obj 554 253 + 1;
#X msg 538 230 0;
#X obj 444 251 until;
#X obj 516 283 t f f;
#X obj 417 360 tabwrite E05-tab;
#X obj 443 279 sel 258;
#X obj 391 334 expr 16*$f1*$f1*$f1*$f1*$f1-20*$f1*$f1*$f1+5*$f1;
#X obj 444 209 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
-1;
#X obj 391 310 expr ($f1-129)/128;
#X obj 444 186 inlet;
#X obj 504 476 t b b;
#X obj 576 501 f;
#X obj 614 501 + 1;
#X msg 598 478 0;
#X obj 504 499 until;
#X obj 576 531 t f f;
#X obj 477 624 tabwrite E05-tab;
#X obj 503 527 sel 258;
#X obj 504 457 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
-1;
#X obj 448 558 expr ($f1-129)/128;
#X obj 504 434 inlet;
#X obj 88 410 expr 4*$f1*$f1*$f1-3*$f1;
#X obj 118 640 expr 8*$f1*$f1*$f1*$f1-8*$f1*$f1+1;
#X obj 448 582 expr 32*$f1*$f1*$f1*$f1*$f1*$f1 -48*$f1*$f1*$f1*$f1+18*$f1*$f1-1
;
#X text 641 622 6th C.P. and basta.;
#X obj 83 92 t b b;
#X obj 155 117 f;
#X obj 193 117 + 1;
#X msg 177 94 0;
#X obj 83 115 until;
#X obj 155 147 t f f;
#X obj 56 224 tabwrite E05-tab;
#X obj 82 143 sel 258;
#X obj 83 73 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
-1;
#X obj 30 174 expr ($f1-129)/128;
#X obj 83 50 inlet;
#X obj 30 198 expr 2*$f1*$f1-1;
#X text 203 198 2nd C.P.;
#X text 309 410 3rd C.P.;
#X text 331 660 4th C.P.;
#X text 613 357 5th C.P.;
#X text 259 51 This patch computes Chebychev polynomials and stores
them in a wavetable for use later.;
#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 7 0;
#X connect 2 0 1 1;
#X connect 3 0 1 1;
#X connect 4 0 1 0;
#X connect 5 0 10 0;
#X connect 5 1 6 1;
#X connect 7 0 4 1;
#X connect 9 0 0 0;
#X connect 10 0 46 0;
#X connect 11 0 9 0;
#X connect 12 0 16 0;
#X connect 12 1 15 0;
#X connect 13 0 14 0;
#X connect 13 0 17 0;
#X connect 13 0 19 0;
#X connect 14 0 13 1;
#X connect 15 0 13 1;
#X connect 16 0 13 0;
#X connect 17 0 21 0;
#X connect 17 1 18 1;
#X connect 19 0 16 1;
#X connect 20 0 12 0;
#X connect 21 0 47 0;
#X connect 22 0 20 0;
#X connect 23 0 27 0;
#X connect 23 1 26 0;
#X connect 24 0 25 0;
#X connect 24 0 28 0;
#X connect 24 0 30 0;
#X connect 25 0 24 1;
#X connect 26 0 24 1;
#X connect 27 0 24 0;
#X connect 28 0 33 0;
#X connect 28 1 29 1;
#X connect 30 0 27 1;
#X connect 31 0 29 0;
#X connect 32 0 23 0;
#X connect 33 0 31 0;
#X connect 34 0 32 0;
#X connect 35 0 39 0;
#X connect 35 1 38 0;
#X connect 36 0 37 0;
#X connect 36 0 40 0;
#X connect 36 0 42 0;
#X connect 37 0 36 1;
#X connect 38 0 36 1;
#X connect 39 0 36 0;
#X connect 40 0 44 0;
#X connect 40 1 41 1;
#X connect 42 0 39 1;
#X connect 43 0 35 0;
#X connect 44 0 48 0;
#X connect 45 0 43 0;
#X connect 46 0 6 0;
#X connect 47 0 18 0;
#X connect 48 0 41 0;
#X connect 50 0 54 0;
#X connect 50 1 53 0;
#X connect 51 0 52 0;
#X connect 51 0 55 0;
#X connect 51 0 57 0;
#X connect 52 0 51 1;
#X connect 53 0 51 1;
#X connect 54 0 51 0;
#X connect 55 0 59 0;
#X connect 55 1 56 1;
#X connect 57 0 54 1;
#X connect 58 0 50 0;
#X connect 59 0 61 0;
#X connect 60 0 58 0;
#X connect 61 0 56 0;
203 204
#X restore 429 166 pd make-table;
#X obj 429 146 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
Miller Puckette's avatar
Miller Puckette committed
205
-1;
206
#X obj 457 146 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
Miller Puckette's avatar
Miller Puckette committed
207
-1;
208
#X obj 485 146 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
Miller Puckette's avatar
Miller Puckette committed
209
-1;
210
#X obj 513 146 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
Miller Puckette's avatar
Miller Puckette committed
211
-1;
212
#X obj 540 146 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
Miller Puckette's avatar
Miller Puckette committed
213
-1;
214 215 216 217 218 219 220 221 222 223 224
#X text 437 65 calculate;
#X text 435 84 Chebychev;
#X text 436 103 polynomials;
#X text 430 127 2;
#X text 457 127 3;
#X text 486 127 4;
#X text 512 128 5;
#X text 541 127 6;
#X obj 22 206 +~ 129;
#X obj 22 255 hip~ 5;
#X text 107 276 This patch demonstrates using Chebychev polynomials
Miller Puckette's avatar
Miller Puckette committed
225 226 227 228 229
(of the first kind) to generate pure harmonics using waveshaping. The
pure harmonic only comes out when the index is one (top of the scale).
Smaller indices will give various mixes of harmonics. The table initially
holds the fifth Chebychev polynomial \, so you can get the fifth harmonic.
;
230
#X text 19 351 There is an audible "rolling" sound as the index changes
Miller Puckette's avatar
Miller Puckette committed
231 232 233
for the higher degree polynomials \, because the amplitudes of the
lower partials can rise and fall several times apiece as the index
rises from zero to one.;
234
#X text 19 404 Indices greater than one will try to read values outside
Miller Puckette's avatar
Miller Puckette committed
235 236 237
the table (which would be clipped appropriately). Anyway \, the polynomials
increase rapidly in value outside the interval from -1 to 1 that we
are using here.;
238
#X text 20 457 When you get tired of Chebychev polynomials you can
Miller Puckette's avatar
Miller Puckette committed
239
draw your own functions by hand and/or try other formulas.;
240 241 242 243 244 245 246
#X obj 1 1 cnv 15 445 20 empty \$0-pddp.cnv.header waveshaping_with_Chebychev_polynomials
20 10 1 18 -261139 -33289 0;
#X obj 407 2 pddp/pddplink http://puredata.info/dev/pddp -text pddp
;
#X obj 1 501 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;
247 248 249 250 251
#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.37. Jonathan
252 253
Wilkes revised the patch to conform to the PDDP template for Pd version
0.42.;
254 255
#X text 12 45 DESCRIPTION waveshaping with Chebychev polynomials;
#X text 12 5 KEYWORDS signal tutorial;
256 257 258 259 260 261 262 263 264
#X restore 392 503 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 waveshaping- Related Help Documents;
#X text 19 37 links:;
#X restore 103 503 pd References;
#X obj 6 503 pddp/pddplink ../5.reference/pddp/help.pd -text help;
#X connect 1 0 5 0;
Miller Puckette's avatar
Miller Puckette committed
265
#X connect 2 0 1 0;
266 267 268 269 270 271 272 273 274 275 276 277 278 279
#X connect 3 0 9 0;
#X connect 4 0 3 0;
#X connect 5 0 6 0;
#X connect 6 0 3 1;
#X connect 9 0 27 0;
#X connect 10 0 28 0;
#X connect 14 0 13 0;
#X connect 15 0 13 1;
#X connect 16 0 13 2;
#X connect 17 0 13 3;
#X connect 18 0 13 4;
#X connect 27 0 10 0;
#X connect 28 0 0 0;
#X connect 28 0 0 1;