Midi Wind Chimes by NoteJam22nd May 2005 23:24
|
---|
Summary Demo of a way to use midiOutShortMessage to play random midi notes under program control Description Program generates random numbers, and those numbers play midi notes. It sounds sort of like a wind chime. This is a demo program, to show the basics of making api midi calls, selecting what general midi instrument to use, and how to send note on and note off messages. Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com REM WINDCHIME BY NOTEJAM Load Dll "WINMM.DLL",1 HANDLE = Make Memory(4) PORT=1:REM CHANGE TO PORT YOU DESIRE -1=MIDIMAPPER, 1 TO ? = YOURS CALL DLL 1,"midiOutOpen",HANDLE,PORT,0,0,0 rem to get the handle of the Midi Out port: HMO As DWORD HMO = *HANDLE HERE: note=rnd(72)+20:REM PICK A RANDOM NOTR event = 192 INSTRUMENT=12:REM VIBES lo = (INSTRUMENT*256)+event Message=lo+hi Call Dll 1, "midiOutShortMsg", HMO, Message note=rnd(72)+30 event = 144 lo = (note*256)+event vel = 127 hi=vel*65536 Message=lo+hi rem put it out Call Dll 1, "midiOutShortMsg", HMO, Message WAIT 120 EVENT=144 VEL=0 LO=(NOTE*256)+EVENT HI=VEL*256 Message=lo+hi CALL DLL 1,"midiOutShortMsg",hmo,Message GOTO HERE REM HAVE Q KEY PRESS CAUSE JUMP TO EXIT: TO QUIT PROGRAM EXIT: DELETE MEMORY HANDLE DELETE DLL 1 END |