max v2; #N vpatcher 151 204 1022 769; #P window setfont Times 12.; #P window linecount 3; #P comment 565 493 98 1310732 full amplitude of 1 is assumed as the reference amplitude; #P window setfont Times 18.; #P window linecount 1; #P comment 550 449 263 1310738 formula to convert amplitude to dB; #P comment 292 259 80 1310738 amplitude; #P window setfont Times 12.; #P window linecount 3; #P comment 477 249 158 1310732 comma is a "special character" in Max \, so must be preceded by a backslash in 'expr'; #P window linecount 1; #P comment 671 494 158 1310732 this is an equivalent Max object; #P comment 644 250 158 1310732 this is an equivalent Max object; #P window setfont Times 18.; #P comment 234 459 96 1310738 audio on/off; #P window linecount 2; #P comment 437 311 211 1310738 take 20 ms to go smoothly to the new amplitude; #P window linecount 1; #P comment 478 203 263 1310738 formula to convert dB to amplitude; #P comment 416 91 194 1310738 dial sends numbers 0-100; #P window setfont "Fixedwidth Serif" 18.; #P message 262 200 19 1441810 0; #P window setfont Times 12.; #P window linecount 2; #P comment 79 170 183 1310732 when minimum position is reached on the dial \, turn volume down entirely; #P window linecount 1; #P comment 382 176 191 1310732 pass through everything that is not -60; #P window setfont "Fixedwidth Serif" 18.; #P newex 262 171 120 1441810 select -60; #P window setfont Times 18.; #P window linecount 2; #P comment 323 23 207 1310738 Volume control by decibels (i.e. an exponential curve); #P window setfont "Fixedwidth Serif" 18.; #P window linecount 1; #P newex 644 225 65 1441810 dBtoA; #P newex 671 469 65 1441810 AtodB; #P user ezdac~ 256 426 300 459 0; #P newex 273 382 32 1441810 *~; #P message 427 289 32 1441810 20; #P newex 372 316 65 1441810 line~; #P user dial 376 73 40 40 61 1 -60 0 223 270 1 1. 170 170 170 221 221 221 120 120 120 225 225 225 0 0 0 0 0 0; #P flonum 372 259 103 18 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0; #P number 372 200 57 18 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0; #P flonum 444 499 103 18 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0; #P flonum 444 443 103 18 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0; #P newex 372 225 263 1441810 expr pow(10.\\\,$f1*0.05); #P newex 444 469 219 1441810 expr 20.*log10($f1); #P newex 168 318 120 1441810 cycle~ 400; #P window setfont Times 18.; #P comment 429 202 31 1310738 dB; #P connect 11 0 12 0; #P connect 8 0 16 0; #P connect 16 0 19 0; #P connect 1 0 11 0; #P connect 11 0 12 1; #P connect 9 0 11 1; #P connect 16 1 6 0; #P connect 6 0 3 0; #P connect 3 0 7 0; #P fasten 19 0 7 0 267 254 377 254; #P connect 7 0 9 0; #P fasten 7 0 10 0 377 283 432 283; #P connect 10 0 9 1; #P connect 4 0 2 0; #P connect 2 0 5 0; #P pop;