max v2; #N vpatcher 78 48 1112 669; #P window setfont Times 12.; #P window linecount 2; #P comment 148 469 190 1310732 Use floating point addition to preserve the fractional part of the number.; #P window setfont "Fixedwidth Serif" 18.; #P window linecount 1; #P newex 199 395 54 1441810 + 2.; #P button 304 165 15 0; #P window setfont Times 18.; #P window linecount 2; #P comment 532 83 260 1310738 initializes the rate as 2 notes per second before starting the metro; #P window setfont "Fixedwidth Serif" 18.; #P window linecount 1; #P message 513 87 19 1441810 2; #P newex 199 341 43 1441810 + 1; #P window setfont Times 18.; #P window linecount 2; #P comment 178 428 123 1310738 change the rate after every note; #P window setfont "Fixedwidth Serif" 18.; #P window linecount 1; #P newex 199 368 76 1441810 / 1.75; #P window setfont Times 12.; #P window linecount 7; #P comment 107 508 349 1310732 Note the importance of the right-to-left ordering of Max messages here. The rate of the metro is initialized first (also setting the duration of the first note) before the metro is started. The velocity values are produced next \, so that they will have already been received by makenote when the pitch values arrive. After each note is played \, a new rate is given to the metro (and a new duration to makenote) in preparation for the subsequent note. After the last note is played \, stop the metro \,; #P window setfont Times 18.; #P window linecount 4; #P comment 613 354 145 1310738 scale and offset the numbers 0-35 to produce velocity values 20-125; #P window setfont "Fixedwidth Serif" 18.; #P number 634 445 48 18 0 127 3 22 0 0 0 221 221 221 222 222 222 0 0 0; #P window linecount 1; #P newex 559 404 54 1441810 + 20; #P newex 559 376 43 1441810 * 3; #P window setfont Times 18.; #P comment 47 381 114 1310738 stop the metro; #P window setfont "Fixedwidth Serif" 18.; #P message 349 210 54 1441810 stop; #P newex 38 356 109 1441810 select 35; #N vtable 36 30 89 413 296 970020 128; #T set 0 36 38 40 41 43 45 47 48 50 52 53 55 57 59 60 62 64 65 67 69 71 72 74 76 77 79 81 83 84 86 88 89 91 93 95 96; #P newobj 330 338 65 1441810 table; #P window setfont Times 18.; #P window linecount 3; #P comment 11 27 472 1310738 Use counter to play a 7-note ("diatonic") scale over five octaves \, and also to increase the velocity from soft to loud (20 to 125) \, and also to increase the rate from 2 to 22 notes per second; #P window linecount 2; #P comment 628 511 369 1310738 set port a in the MIDI Setup... dialog \, or you can double-click to select the port from a popup menu; #P window setfont "Fixedwidth Serif" 18.; #P window linecount 1; #P newex 519 516 109 1441810 noteout a; #P window setfont Times 18.; #P window linecount 3; #P comment 337 363 146 1310738 use the numbers to look up the notes of a C-major scale; #P window setfont "Fixedwidth Serif" 18.; #P number 519 444 44 18 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0; #P window setfont Times 18.; #P window linecount 2; #P comment 760 459 191 1310738 inter-onset interval is also used as the note duration; #P window setfont "Fixedwidth Serif" 18.; #P window linecount 1; #P newex 519 470 241 1441810 makenote 100; #P flonum 513 185 71 18 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0; #P window setfont Times 18.; #P comment 585 133 37 1310738 rate; #P comment 584 186 31 1310738 ms; #P comment 203 273 101 1310738 count events; #P comment 446 275 227 1310738 count 36 bangs (from 0 to 35); #P window setfont "Fixedwidth Serif" 18.; #P number 304 301 35 18 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0; #P flonum 513 132 71 18 0 0 0 22 0 0 0 252 255 141 222 222 222 0 0 0; #P newex 513 157 98 1441810 !/ 1000.; #P newex 304 242 219 1441810 metro; #N counter 0 35; #X flags 0 0; #P newobj 304 272 142 1441810 counter 0 35; #P window setfont Times 18.; #P comment 261 163 41 1310738 start; #P user panel 158 332 161 137; #X brgb 179 217 213; #X frgb 0 0 0; #X border 0; #X rounded 16; #X shadow 0; #X done; #P user panel 325 332 167 103; #X brgb 252 245 145; #X frgb 0 0 0; #X border 0; #X rounded 16; #X shadow 0; #X done; #P user panel 555 337 206 102; #X brgb 253 175 160; #X frgb 0 0 0; #X border 0; #X rounded 16; #X shadow 0; #X done; #P fasten 8 0 22 0 309 328 43 328; #P fasten 8 0 32 0 309 328 204 328; #P connect 32 0 30 0; #P connect 30 0 36 0; #P connect 35 0 5 0; #P fasten 23 0 5 0 354 237 309 237; #P connect 5 0 4 0; #P connect 4 0 8 0; #P fasten 8 0 21 0 309 328 335 328; #P fasten 22 0 23 0 43 384 34 384 34 203 354 203; #P fasten 35 0 33 0 309 185 503 185 503 82 518 82; #P connect 33 0 7 0; #P fasten 36 0 7 0 204 424 194 424 194 126 518 126; #P connect 7 0 6 0; #P connect 6 0 13 0; #P connect 13 0 5 1; #P fasten 21 0 16 0 335 422 524 422; #P connect 16 0 14 0; #P connect 14 0 18 0; #P fasten 8 0 25 0 309 328 564 328; #P connect 25 0 26 0; #P fasten 14 1 18 1 755 499 573 499; #P fasten 26 0 27 0 564 434 639 434; #P connect 27 0 14 1; #P fasten 13 0 14 2 518 233 762 233 762 450 754 450; #P pop;