#N canvas 975 158 953 798 10; #X obj 543 282 soundfiler; #X obj 256 298 float; #X floatatom 301 413 0 0 0 0 - - - 0; #X obj 256 508 pack f f; #X obj 445 316 samplerate~; #X obj 543 230 pack s \$0; #X obj 251 10 table \$0-audio-L; #X obj 451 622 loadbang; #X obj 256 577 tabread4~ \$0-audio-L; #X obj 256 35 notein; #X obj 256 237 mtof; #X obj 255 160 stripnote; #X obj 547 347 * 0.008; #X obj 547 380 t f f; #X obj 625 376 unpack f f f f; #X obj 256 618 *~; #X obj 255 87 pack f f f; #X obj 255 133 unpack f f f; #X obj 255 111 route 1 2; #X obj 256 62 poly 1 1; #X msg 627 355 2 1000 50 700; #X obj 543 169 loadbang; #X obj 352 421 *; #X obj 301 437 /; #X floatatom 301 485 0 0 0 0 - - - 0; #X msg 543 205 piano-A.wav; #X floatatom 214 253 0 0 0 0 - - - 0; #X obj 371 327 f 44100; #X obj 551 475 tabplay~ \$0-audio-L; #X obj 553 451 bng 15 250 50 0 empty empty compare\\\ tuning 17 7 0 10 #fcfcfc #000000 #000000; #X floatatom 385 391 5 0 0 0 - - - 0; #X obj 475 378 tgl 15 1 empty empty empty 17 7 0 10 #c6ffc7 #000000 #000000 1 1; #X floatatom 210 206 0 0 0 0 - - - 0; #X msg 256 530 0 \, \$1 \$2; #X obj 256 268 t b b f b; #X obj 256 368 t f f, f 8; #X obj 256 555 vline~; #N canvas 208 208 450 300 adsr 0; #X obj 105 111 inlet; #X obj 435 151 inlet; #X text 101 86 trigger; #X obj 105 139 sel 0; #X obj 244 155 t b; #X obj 166 264 f \$1; #X obj 166 289 pack 0 \$2; #X obj 492 151 inlet; #X obj 438 281 del \$2; #X obj 458 429 line~; #X obj 462 304 f \$4; #X obj 501 379 pack 0 \$3; #X obj 554 151 inlet; #X obj 616 151 inlet; #X obj 689 150 inlet; #X msg 105 170 stop; #X obj 612 306 pack 0 \$5; #X text 435 129 level; #X obj 501 355 * \$1; #X obj 458 454 outlet~; #X text 102 378 and pack with; #X text 103 398 attack time; #X text 31 126 if zero; #X text 32 143 release; #X text 12 160 and cancel; #X text 43 177 decay; #X text 284 272 on attack \, set a; #X text 278 305 recall sustain value; #X text 315 378 pack with decay time; #X text 605 332 on release ramp; #X text 606 349 back to zero; #X obj 462 329 * 0.01; #X text 47 567 Objects such as "f" and "pack" can be given dollar sign arguments to initialize their contents from adsr's creation arguments. Inlets are supplied to change them on the fly.; #X text 13 2 ADSR ENVELOPE; #X text 488 129 attack; #X text 555 128 decay; #X text 609 129 sustain; #X text 686 129 release; #X text 202 71 attack; #X obj 204 92 moses; #X obj 194 122 t b b; #X msg 128 290 0; #X text 20 273 optionally; #X text 10 291 bash to zero; #X text 25 246 ATTACK:; #X text 49 477 When you send this patch a positive trigger it schedules a line~ to do an attack and decay \, and if zero \, it starts the release ramp.; #X text 495 629 Updated for Pd version 0.37; #X text 255 89 test for negative trigger; #X text 253 113 if so \, zero; #X text 254 129 the output; #X text 278 165 in any case; #X text 303 355 multiply by peak level; #X text 280 286 delay for sustain; #X text 276 328 convert from percent; #X text 155 340 ... then; #X text 103 359 recall peak level; #X text 439 113 peak; #X text 281 149 ... do this; #X text 47 529 Negative triggers cause the output to jump to zero and then attack (instead of attacking from the current location).; #X text 208 1 Arguments: level \, attack time \, decay time \, sustain level \, release time. A \, D \, and R are in msec and S is in percent. This patch is used as an abstraction in various examples.; #X connect 0 0 3 0; #X connect 1 0 5 1; #X connect 1 0 18 1; #X connect 3 0 15 0; #X connect 3 0 16 0; #X connect 3 1 39 0; #X connect 4 0 5 0; #X connect 4 0 8 0; #X connect 5 0 6 0; #X connect 6 0 9 0; #X connect 7 0 6 1; #X connect 7 0 8 1; #X connect 8 0 10 0; #X connect 9 0 19 0; #X connect 10 0 31 0; #X connect 11 0 9 0; #X connect 12 0 11 1; #X connect 13 0 10 1; #X connect 14 0 16 1; #X connect 15 0 8 0; #X connect 16 0 9 0; #X connect 18 0 11 0; #X connect 31 0 18 0; #X connect 39 0 40 0; #X connect 39 1 4 0; #X connect 40 0 4 0; #X connect 40 1 41 0; #X connect 41 0 9 0; #X restore 547 412 pd adsr; #X f 20; #X obj 255 703 dac~; #X obj 256 654 *~; #X msg 451 638 0.3; #N canvas 208 208 450 300 swop-over 0; #X obj 129 75 inlet; #X obj 215 75 inlet; #X obj 310 76 inlet; #X obj 137 162 spigot; #X obj 211 165 spigot; #X obj 168 226 outlet; #X obj 170 131 == 0; #X obj 244 132 != 0; #X connect 0 0 3 0; #X connect 1 0 4 0; #X connect 2 0 6 0; #X connect 2 0 7 0; #X connect 3 0 5 0; #X connect 4 0 5 0; #X connect 6 0 3 1; #X connect 7 0 4 1; #X restore 384 370 pd swop-over; #X msg 650 185 \; pd dsp 1; #X obj 99 512 *~; #X obj 100 451 phasor~; #X obj 98 572 tabread4~ \$0-audio-L; #X obj 100 413 *; #X obj 138 327 samplerate~; #X obj 138 398 /; #X obj 543 306 s \$0-length; #X obj 138 273 r \$0-length; #X obj 117 486 r \$0-length; #X msg 100 329 1; #X obj 138 300 t b f, f 8; #X floatatom 145 428 0 0 0 0 - - - 0; #X msg 100 310 0; #X msg 544 256 read -resize \$1 \$2-audio-L; #X obj 255 190 - 0; #X obj 300 463 * 110000; #X text 361 461 base freq; #X connect 0 0 1 1; #X connect 0 0 49 0; #X connect 1 0 35 0; #X connect 2 0 23 0; #X connect 3 0 33 0; #X connect 4 0 41 1; #X connect 5 0 56 0; #X connect 7 0 40 0; #X connect 8 0 15 0; #X connect 9 0 19 0; #X connect 9 1 19 1; #X connect 10 0 26 0; #X connect 10 0 34 0; #X connect 11 0 57 0; #X connect 12 0 13 0; #X connect 13 0 37 0; #X connect 13 1 37 1; #X connect 14 0 37 2; #X connect 14 1 37 3; #X connect 14 2 37 4; #X connect 14 3 37 5; #X connect 15 0 39 0; #X connect 16 0 18 0; #X connect 17 0 11 0; #X connect 17 1 11 1; #X connect 17 1 12 0; #X connect 18 0 17 0; #X connect 19 0 16 0; #X connect 19 1 16 1; #X connect 19 2 16 2; #X connect 20 0 14 0; #X connect 21 0 25 0; #X connect 21 0 20 0; #X connect 21 0 42 0; #X connect 22 0 23 1; #X connect 23 0 58 0; #X connect 24 0 3 1; #X connect 25 0 5 0; #X connect 27 0 41 0; #X connect 28 0 39 0; #X connect 29 0 28 0; #X connect 30 0 22 1; #X connect 31 0 41 2; #X connect 33 0 36 0; #X connect 34 0 1 0; #X connect 34 2 22 0; #X connect 34 3 27 0; #X connect 34 3 4 0; #X connect 35 0 3 0; #X connect 35 1 2 0; #X connect 36 0 8 0; #X connect 37 0 15 1; #X connect 39 0 38 0; #X connect 39 0 38 1; #X connect 40 0 39 1; #X connect 41 0 30 0; #X connect 43 0 45 0; #X connect 44 0 43 0; #X connect 45 0 39 0; #X connect 46 0 44 0; #X connect 46 0 54 0; #X connect 47 0 48 0; #X connect 48 0 46 1; #X connect 50 0 53 0; #X connect 51 0 43 1; #X connect 52 0 46 0; #X connect 53 0 47 0; #X connect 53 1 48 1; #X connect 55 0 46 0; #X connect 56 0 0 0; #X connect 57 0 10 0; #X connect 57 0 32 0; #X connect 58 0 24 0;