#INCLUDE "C:\B\pb\Winapi\win32api.inc" ' meta-compiler statement - include Windows functions #INCLUDE "C:\B\pb\gmt\gmt_kons.bi" ' include constants for GMT #INCLUDE "C:\B\pb\gmt\gmt_type.bi" ' include structures #INCLUDE "C:\B\pb\gmt\gmt_lib.bi" ' include DLL library via the declarations FUNCTION PBMAIN() AS LONG LOCAL hmo AS LONG ' handle for midi-out device LOCAL cnt AS WORD LOCAL i AS LONG LOCAL mididevice AS DWORD STATIC notes() AS BYTE STATIC oldnotes () AS BYTE STATIC nrvoices AS BYTE CONSOLE SCREEN 50,80 CONSOLE NAME "les 1050 demo - midi output" mididevice = 1 ' 0= mpu, 1= internal synth ' the number here depends on your configuration. hmo = OpenMidiOutputDevice (mididevice) IF ISFALSE hmo THEN LOCATE 1,1 PRINT "Cannot open midi output device nr "; STR$(1) WAITKEY$ EXIT FUNCTION ELSE LOCATE 1,1: PRINT "Midi device opened succesfully" nrvoices = 4 DIM notes(0 TO nrvoices) AS STATIC BYTE DIM oldnotes(0 TO nrvoices) AS STATIC BYTE END IF WAITKEY$ DO FOR i = 0 TO nrvoices-1 notes(i) = 48 + (RND(1) * 24) NEXT i GOSUB DoIt LOOP UNTIL INKEY$ = "*" SLEEP 1000 ' fermata FOR i = 0 TO Nrvoices -1 NoteOff i,oldnotes(i) NEXT i WAITKEY$ midiInClose hmo EXIT FUNCTION DoIt: FOR i = 0 TO nrvoices -1 IF (notes(i) MOD 12) <> (oldnotes(i) MOD 12) THEN IF oldnotes(i) THEN NoteOff i,oldnotes(i) Play i, notes(i),74 oldnotes(i)= notes(i) ELSE INCR cnt END IF NEXT i ' ritme: SELECT CASE cnt CASE 0 SLEEP 40 CASE 1,2 SLEEP 60 CASE 3,4 SLEEP 90 CASE 5,6,7 SLEEP 120 CASE 8 SLEEP 180 CASE ELSE SLEEP 240 END SELECT cnt = cnt MOD 10 PRINT cnt; RETURN END FUNCTION '---------------------------------------------------------------------------