#N canvas 112 44 660 645 12;
#X text 450 623 updated for Pd version 0.26;
#X obj 32 80 r trigger;
#X text 85 8 USING ADSR'S OUTPUT AS dB;
#X text 34 28 For natural sounding amplitude control \, you will want
to use the ADSR's output as log amplitude. In practice this is best
done using a lookup table:;
#X obj 32 131 tabread4~ dbtorms;
#X graph graph1 0 0 123 10 387 183 587 83;
#X array dbtorms 123 float 0;
#X pop;
#N canvas 574 520 600 388 make-table 0;
#X obj 84 217 moses 2;
#X msg 81 44 bang;
#X obj 81 73 t b b;
#X obj 159 142 f;
#X obj 197 142 + 1;
#X msg 175 112 0;
#X obj 81 102 until;
#X obj 63 168 sel 122;
#X msg 84 248 0;
#X obj 128 249 dbtorms;
#X obj 161 177 t f f;
#X obj 84 281 tabwrite dbtorms;
#X obj 411 138 tabread4~ dbtorms;
#X obj 411 106 sig~;
#X floatatom 411 78 0 0 0;
#X floatatom 427 170 0 0 0;
#X obj 427 198 metro 250;
#X obj 411 227 snapshot~;
#X floatatom 411 256 0 0 0;
#X msg 63 328 \; dbtorms write dbtorms.txt;
#X obj 341 311 loadbang;
#X msg 341 334 \; dbtorms read dbtorms.txt;
#X connect 0 0 8 0;
#X connect 0 1 9 0;
#X connect 1 0 2 0;
#X connect 2 0 6 0;
#X connect 2 1 5 0;
#X connect 3 0 4 0;
#X connect 3 0 7 0;
#X connect 3 0 10 0;
#X connect 4 0 3 1;
#X connect 5 0 3 1;
#X connect 6 0 3 0;
#X connect 7 0 6 1;
#X connect 8 0 11 0;
#X connect 9 0 11 0;
#X connect 10 0 0 0;
#X connect 10 1 11 1;
#X connect 12 0 17 0;
#X connect 13 0 12 0;
#X connect 14 0 13 0;
#X connect 15 0 16 0;
#X connect 16 0 17 0;
#X connect 17 0 18 0;
#X connect 20 0 21 0;
#X restore 288 328 pd make-table;
#X text 258 299 here's the patch I used to make the table:;
#X obj 48 156 osc~ 440;
#X text 589 176 0;
#X text 590 77 10;
#X text 406 186 ------ 123 samples ------;
#X floatatom 61 204 0 0 0;
#N canvas 159 26 532 285 output 0;
#X obj 338 160 t b;
#X obj 338 110 f;
#X obj 338 60 inlet;
#X text 344 29 mute;
#X obj 338 185 f;
#X msg 425 178 0;
#X msg 338 85 bang;
#X obj 338 135 moses 1;
#X obj 397 117 moses 1;
#X obj 83 148 dbtorms;
#X obj 397 92 r master-lvl;
#X obj 83 42 r master-lvl;
#X obj 338 210 s master-lvl;
#X obj 22 181 inlet~;
#X obj 199 41 inlet;
#X text 199 18 level;
#X obj 199 100 s master-lvl;
#X msg 96 65 set \$1;
#X obj 96 89 outlet;
#X msg 214 64 \; pd dsp 1;
#X obj 83 194 line~;
#X obj 22 212 *~;
#X obj 22 241 dac~;
#X obj 83 171 pack 0 50;
#X text 20 158 audio;
#X text 93 110 show level;
#X obj 425 153 t b;
#X connect 0 0 4 0;
#X connect 1 0 7 0;
#X connect 2 0 6 0;
#X connect 4 0 12 0;
#X connect 5 0 12 0;
#X connect 6 0 1 0;
#X connect 7 0 0 0;
#X connect 7 1 26 0;
#X connect 8 1 4 1;
#X connect 9 0 23 0;
#X connect 10 0 1 1;
#X connect 10 0 8 0;
#X connect 11 0 9 0;
#X connect 11 0 17 0;
#X connect 13 0 21 0;
#X connect 14 0 16 0;
#X connect 14 0 19 0;
#X connect 17 0 18 0;
#X connect 20 0 21 1;
#X connect 21 0 22 0;
#X connect 21 0 22 1;
#X connect 23 0 20 0;
#X connect 26 0 5 0;
#X restore 32 232 pd output;
#X msg 108 205 MUTE;
#X text 149 204 <-- output amplitude;
#X text 112 276 <-- attack;
#X text 113 333 <-- release;
#X msg 32 319 \; pd dsp 1 \; trigger 0;
#X obj 32 182 *~;
#X msg 31 264 \; pd dsp 1 \; trigger 1;
#X text 29 381 The table is indexed from 1 to 120 1 gives a true zero
out and 120 gives 10 (a 20 dB boost.) The extra 20 dB are called headroom.
;
#X text 29 431 Notice how the attack sounds different when you retrigger
than when you start from zero. This is because if you go from the steady
state you only rise 30 dB instead of 100 \, so it sounds slower.;
#X text 28 498 If this is a problem you have at least 2 ways of dealing
with it. The best might be to adjust the attack time inside the abstraction
using snapshot~ to find out where you're slewing from.If this is a
problem you have at least 2 ways of dealing with it. The best might
be to adjust the attack time inside the abstraction using snapshot~
to find out where you're slewing from \, as demonstrated in the next
patch.;
#X obj 32 106 adsr 100 100 200 70 300;
#X connect 1 0 24 0;
#X connect 4 0 19 0;
#X connect 8 0 19 1;
#X connect 12 0 13 1;
#X connect 13 0 12 0;
#X connect 14 0 13 2;
#X connect 19 0 13 0;
#X connect 24 0 4 0;
