#N canvas 0 22 991 701 10; #X obj 149 199 key; #X floatatom 149 218 5 0 0 0 - - -; #X obj 149 234 select 27; #X msg 149 270 \; pd dsp \$1; #X obj 523 250 select 9; #X text 110 218 ASCII; #X text 68 199 PC keyboard; #X text 61 282 audio on/off; #X text 96 234 esc key; #X text 471 250 tab key; #X obj 149 253 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1 1; #X text 75 253 toggle 1/0; #X obj 523 269 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1; #X obj 523 286 select 1; #X text 450 270 toggle 1/0; #X text 457 286 if it's 1; #X obj 523 347 vline~; #X msg 574 305 0 500; #X text 614 305 rel.; #X obj 539 440 vsl 15 101 0 100 0 0 empty empty volume -12 -8 0 12 -262144 -1 -1 5000 1; #X obj 539 562 * 0.01; #X floatatom 539 546 4 0 100 0 - - -; #X msg 539 581 \$1 50; #X obj 539 600 line~; #X obj 523 619 *~; #X obj 400 635 *~; #X obj 681 403 loadbang; #X msg 681 422 50; #X obj 388 669 dac~; #X msg 523 325 1 5 \, 0.0625 245 5 \, 0.001 9750 250; #X obj 281 557 osc~ 5; #X obj 281 577 *~ 6; #X obj 220 619 osc~; #X obj 220 600 +~; #X obj 220 557 sig~ 880; #X text 11 108 This part of the program just demonstrates how to use the PC keyboard to trigger events. We look for the ASCII code of particular keys. (ASCII 27 is the escape key \, and ASCII 9 is the tab key.) We use the esc key to toggle DSP processing on and off \, and we use the tab key to turn a note on and off (simulating the pressing and releasing of a key on a music keyboard).; #X text 247 -2 This is an example of one way to make an "envelope" (a control function made up of line segments). It uses the "vline~" object to queue up three line segments \, which constitute the "attack" \, "decay" \, and "sustain" portion of an ADSR envelope controlling the amplitude of a wave. The release" portion occurs when the note is released (turned off).; #X text 419 194 When the note is turned on (toggle goes to 1) \, generate the attack \, decay \, and sustain portions of the amplitude envelope. When the note is turned off (toggle goes to 0) gnerate the release. ; #X text 423 325 att./dec./sus.; #X text 120 341 go to 1 in 5 ms \, after 5 ms go to 0.0625 in 245 ms \, and after 250 ms go to 0.001 in 9750 ms \, and when the note is released go to 0 in 500 ms; #X text 552 617 This is just a master volume control. The amplitude envelope will be scaled by this amount.; #X obj 614 374 initialize the volume to 50 (thus setting the peak amplitude to 0.5) when the window is opened; #X text 75 517 This could be any kind of instrument to which we want to apply the amplitude envelope. In this case \, it's just a sine tone with a low-frequency (5 Hz) vibrato.; #X connect 0 0 1 0; #X connect 1 0 2 0; #X connect 2 0 10 0; #X connect 2 1 4 0; #X connect 4 0 12 0; #X connect 10 0 3 0; #X connect 12 0 13 0; #X connect 13 0 29 0; #X connect 13 1 17 0; #X connect 16 0 24 0; #X connect 17 0 16 0; #X connect 19 0 21 0; #X connect 20 0 22 0; #X connect 21 0 20 0; #X connect 22 0 23 0; #X connect 23 0 24 1; #X connect 24 0 25 1; #X connect 25 0 28 0; #X connect 25 0 28 1; #X connect 26 0 27 0; #X connect 27 0 19 0; #X connect 29 0 16 0; #X connect 30 0 31 0; #X connect 31 0 33 1; #X connect 32 0 25 0; #X connect 33 0 32 0; #X connect 34 0 33 0;