#N canvas 8 25 980 676 10; #X msg 69 136 \; pd dsp 1; #X msg 135 136 \; pd dsp 0; #X text 93 121 Audio On/Off; #N canvas 0 0 450 300 graph3 0; #X array envelope 12 float 1; #A 0 0 1 0.5 0.25 0.125 0.0625 0.03125 0.015625 0.007813 0.003906 0.001953 0; #X coords 0 1 11 0 240 101 1; #X restore 575 158 graph; #X text 594 621 This is one way to fill the array.; #X obj 379 394 line~; #X obj 379 463 tabread4~ envelope; #X obj 379 248 key; #X obj 379 286 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1; #X obj 379 267 select 112; #X text 454 267 p; #X obj 379 306 select 1; #X obj 379 542 *~; #X floatatom 395 507 5 0 100 1 volume - -; #X obj 685 472 loadbang; #X msg 685 491 50; #X obj 395 523 * 0.01; #X msg 527 592 \; envelope 0 0 1 0.5 0.25 0.125 0.0625 0.03125 0.015625 0.007813 0.003906 0.001953 0; #X obj 95 518 noise~; #X obj 363 584 *~; #X obj 352 612 dac~; #X msg 453 357 11 100; #X msg 379 357 0 \, 7 1000; #X text 270 12 This program demonstrates storing an envelope shape in an array \, and then reading through the array in a given amount of time \, treating the values in the array as a control signal.; #X text 489 89 This array has 12 values (in array indexes 0 to 11). When the note is turned on \, we read from index 0 to index 7 in 1000 ms (interpolating along the way). When the note is turned off \, we go from index 7 to index 11 (which \, conveniently \, we have set to store the value 0) in 100 ms.; #X text 47 268 Use the 'p' key to play or turn off the "note".; #X text 440 303 Do one thing when the note is turned on \, and another thing when it's turned off.; #X text 130 394 Using a signal \, traverse the array.; #X text 616 506 Initialize the peak amplitude to 0.5.; #X text 386 413 This object reads from the "envelope" array \, treating it as a signal (rather than as discrete events). It uses 4-point polynomial interpolation to calculate the intermediate values between array indexes. ; #X text 384 558 The amplitude of the note will be controlled by the function stored in the array.; #X text -42 489 This could be any sound-generating "instrument". In this case \, we're just using white noise (random samples).; #X text 503 342 The first 3/4 of the array shape is used to control the amplitude continuously over the first 1 second of the note. Then \, when the note is turned off \, we use the rest of the array to complete the note in 100 ms.; #X connect 5 0 6 0; #X connect 6 0 12 0; #X connect 7 0 9 0; #X connect 8 0 11 0; #X connect 9 0 8 0; #X connect 11 0 22 0; #X connect 11 1 21 0; #X connect 12 0 19 1; #X connect 13 0 16 0; #X connect 14 0 15 0; #X connect 15 0 13 0; #X connect 16 0 12 1; #X connect 18 0 19 0; #X connect 19 0 20 0; #X connect 19 0 20 1; #X connect 21 0 5 0; #X connect 22 0 5 0;