max v2;
#N vpatcher 373 55 1482 819;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 438 360 45 196617 Uzi 513;
#P button 438 340 15 0;
#N counter 0 0 513;
#X flags 0 0;
#P newobj 438 383 83 196617 counter 0 0 513;
#P number 488 408 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 526 434 45 196617 fetch \$1;
#P number 707 531 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P user multiSlider 529 454 179 71 -1. 1. 512 2681 47 1 0 2 0 0 0;
#M frgb 0 0 0;
#M brgb 255 255 255;
#M rgb2 127 127 127;
#M rgb3 0 0 0;
#M rgb4 37 52 91;
#M rgb5 74 105 182;
#M rgb6 112 158 18;
#M rgb7 149 211 110;
#M rgb8 187 9 201;
#M rgb9 224 62 37;
#M rgb10 7 114 128;
#P newex 488 658 85 196617 peek~ wavetable;
#P number 863 221 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 263 317 47 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 173 316 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P comment 181 346 70 196617 Sample offset;
#P comment 271 345 56 196617 Table size;
#N vpatcher 625 103 1410 742;
#P inlet 46 124 15 0;
#P window setfont "Sans Serif" 9.;
#P number 115 151 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P comment 678 460 51 196617 see also:;
#P message 679 492 48 196617 lookup~;
#P message 679 475 48 196617 kink~;
#P hidden newex 678 514 64 196617 prepend help;
#P objectname phelp;
#P hidden newex 678 534 45 196617 pcontrol;
#P window setfont "Sans Serif" 18.;
#P comment 74 46 106 196626 overdrive~;
#B frgb 26 8 57;
#P window setfont "Sans Serif" 9.;
#P comment 74 72 335 196617 Apply nonlinear transfer function (aka waveshaping) to a signal.;
#P user panel 69 42 400 50;
#X brgb 226 250 200;
#X frgb 0 0 0;
#X border 0;
#X rounded 0;
#X shadow 0;
#X done;
#P hidden message 284 174 20 196617 50;
#P window linecount 2;
#P comment 176 280 30 196617 shape input;
#P window linecount 1;
#P hidden message 420 189 49 196617 trigger 1;
#P hidden newex 420 159 45 196617 loadbang;
#P flonum 141 249 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 141 226 32 196617 / 10.;
#P user hslider 141 201 18 128 100 1 10 0;
#P comment 81 304 35 196617 output;
#P message 373 232 27 196617 stop;
#P message 305 232 65 196617 startwindow;
#P newex 304 365 29 196617 dac~;
#P comment 280 576 155 196617 original sine wave;
#P user scope~ 378 389 626 553 256 3 128 -1. 1. 0 0. 1 0. 102 255 51 135 135 135 0;
#P newex 116 284 59 196617 overdrive~;
#B color 5;
#P user scope~ 115 385 365 553 256 3 128 -1. 1. 0 0. 1 0. 102 255 51 135 135 135 1;
#P newex 116 172 45 196617 cycle~ 2;
#P comment 302 218 100 196617  start/stop audio;
#P comment 110 574 155 196617 shaped sine wave;
#P comment 86 270 30 196617 input;
#P window linecount 2;
#P comment 213 277 86 196617 optional argument sets initial drive;
#P window linecount 5;
#P comment 83 96 390 196617 overdrive~ distorts signals by applying a nonlinear transfer function \, thereby simulating an overdriven amplifier. The shape of the function is determined by a floating-point "drive" parameter. If drive is 1. \, the signal is unchanged. Increasing drive increases the distortion. If drive is set to less than zero \, VERY LOUD BAD distortion results \, which may or may not be desireable. Use caution.;
#P user panel 292 212 123 43;
#X brgb 255 255 255;
#X frgb 100 202 30;
#X border 2;
#X rounded 0;
#X shadow 0;
#X done;
#P connect 31 0 30 0;
#P hidden fasten 19 0 7 0 425 317 120 317;
#P connect 8 0 7 0;
#P connect 30 0 6 0;
#P connect 6 0 8 0;
#P connect 17 0 8 0;
#P hidden fasten 21 0 15 0 289 195 146 195;
#P connect 15 0 16 0;
#P connect 16 0 17 0;
#P hidden fasten 18 0 21 0 425 179 308 179 308 166 289 166;
#P fasten 13 0 11 0 378 260 309 260;
#P connect 12 0 11 0;
#P fasten 8 0 11 0 121 340 309 340;
#P fasten 8 0 11 1 121 331 328 331;
#P fasten 6 0 9 0 121 271 383 271;
#P hidden fasten 19 0 9 0 425 312 383 312;
#P hidden connect 18 0 19 0;
#P hidden connect 27 0 26 0;
#P hidden connect 28 0 26 0;
#P hidden connect 26 0 25 0;
#P pop;
#P newobj 864 244 63 196617 p overdrive;
#N vpatcher 48 81 1302 868;
#P origin 46 8;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P comment 390 349 100 196617 plays the buffer;
#P window linecount 2;
#P comment 1016 163 100 196617 sends the values into the buffer 'foo';
#P window linecount 1;
#P newex 723 144 27 196617 - 1.;
#P newex 915 159 45 196617 Uzi 513;
#P button 915 139 15 0;
#N counter 0 0 513;
#X flags 0 0;
#P newobj 915 182 83 196617 counter 0 0 513;
#P number 965 207 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 1003 233 45 196617 fetch \$1;
#P number 1184 330 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P user multiSlider 1006 253 179 71 -1. 1. 512 2681 47 1 0 2 0 0 0;
#M frgb 0 0 0;
#M brgb 255 255 255;
#M rgb2 127 127 127;
#M rgb3 0 0 0;
#M rgb4 37 52 91;
#M rgb5 74 105 182;
#M rgb6 112 158 18;
#M rgb7 149 211 110;
#M rgb8 187 9 201;
#M rgb9 224 62 37;
#M rgb10 7 114 128;
#P message 595 91 33 196617 clear;
#P newex 654 117 46 196617 urn 512;
#P newex 654 62 44 196617 Uzi 512;
#P newex 654 143 27 196617 + 1;
#P message 654 214 65 196617 select \$1 \$2;
#P newex 654 192 50 196617 pack 0 0.;
#P flonum 723 163 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 723 125 40 196617 / 100.;
#P message 789 100 50 196617 seed 777;
#P newex 723 100 64 196617 random 200;
#P button 654 28 15 0;
#P newex 822 471 51 196617 peek~ foo;
#P comment 24 75 292 196617 Use a buffer~ for nonlinear distortion of a signal;
#P newex 265 513 39 196617 *~ 0.1;
#P flonum 445 419 47 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 355 418 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 399 528 27 196617 stop;
#P message 325 528 65 196617 startwindow;
#P newex 54 283 31 196617 - 1.;
#P newex 265 562 29 196617 dac~;
#P newex 265 414 39 196617 *~ 0.5;
#P newex 265 381 59 196617 cycle~ 440;
#P newex 54 251 38 196617 / 256.;
#P button 26 169 27 0;
#P newex 37 203 43 196617 Uzi 512;
#N counter 0 511;
#X flags 0 0;
#P newobj 37 228 72 196617 counter 0 511;
#P newex 34 391 82 196617 buffer~ foo 512;
#P newex 34 327 51 196617 peek~ foo;
#P newex 265 463 191 196617 lookup~ foo;
#B color 5;
#P window linecount 5;
#P comment 441 488 194 196617 Argument sets name of buffer~ to use. Optional int after that sets sample offset into buffer (default 0). Final optional int sets size of table to use (default is 512 samples).;
#P window linecount 1;
#P comment 325 513 108 196617  second \, start audio;
#P window linecount 3;
#P comment 55 165 108 196617  first \, click here to generate a lookup table function;
#P window linecount 2;
#P comment 34 363 120 196617  double-click to see the function generated;
#P window linecount 4;
#P comment 24 92 394 196617 lookup~ allows you to use a table of samples (buffer~ object) to do waveshaping on a signal \, in which the Y values of a input signal are used as X values to look up new signal values. Input values of -1 to +1 are mapped to table values between 0 (or the specified sample offset) and the size of the table.;
#P window linecount 3;
#P comment 88 315 74 196617 peek~ writes values into a buffer~;
#P window linecount 2;
#P comment 355 388 254 196617 These inlets take floats or signals \, but the values are converted to int (except when offset is a signal).;
#P window linecount 1;
#P comment 274 448 30 196617 Input;
#P comment 275 484 100 196617 Distorted Output;
#P comment 363 448 70 196617 Sample offset;
#P comment 453 447 56 196617 Table size;
#P user panel 314 507 123 43;
#X brgb 255 255 255;
#X frgb 100 202 30;
#X border 2;
#X rounded 0;
#X shadow 0;
#X done;
#P window linecount 2;
#P comment 730 58 100 196617 generates a buffer of random values;
#P connect 16 0 14 0;
#P connect 18 0 17 0;
#P connect 17 0 16 0;
#P connect 16 0 19 0;
#P connect 19 0 23 0;
#P connect 23 0 14 1;
#P connect 20 0 21 0;
#P connect 21 0 13 0;
#P connect 13 0 28 0;
#P connect 28 0 22 0;
#P connect 24 0 22 0;
#P connect 25 0 22 0;
#P fasten 28 0 22 1 270 546 289 546;
#P connect 26 0 13 1;
#P connect 27 0 13 2;
#P fasten 31 0 41 0 659 55 600 55;
#P connect 31 0 39 0;
#P connect 39 0 40 0;
#P fasten 41 0 40 0 600 112 659 112;
#P connect 40 0 38 0;
#P connect 38 0 36 0;
#P connect 36 0 37 0;
#P fasten 35 0 36 1 728 184 699 184;
#P fasten 39 0 32 0 659 89 728 89;
#P fasten 33 0 32 0 794 123 720 123 720 96 728 96;
#P connect 32 0 34 0;
#P connect 34 0 49 0;
#P connect 49 0 35 0;
#P fasten 45 0 30 0 970 309 827 309;
#P fasten 42 1 30 1 1180 360 847 360;
#P connect 47 0 48 0;
#P connect 48 0 46 0;
#P fasten 46 0 45 0 920 203 970 203;
#P fasten 45 0 44 0 970 227 1008 227;
#P connect 44 0 42 0;
#P fasten 37 0 42 0 659 251 1011 251;
#P connect 42 1 43 0;
#P pop;
#P newobj 866 197 46 196617 p lookup;
#P button 765 707 15 0;
#P message 765 686 118 196617 # 20070402 221343;
#P hidden newex 766 686 56 196617 datestamp;
#P message 781 707 179 196617 http://rhoadley.net - latest versions;
#P hidden button 765 707 15 0;
#P hidden newex 765 686 48 196617 loadbang;
#P hidden message 766 688 201 196617 ./patches/templates/RH/Waveshaping.txt;
#P window linecount 3;
#P hidden message 765 687 314 196617 \; max launch_browser http://rhoadley.net/cgi/courses/tech_resources/max-msp/examples/PERFORMANCE_TEMPLATES/;
#P window setfont "American Typewriter" 18.;
#P window linecount 1;
#P comment 765 646 129 199491602 Waveshaping;
#P window setfont "Sans Serif" 9.;
#P comment 765 671 100 196617 v 0.01;
#P message 350 521 84 196617 read gtr512.aiff;
#P message 256 521 76 196617 read jongly.aif;
#P message 209 522 30 196617 read;
#P newex 220 375 38 196617 r Amp;
#P window linecount 3;
#P message 18 312 54 196617 \; Amp 0.5 \; Freq 55.;
#P window linecount 1;
#P newex 18 291 54 196617 loadbang;
#P window linecount 2;
#P comment 77 533 62 196617 Audio On/Off;
#P comment 224 476 189 196617 Double-click to see the buffered waveform;
#P window linecount 3;
#P comment 850 347 104 196617 Open this gate~ to hear the buffered waveform;
#P window linecount 1;
#P comment 655 59 87 196617 Modulation depth;
#P comment 744 59 83 196617 Modulation rate;
#P window linecount 4;
#P comment 11 359 122 196617 Cycle~s amplitude determines its scanning range within the lookup table;
#P window linecount 1;
#P newex 933 444 32 196617 dac~;
#P toggle 933 396 15 0;
#P newex 933 418 38 196617 gate~;
#P flonum 961 336 60 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 994 375 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 961 393 43 196617 *~ 0.2;
#P window linecount 2;
#P comment 12 141 167 196617 Choose a method for affecting the range of table lookup;
#P user umenu 12 167 168 196645 1 64 183 0;
#X add Table Lookup Off;
#X add Set range by hand;
#X add Control range by envelope;
#X add Modulate range by a wave;
#P window linecount 1;
#P comment 660 37 107 196617 By modulating wave;
#P comment 212 40 82 196617 By envelope;
#P comment 79 39 49 196617 By hand;
#P comment 111 23 379 196617 Change cycle~s amplitude to determine its scanning range within the lookup table;
#P newex 220 448 38 196617 line~;
#P message 248 429 20 196617 50;
#P flonum 220 407 61 9 0. 1. 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P comment 230 393 57 196617 Amplitude;
#P comment 21 442 58 196617 Frequency;
#P newex 15 422 43 196617 r Freq;
#P newex 675 119 38 196617 line~;
#P message 703 100 20 196617 50;
#P flonum 675 78 61 9 0. 1. 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 616 144 69 196617 *~;
#P newex 616 111 44 196617 +~ 0.5;
#P flonum 746 78 60 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 232 62 41 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 232 80 80 196617 setdomain \$1;
#P button 212 62 15 0;
#P newex 242 169 40 196617 line~;
#P user function 212 102 312 166 1 1 0 0;
#X frgb 82 82 82;
#X brgb 204 204 204;
#X rgb2 85 85 85;
#X rgb3 255 255 255;
#X rgb4 0 0 0;
#X rgb5 0 0 0;
#X add 0. 1. 0;
#X add 488. 0. 0;
#X domain 488.;
#X range 0. 1.;
#X done;
#P flonum 79 61 61 9 0. 1. 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 107 83 26 196617 100;
#P newex 79 102 38 196617 line~;
#P newex 156 202 73 196617 selector~ 3;
#P newex 85 422 60 196617 *~;
#P newex 961 354 104 196617 cycle~ 55 wavetable;
#P newex 746 99 43 196617 cycle~;
#P newex 616 78 50 196617 *~ 0.45;
#P flonum 15 456 60 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 15 474 32 196617 sig~;
#P user ezdac~ 85 499 129 532 0;
#P newex 85 473 123 196617 *~;
#P newex 15 499 44 196617 cycle~;
#P newex 209 543 147 196617 buffer~ wavetable gtr512.aiff;
#P newex 85 448 93 196617 lookup~ wavetable;
#B color 5;
#P comment 273 62 47 196617 Duration;
#P window linecount 3;
#P comment 319 112 100 196617 <<<< (shift-click to remove points \, click to add them);
#P comment 944 220 100 196617 <<< NB turn overdrive to zero to start with!;
#P window linecount 6;
#P comment 544 349 100 196617 see also p look up to the right. Draw the wave in below and bang the Uzi to th left to draw your own waveform...;
#P connect 30 0 10 0;
#P connect 10 0 9 0;
#P connect 9 0 6 0;
#P connect 54 0 55 0;
#P connect 18 0 16 0;
#P fasten 6 0 14 0 20 520 79 520 79 417 90 417;
#P connect 14 0 4 0;
#P connect 4 0 7 0;
#P connect 7 0 8 0;
#P fasten 18 0 17 0 84 79 112 79;
#P connect 17 0 16 1;
#P fasten 7 0 8 1 90 494 124 494;
#P fasten 74 0 4 1 178 389 131 389;
#P fasten 15 0 14 1 161 265 140 265;
#P fasten 40 0 15 0 17 186 161 186;
#P fasten 75 0 4 2 268 361 172 361;
#P fasten 16 0 15 1 84 125 182 125;
#P fasten 20 0 15 2 247 191 203 191;
#P fasten 35 0 7 1 225 469 203 469;
#P connect 57 0 5 0;
#P fasten 58 0 5 0 261 539 214 539;
#P fasten 59 0 5 0 355 539 214 539;
#P fasten 22 0 19 0 237 99 217 99;
#P connect 21 0 19 0;
#P fasten 26 0 15 3 621 197 224 197;
#P connect 56 0 33 0;
#P connect 33 0 35 0;
#P connect 23 0 22 0;
#P connect 19 1 20 0;
#P fasten 33 0 34 0 225 425 253 425;
#P connect 34 0 35 1;
#P connect 83 0 84 0;
#P connect 84 0 82 0;
#P fasten 82 0 81 0 443 404 493 404;
#P fasten 81 0 77 0 493 496 493 496;
#P fasten 78 1 77 1 703 547 530 547;
#P fasten 81 0 80 0 493 428 531 428;
#P connect 80 0 78 0;
#P fasten 12 0 11 0 751 120 740 120 740 73 621 73;
#P connect 11 0 25 0;
#P connect 25 0 26 0;
#P connect 27 0 29 0;
#P connect 29 0 26 1;
#P fasten 27 0 28 0 680 96 708 96;
#P connect 28 0 29 1;
#P connect 78 1 79 0;
#P connect 24 0 12 0;
#P hidden connect 67 0 68 0;
#P hidden connect 65 0 62 0;
#P hidden connect 66 0 65 0;
#P hidden connect 63 0 67 0;
#P hidden connect 64 0 63 0;
#P hidden connect 69 0 63 0;
#P connect 76 0 71 0;
#P connect 46 0 45 0;
#P connect 45 0 47 0;
#P fasten 45 0 47 1 938 439 960 439;
#P connect 44 0 13 0;
#P connect 13 0 42 0;
#P connect 42 0 45 1;
#P connect 43 0 42 1;
#P pop;
