#include <array.au3>
;======================
;Midi UDFs by Eynstyne
;See Example in Comments
;======================
;Midi Notes
;==========
Const $A0_ON = 0x00401590 ;1
Const $A0SHARP_ON = 0x00401690 ;2
Const $B0_ON = 0x00401790 ;3
Const $C1_ON = 0x00401890 ;4
Const $C1SHARP_ON = 0x00401990 ;5
Const $D1_ON = 0x00401A90 ;6
Const $D1SHARP_ON = 0x00401B90 ;7
Const $E1_ON = 0x00401C90 ;8
Const $F1_ON = 0x00401D90 ;9
Const $F1SHARP_ON = 0x00401E90 ;10
Const $G1_ON = 0x00401F90 ;11
Const $G1SHARP_ON = 0x00402090 ;12
Const $A1_ON = 0x00402190 ;13
Const $A1SHARP_ON = 0x00402290 ;14
Const $B1_ON = 0x00402390 ;15
Const $C2_ON = 0x00402490 ;16
Const $C2SHARP_ON = 0x00402590 ;17
Const $D2_ON = 0x00402690 ;18
Const $D2SHARP_ON = 0x00402790 ;19
Const $E2_ON = 0x00402890 ;20
Const $F2_ON = 0x00402990 ;21
Const $F2SHARP_ON = 0x00402A90 ;22
Const $G2_ON = 0x00402B90 ;23
Const $G2SHARP_ON = 0x00402C90 ;24
Const $A2_ON = 0x00402D90 ;25
Const $A2SHARP_ON = 0x00402E90 ;26
Const $B2_ON = 0x00402F90 ;27
Const $C3_ON = 0x00403090 ;28
Const $C3SHARP_ON = 0x00403190 ;29
Const $D3_ON = 0x00403290 ;30
Const $D3SHARP_ON = 0x00403390 ;31
Const $E3_ON = 0x00403490 ;32
Const $F3_ON = 0x00403590 ;33
Const $F3SHARP_ON = 0x00403690 ;34
Const $G3_ON = 0x00403790 ;35
Const $G3SHARP_ON = 0x00403890 ;36
Const $A3_ON = 0x00403990 ;37
Const $A3SHARP_ON = 0x00403A90 ;38
Const $B3_ON = 0x00403B90 ;39
Const $C4_ON = 0x00403C90 ;40 - Middle C
Const $C4SHARP_ON = 0x00403D90 ;41
Const $D4_ON = 0x00403E90 ;42
Const $D4SHARP_ON = 0x00403F90 ;43
Const $E4_ON = 0x00404090 ;44
Const $F4_ON = 0x00404190 ;45
Const $F4SHARP_ON = 0x00404290 ;46
Const $G4_ON = 0x00404390 ;47
Const $G4SHARP_ON = 0x00404490 ;48
Const $A4_ON = 0x00404590 ;49
Const $A4SHARP_ON = 0x00404690 ;50
Const $B4_ON = 0x00404790 ;51
Const $C5_ON = 0x00404890 ;52
Const $C5SHARP_ON = 0x00404990 ;53
Const $D5_ON = 0x00404A90 ;54
Const $D5SHARP_ON = 0x00404B90 ;55
Const $E5_ON = 0x00404C90 ;56
Const $F5_ON = 0x00404D90 ;57
Const $F5SHARP_ON = 0x00404E90 ;58
Const $G5_ON = 0x00404F90 ;59
Const $G5SHARP_ON = 0x00405090 ;60
Const $A5_ON = 0x00405190 ;61
Const $A5SHARP_ON = 0x00405290 ;62
Const $B5_ON = 0x00405390 ;63
Const $C6_ON = 0x00405490 ;64
Const $C6SHARP_ON = 0x00405590 ;65
Const $D6_ON = 0x00405690 ;66
Const $D6SHARP_ON = 0x00405790 ;67
Const $E6_ON = 0x00405890 ;68
Const $F6_ON = 0x00405990 ;69
Const $F6SHARP_ON = 0x00405A90 ;70
Const $G6_ON = 0x00405B90 ;71
Const $G6SHARP_ON = 0x00405C90 ;72
Const $A6_ON = 0x00405D90 ;73
Const $A6SHARP_ON = 0x00405E90 ;74
Const $B6_ON = 0x00405F90 ;75
Const $C7_ON = 0x00406090 ;76
Const $C7SHARP_ON = 0x00406190 ;77
Const $D7_ON = 0x00406290 ;78
Const $D7SHARP_ON = 0x00406390 ;79
Const $E7_ON = 0x00406490 ;80
Const $F7_ON = 0x00406590 ;81
Const $F7SHARP_ON = 0x00406690 ;82
Const $G7_ON = 0x00406790 ;83
Const $G7SHARP_ON = 0x00406890 ;84
Const $A7_ON = 0x00406990 ;85
Const $A7SHARP_ON = 0x00406A90 ;86
Const $B7_ON = 0x00406B90 ;87
Const $C8_ON = 0x00406C90 ;88
;Turn Off
Const $A0_OFF = 0x00001590 ;1
Const $A0SHARP_OFF = 0x00001690 ;2
Const $B0_OFF = 0x00001790 ;3
Const $C1_OFF = 0x00001890 ;4
Const $C1SHARP_OFF = 0x00001990 ;5
Const $D1_OFF = 0x00001A90 ;6
Const $D1SHARP_OFF = 0x00001B90 ;7
Const $E1_OFF = 0x00001C90 ;8
Const $F1_OFF = 0x00001D90 ;9
Const $F1SHARP_OFF = 0x00001E90 ;10
Const $G1_OFF = 0x00001F90 ;11
Const $G1SHARP_OFF = 0x00002090 ;12
Const $A1_OFF = 0x00002190 ;13
Const $A1SHARP_OFF = 0x00002290 ;14
Const $B1_OFF = 0x00002390 ;15
Const $C2_OFF = 0x00002490 ;16
Const $C2SHARP_OFF = 0x00002590 ;17
Const $D2_OFF = 0x00002690 ;18
Const $D2SHARP_OFF = 0x00002790 ;19
Const $E2_OFF = 0x00002890 ;20
Const $F2_OFF = 0x00002990 ;21
Const $F2SHARP_OFF = 0x00002A90 ;22
Const $G2_OFF = 0x00002B90 ;23
Const $G2SHARP_OFF = 0x00002C90 ;24
Const $A2_OFF = 0x00002D90 ;25
Const $A2SHARP_OFF = 0x00002E90 ;26
Const $B2_OFF = 0x00002F90 ;27
Const $C3_OFF = 0x00003090 ;28
Const $C3SHARP_OFF = 0x00003190 ;29
Const $D3_OFF = 0x00003290 ;30
Const $D3SHARP_OFF = 0x00003390 ;31
Const $E3_OFF = 0x00003490 ;32
Const $F3_OFF = 0x00003590 ;33
Const $F3SHARP_OFF = 0x00003690 ;34
Const $G3_OFF = 0x00003790 ;35
Const $G3SHARP_OFF = 0x00003890 ;36
Const $A3_OFF = 0x00003990 ;37
Const $A3SHARP_OFF = 0x00003A90 ;38
Const $B3_OFF = 0x00003B90 ;39
Const $C4_OFF = 0x00003C90 ;40 - Middle C
Const $C4SHARP_OFF = 0x00003D90 ;41
Const $D4_OFF = 0x00003E90 ;42
Const $D4SHARP_OFF = 0x00003F90 ;43
Const $E4_OFF = 0x00004090 ;44
Const $F4_OFF = 0x00004190 ;45
Const $F4SHARP_OFF = 0x00004290 ;46
Const $G4_OFF = 0x00004390 ;47
Const $G4SHARP_OFF = 0x00004490 ;48
Const $A4_OFF = 0x00004590 ;49
Const $A4SHARP_OFF = 0x00004690 ;50
Const $B4_OFF = 0x00004790 ;51
Const $C5_OFF = 0x00004890 ;52
Const $C5SHARP_OFF = 0x00004990 ;53
Const $D5_OFF = 0x00004A90 ;54
Const $D5SHARP_OFF = 0x00004B90 ;55
Const $E5_OFF = 0x00004C90 ;56
Const $F5_OFF = 0x00004D90 ;57
Const $F5SHARP_OFF = 0x00004E90 ;58
Const $G5_OFF = 0x00004F90 ;59
Const $G5SHARP_OFF = 0x00005090 ;60
Const $A5_OFF = 0x00005190 ;61
Const $A5SHARP_OFF = 0x00005290 ;62
Const $B5_OFF = 0x00005390 ;63
Const $C6_OFF = 0x00005490 ;64
Const $C6SHARP_OFF = 0x00005590 ;65
Const $D6_OFF = 0x00005690 ;66
Const $D6SHARP_OFF = 0x00005790 ;67
Const $E6_OFF = 0x00005890 ;68
Const $F6_OFF = 0x00005990 ;69
Const $F6SHARP_OFF = 0x00005A90 ;70
Const $G6_OFF = 0x00005B90 ;71
Const $G6SHARP_OFF = 0x00005C90 ;72
Const $A6_OFF = 0x00005D90 ;73
Const $A6SHARP_OFF = 0x00005E90 ;74
Const $B6_OFF = 0x00005F90 ;75
Const $C7_OFF = 0x00006090 ;76
Const $C7SHARP_OFF = 0x00006190 ;77
Const $D7_OFF = 0x00006290 ;78
Const $D7SHARP_OFF = 0x00006390 ;79
Const $E7_OFF = 0x00006490 ;80
Const $F7_OFF = 0x00006590 ;81
Const $F7SHARP_OFF = 0x00006690 ;82
Const $G7_OFF = 0x00006790 ;83
Const $G7SHARP_OFF = 0x00006890 ;84
Const $A7_OFF = 0x00006990 ;85
Const $A7SHARP_OFF = 0x00006A90 ;86
Const $B7_OFF = 0x00006B90 ;87
Const $C8_OFF = 0x00006C90 ;88
Const $Callback_NULL = 0
Const $callback_Window = 0x10000
Const $callback_thread = 0x20000
Const $callback_function = 0x30000
Const $callback_event = 0x50000
Const $MMSYSERR_BASE = 0
Const $MMSYSERR_ALLOCATED = ($MMSYSERR_BASE + 4)
Const $MMSYSERR_BADDEVICEID = ($MMSYSERR_BASE + 2)
Const $MMSYSERR_BADERRNUM = ($MMSYSERR_BASE + 9)
Const $MMSYSERR_ERROR = ($MMSYSERR_BASE + 1)
Const $MMSYSERR_HANDLEBUSY = ($MMSYSERR_BASE + 12)
Const $MMSYSERR_INVALFLAG = ($MMSYSERR_BASE + 10)
Const $MMSYSERR_INVALHANDLE = ($MMSYSERR_BASE + 5)
Const $MMSYSERR_INVALIDALIAS = ($MMSYSERR_BASE + 13)
Const $MMSYSERR_INVALPARAM = ($MMSYSERR_BASE + 11)
Const $MMSYSERR_LASTERROR = ($MMSYSERR_BASE + 13)
Const $MMSYSERR_NODRIVER = ($MMSYSERR_BASE + 6)
Const $MMSYSERR_NOERROR = 0
Const $MMSYSERR_NOMEM = ($MMSYSERR_BASE + 7)
Const $MMSYSERR_NOTENABLED = ($MMSYSERR_BASE + 3)
Const $MMSYSERR_NOTSUPPORTED = ($MMSYSERR_BASE + 8)
Const $MIDI_CACHE_ALL = 1
Const $MIDI_CACHE_BESTFIT = 2
Const $MIDI_CACHE_QUERY = 3
Const $MIDI_UNCACHE = 4
Const $MIDI_CACHE_VALID = ($MIDI_CACHE_ALL Or $MIDI_CACHE_BESTFIT Or $MIDI_CACHE_QUERY Or $MIDI_UNCACHE)
Const $MIDI_IO_STATUS = 0x20
Const $MIDICAPS_CACHE = 0x4
Const $MIDICAPS_LRVOLUME = 0x20
Const $MIDICAPS_STREAM = 0x8
Const $MIDICAPS_VOLUME = 0x1
Const $MIDIERR_BASE = 64
Const $MIDIERR_INVALIDSETUP = ($MIDIERR_BASE + 5)
Const $MIDIERR_LASTERROR = ($MIDIERR_BASE + 5)
Const $MIDIERR_NODEVICE = ($MIDIERR_BASE + 4)
Const $MIDIERR_NOMAP = ($MIDIERR_BASE + 2)
Const $MIDIERR_NOTREADY = ($MIDIERR_BASE + 3)
Const $MIDIERR_STILLPLAYING = ($MIDIERR_BASE + 1)
Const $MIDIERR_UNPREPARED = ($MIDIERR_BASE + 0)
Const $MIDIMAPPER = -1
Const $MIDIPROP_GET = 0x40000000
Const $MIDIPROP_SET = 0x80000000
Const $MIDIPROP_TEMPO = 0x2
Const $MIDIPROP_TIMEDIV = 0x1
Const $MIDISTRM_ERROR = -2
Const $MM_MPU401_MIDIOUT = 10
Const $MM_MPU401_MIDIIN = 11
Const $MM_MIDI_MAPPER = 1
Const $MIDIPATCHSIZE = 128
Const $MM_MIM_CLOSE = 0x3c2
Const $MM_MIM_DATA = 0x3c3
Const $MM_MIM_ERROR = 0x3c5
Const $MM_MIM_LONGDATA = 0x3c4
Const $MM_MIM_LONGERROR = 0x3c6
Const $MM_MIM_MOREDATA = 0x3cc
Const $MM_MIM_OPEN = 0x3c1
Const $MM_MOM_CLOSE = 0x3c8
Const $MM_MOM_DONE = 0x3c9
Const $MM_MOM_OPEN = 0x3c7
Const $MM_MOM_POSITIONCB = 0x3ca
Const $MIM_CLOSE = ($MM_MIM_CLOSE)
Const $MIM_DATA = ($MM_MIM_DATA)
Const $MIM_ERROR = ($MM_MIM_ERROR)
Const $MIM_LONGDATA = ($MM_MIM_LONGDATA)
Const $MIM_LONGERROR = ($MM_MIM_LONGERROR)
Const $MIM_MOREDATA = ($MM_MIM_MOREDATA)
Const $MIM_OPEN = ($MM_MIM_OPEN)
Const $MOM_CLOSE = ($MM_MOM_CLOSE)
Const $MOM_DONE = ($MM_MOM_DONE)
Const $MOM_OPEN = ($MM_MOM_OPEN)
Const $MOM_POSITIONCB = ($MM_MOM_POSITIONCB)
;Midi Notes
;==========
Const $ABASS_OCTAVEDOWN16_NOTEON = 0x00401590;1
Const $ASHARPBASS_OCTAVEDOWN16_NOTEON = 0x00401690;2
Const $BBASS_OCTAVEDOWN16_NOTEON = 0x00401790;3
Const $CBASS_OCTAVEDOWN8_NOTEON = 0x00401890;4
Const $CSHARPBASS_OCTAVEDOWN8_NOTEON = 0x00401990;5
Const $DBASS_OCTAVEDOWN8_NOTEON = 0x00401A90;6
Const $DSHARPBASS_OCTAVEDOWN8_NOTEON = 0x00401B90;7
Const $EBASS_OCTAVEDOWN8_NOTEON = 0x00401C90;8
Const $FBASS_OCTAVEDOWN8_NOTEON = 0x00401D90;9
Const $FSHARPBASS_OCTAVEDOWN8_NOTEON = 0x00401E90;10
Const $GBASS_OCTAVEDOWN8_NOTEON = 0x00401F90;11
Const $GSHARPBASS_OCTAVEDOWN8_NOTEON = 0x00402090;12
Const $ABASS_OCTAVEDOWN8_NOTEON = 0x00402190;13
Const $ASHARPBASS_OCTAVEDOWN8_NOTEON = 0x00402290;14
Const $BBASS_OCTAVEDOWN_NOTEON = 0x00402390;15
Const $CBASS_OCTAVEDOWN_NOTEON = 0x00402490;16
Const $CSHARPBASS_OCTAVEDOWN_NOTEON = 0x00402590;17
Const $DBASS_OCTAVEDOWN_NOTEON = 0x00402690;18
Const $DSHARPBASS_OCTAVEDOWN_NOTEON = 0x00402790;19
Const $EBASS_OCTAVEDOWN_NOTEON = 0x00402890;20
Const $FBASS_OCTAVEDOWN_NOTEON = 0x00402990;21
Const $FSHARPBASS_OCTAVEDOWN_NOTEON = 0x00402A90;22
Const $GBASS_OCTAVEDOWN_NOTEON = 0x00402B90;23
Const $GSHARPBASS_OCTAVEDOWN_NOTEON = 0x00402C90;24
Const $ABASS_OCTAVEDOWN_NOTEON = 0x00402D90;25
Const $ASHARPBASS_OCTAVEDOWN_NOTEON = 0x00402E90;26
Const $BBASS_NOTEON = 0x00402F90;27
Const $CBASS_NOTEON = 0x00403090;28
Const $CSHARPBASS_NOTEON = 0x00403190;29
Const $DBASS_NOTEON = 0x00403290;30
Const $DSHARPBASS_NOTEON = 0x00403390;31
Const $EBASS_NOTEON = 0x00403490;32
Const $FBASS_NOTEON = 0x00403590;33
Const $FSHARPBASS_NOTEON = 0x00403690;34
Const $GBASS_NOTEON = 0x00403790;35
Const $GSHARPBASS_NOTEON = 0x00403890;36
Const $ABASS_NOTEON = 0x00403990;37
Const $ASHARPBASS_NOTEON = 0x00403A90;38
Const $B_NOTEON = 0x00403B90;39
Const $C_NOTEON = 0x00403C90;40 - Middle C
Const $CSHARP_NOTEON = 0x00403D90;41
Const $D_NOTEON = 0x00403E90;42
Const $DSHARP_NOTEON = 0x00403F90;43
Const $E_NOTEON = 0x00404090;44
Const $F_NOTEON = 0x00404190;45
Const $FSHARP_NOTEON = 0x00404290;46
Const $G_NOTEON = 0x00404390;47
Const $GSHARP_NOTEON = 0x00404490;48
Const $A_NOTEON = 0x00404590;49
Const $ASHARP_NOTEON = 0x00404690;50
Const $B_OCTAVE_NOTEON = 0x00404790;51
Const $C_OCTAVEUP_NOTEON = 0x00404890;52
Const $CSHARP_OCTAVEUP_NOTEON = 0x00404990;53
Const $D_OCTAVEUP_NOTEON = 0x00404A90;54
Const $DSHARP_OCTAVEUP_NOTEON = 0x00404B90;55
Const $E_OCTAVEUP_NOTEON = 0x00404C90;56
Const $F_OCTAVEUP_NOTEON = 0x00404D90;57
Const $FSHARP_OCTAVEUP_NOTEON = 0x00404E90;58
Const $G_OCTAVEUP_NOTEON = 0x00404F90;59
Const $GSHARP_OCTAVEUP_NOTEON = 0x00405090;60
Const $A_OCTAVEUP_NOTEON = 0x00405190;61
Const $ASHARP_OCTAVEUP_NOTEON = 0x00405290;62
Const $B_OCTAVEUP_NOTEON = 0x00405390;63
Const $C_OCTAVEUP8_NOTEON = 0x00405490;64
Const $CSHARP_OCTAVEUP8_NOTEON = 0x00405590;65
Const $D_OCTAVEUP8_NOTEON = 0x00405690;66
Const $DSHARP_OCTAVEUP8_NOTEON = 0x00405790;67
Const $E_OCTAVEUP8_NOTEON = 0x00405890;68
Const $F_OCTAVEUP8_NOTEON = 0x00405990;69
Const $FSHARP_OCTAVEUP8_NOTEON = 0x00405A90;70
Const $G_OCTAVEUP8_NOTEON = 0x00405B90;71
Const $GSHARP_OCTAVEUP8_NOTEON = 0x00405C90;72
Const $A_OCTAVEUP8_NOTEON = 0x00405D90;73
Const $ASHARP_OCTAVEUP8_NOTEON = 0x00405E90;74
Const $B_OCTAVEUP8_NOTEON = 0x00405F90;75
Const $C_OCTAVEUP16_NOTEON = 0x00406090;76
Const $CSHARP_OCTAVEUP16_NOTEON = 0x00406190;77
Const $D_OCTAVEUP16_NOTEON = 0x00406290;78
Const $DSHARP_OCTAVEUP16_NOTEON = 0x00406390;79
Const $E_OCTAVEUP16_NOTEON = 0x00406490;80
Const $F_OCTAVEUP16_NOTEON = 0x00406590;81
Const $FSHARP_OCTAVEUP16_NOTEON = 0x00406690; 82
Const $G_OCTAVEUP16_NOTEON = 0x00406790; 83
Const $GSHARP_OCTAVEUP16_NOTEON = 0x00406890; 84
Const $A_OCTAVEUP16_NOTEON = 0x00406990 ;85
Const $ASHARP_OCTAVEUP16_NOTEON = 0x00406A90 ;86
Const $B_OCTAVEUP16_NOTEON = 0x00406B90 ;87
Const $C_OCTAVEUP32_NOTEON = 0x00406C90 ;88
;Turn Off the Notes
Const $ABASS_OCTAVEDOWN16_NOTEOFF = 0x00001590;1
Const $ASHARPBASS_OCTAVEDOWN16_NOTEOFF = 0x00001690;2
Const $BBASS_OCTAVEDOWN16_NOTEOFF = 0x00001790;3
Const $CBASS_OCTAVEDOWN8_NOTEOFF = 0x00001890;4
Const $CSHARPBASS_OCTAVEDOWN8_NOTEOFF = 0x00001990;5
Const $DBASS_OCTAVEDOWN8_NOTEOFF = 0x00001A90;6
Const $DSHARPBASS_OCTAVEDOWN8_NOTEOFF = 0x00001B90;7
Const $EBASS_OCTAVEDOWN8_NOTEOFF = 0x00001C90;8
Const $FBASS_OCTAVEDOWN8_NOTEOFF = 0x00001D90;9
Const $FSHARPBASS_OCTAVEDOWN8_NOTEOFF = 0x00001E90;10
Const $GBASS_OCTAVEDOWN8_NOTEOFF = 0x00001F90;11
Const $GSHARPBASS_OCTAVEDOWN8_NOTEOFF = 0x00002090;12
Const $ABASS_OCTAVEDOWN8_NOTEOFF = 0x00002190;13
Const $ASHARPBASS_OCTAVEDOWN8_NOTEOFF = 0x00002290;14
Const $BBASS_OCTAVEDOWN_NOTEOFF = 0x00002390;15
Const $CBASS_OCTAVEDOWN_NOTEOFF = 0x00002490;16
Const $CSHARPBASS_OCTAVEDOWN_NOTEOFF = 0x00002590;17
Const $DBASS_OCTAVEDOWN_NOTEOFF = 0x00002690;18
Const $DSHARPBASS_OCTAVEDOWN_NOTEOFF = 0x00002790;19
Const $EBASS_OCTAVEDOWN_NOTEOFF = 0x00002890;20
Const $FBASS_OCTAVEDOWN_NOTEOFF = 0x00002990;21
Const $FSHARPBASS_OCTAVEDOWN_NOTEOFF = 0x00002A90;22
Const $GBASS_OCTAVEDOWN_NOTEOFF = 0x00002B90;23
Const $GSHARPBASS_OCTAVEDOWN_NOTEOFF = 0x00002C90;24
Const $ABASS_OCTAVEDOWN_NOTEOFF = 0x00002D90;25
Const $ASHARPBASS_OCTAVEDOWN_NOTEOFF = 0x00002E90;26
Const $BBASS_NOTEOFF = 0x00002F90;27
Const $CBASS_NOTEOFF = 0x00003090;28
Const $CSHARPBASS_NOTEOFF = 0x00003190;29
Const $DBASS_NOTEOFF = 0x00003290;30
Const $DSHARPBASS_NOTEOFF = 0x00003390;31
Const $EBASS_NOTEOFF = 0x00003490;32
Const $FBASS_NOTEOFF = 0x00003590;33
Const $FSHARPBASS_NOTEOFF = 0x00003690;34
Const $GBASS_NOTEOFF = 0x00003790;35
Const $GSHARPBASS_NOTEOFF = 0x00003890;36
Const $ABASS_NOTEOFF = 0x00003990;37
Const $ASHARPBASS_NOTEOFF = 0x00003A90;38
Const $B_NOTEOFF = 0x00003B90;39
Const $C_NOTEOFF = 0x00003C90;00 - Middle C
Const $CSHARP_NOTEOFF = 0x00003D90;41
Const $D_NOTEOFF = 0x00003E90;42
Const $DSHARP_NOTEOFF = 0x00003F90;43
Const $E_NOTEOFF = 0x00000090;44
Const $F_NOTEOFF = 0x00004190;45
Const $FSHARP_NOTEOFF = 0x00004290;46
Const $G_NOTEOFF = 0x00004390;47
Const $GSHARP_NOTEOFF = 0x00004490;48
Const $A_NOTEOFF = 0x00004590;49
Const $ASHARP_NOTEOFF = 0x00004690;50
Const $B_OCTAVE_NOTEOFF = 0x00004790;51
Const $C_OCTAVEUP_NOTEOFF = 0x00004890;52
Const $CSHARP_OCTAVEUP_NOTEOFF = 0x00004990;53
Const $D_OCTAVEUP_NOTEOFF = 0x00004A90;54
Const $DSHARP_OCTAVEUP_NOTEOFF = 0x00004B90;55
Const $E_OCTAVEUP_NOTEOFF = 0x00004C90;56
Const $F_OCTAVEUP_NOTEOFF = 0x00004D90;57
Const $FSHARP_OCTAVEUP_NOTEOFF = 0x00004E90;58
Const $G_OCTAVEUP_NOTEOFF = 0x00004F90;59
Const $GSHARP_OCTAVEUP_NOTEOFF = 0x00005090;60
Const $A_OCTAVEUP_NOTEOFF = 0x00005190;61
Const $ASHARP_OCTAVEUP_NOTEOFF = 0x00005290;62
Const $B_OCTAVEUP_NOTEOFF = 0x00005390;63
Const $C_OCTAVEUP8_NOTEOFF = 0x00005490;64
Const $CSHARP_OCTAVEUP8_NOTEOFF = 0x00005590;65
Const $D_OCTAVEUP8_NOTEOFF = 0x00005690;66
Const $DSHARP_OCTAVEUP8_NOTEOFF = 0x00005790;67
Const $E_OCTAVEUP8_NOTEOFF = 0x00005890;68
Const $F_OCTAVEUP8_NOTEOFF = 0x00005990;69
Const $FSHARP_OCTAVEUP8_NOTEOFF = 0x00005A90;70
Const $G_OCTAVEUP8_NOTEOFF = 0x00005B90;71
Const $GSHARP_OCTAVEUP8_NOTEOFF = 0x00005C90;72
Const $A_OCTAVEUP8_NOTEOFF = 0x00005D90;73
Const $ASHARP_OCTAVEUP8_NOTEOFF = 0x00005E90;74
Const $B_OCTAVEUP8_NOTEOFF = 0x00005F90;75
Const $C_OCTAVEUP16_NOTEOFF = 0x00006090;76
Const $CSHARP_OCTAVEUP16_NOTEOFF = 0x00006190;77
Const $D_OCTAVEUP16_NOTEOFF = 0x00006290;78
Const $DSHARP_OCTAVEUP16_NOTEOFF = 0x00006390;79
Const $E_OCTAVEUP16_NOTEOFF = 0x00006490;80
Const $F_OCTAVEUP16_NOTEOFF = 0x00006590;81
Const $FSHARP_OCTAVEUP16_NOTEOFF = 0x00006690; 82
Const $G_OCTAVEUP16_NOTEOFF = 0x00006790; 83
Const $GSHARP_OCTAVEUP16_NOTEOFF = 0x00006890; 84
Const $A_OCTAVEUP16_NOTEOFF = 0x00006990 ;85
Const $ASHARP_OCTAVEUP16_NOTEOFF = 0x00006A90 ;86
Const $B_OCTAVEUP16_NOTEOFF = 0x00006B90 ;87
Const $C_OCTAVEUP32_NOTEOFF = 0x00006C90 ;88
;Instruments
#cs
Grand Piano;0 ;modorate
Bright Piano;1 ;piano
Electric Grand Piano;2 ;forte
Honky-Tonk Piano;3 ;modorate
Electric piano 1; 4
Electric Piano 2; 5
Harpsichord; 6
Clavinet; 7
Celesta; 8
Glockenspiel; 9
Music Box; 10
Vibraphone; 11
Marimba; 12
Xylophone; 13
Tubular bells; 14
Dulcimer; 15
Drawbar Organ; 16
Percussive Organ; 17
Rock Organ; 18
Church Organ; 19
Reed Organ; 20
Accordion; 21
Harmonica; 22
Tango Accordion; 23
Nylon String Guitar; 24
Steel String Guitar; 25
Jazz Guitar; 26
Clean Electric Guitar; 27
Muted Electric Guitar; 28
Overdrive Guitar; 29
Distortion Guitar; 30
Guitar Harmonics; 31
Accoustic Bass; 32
Fingered Bass; 33
Picked Bass; 34
Fretless Bass; 35
Slap Bass 1; 36
Slap Bass 2; 37
Synth Bass 1; 38
Synth Bass 2; 39
Violin; 40
Viola; 41
Cello; 42
Contrabass; 43
Tremolo Strings; 44
Pizzicato Strings; 45
Orchestral Harp; 46
Timpani; 47
String Ensemble 1; 48
String Ensemble 2; 49
Synth Strings 1; 50
Synth Strings 2; 51
Choir ahh; 52
Choir oohh; 53
Synth Voice; 54
Orchestral Hit; 55
Trumpet; 56
Trombone; 57
Tuba; 58
Muted Trumpet; 59
French Horn; 60
Brass Section; 61
Synth Brass 1; 62
Synth Brass 2; 63
Soprano Sax; 64
Alto Sax; 65
Tenor Sax; 66
Baritone Sax; 67
Oboe; 68
English Horn; 69
Bassoon; 70
Clarinet; 71
Piccolo; 72
Flute; 73
Recorder; 74
Pan flute; 75
Blown Bottle; 76
Shakuhachi; 77
Whistle; 78
Ocarina; 79
Square Wave; 80
Sawtooth Wave; 81
Caliope; 82
Chiff; 83
Charang; 84
Voice; 85
Fifths; 86
Bass & Lead; 87
New Age; 88
Warm; 89
PolySynth; 90
Choir; 91
Bowed; 92
Metallic; 93
Halo; 94
Sweep; 95
FX: Rain;96
FX: Soundtrack;97
FX: Crystal;98
FX: Atmosphere;99
FX: Brightness;100
FX: Goblins;101
FX: Echo Drops;102
FX: Star Theme;103
Sitar;104
Banjo;105
Shamisen;106
Koto;107
Kalimba;108
Bagpipe;109
Fiddle;110
Shanai;111
Tinkle bell;112
Agogo;113
Steel Drums;114
Woodblock;115
Taiko Drum;116
Melodic Tom;117
Synth Drum;118
Reverse Cymbal;119
Guitar Fret Noise;120
Breath Noise;121
Seashore;122
Bird Tweet;123
Telephone Ring;124
Helicopter;125
Applause;126
Gunshot;127
Drums
=====
Range from 27 - 87
#ce
;THE FOLLOWING IS AN EXAMPLE ON HOW TO USE THE CONSTANTS...
;PIECE - 12 VARIATIONS (K.265,Ah! vous dirai-je maman) THEME
;Composer : Wolfgang Amadeus Mozart
;Resequenced by Eynstyne
;~ $open = _midiOutOpen()
;~ for $i = 27 to 87
;~ _MidiOutShortMsg($open,0x99 + ($i * 256) + (127 * 0x10000)) ; Drums Bitch!
;~ sleep(200)
;~ Next
;~ FOR $I = 1 TO 2
;~ _MidiOutShortMsg($open,256 * 16 + 192)
;~ $msg = _midioutshortmsg($open,$C_OCTAVEUP_NOTEON)
;~ $msg = _midioutshortmsg($open,$CBASS_NOTEON)
;~ sleep(500)
;~ $msg = _midioutshortmsg($open,$C_OCTAVEUP_NOTEON)
;~ $msg = _midioutshortmsg($open,$C_NOTEON)
;~ sleep(500)
;~ $msg = _midioutshortmsg($open,$G_OCTAVEUP_NOTEON)
;~ $msg = _midioutshortmsg($open,$E_NOTEON)
;~ sleep(500)
;~ $msg = _midioutshortmsg($open,$G_OCTAVEUP_NOTEON)
;~ $msg = _midioutshortmsg($open,$C_NOTEON)
;~ sleep(500)
;~ $msg = _midioutshortmsg($open,$A_OCTAVEUP_NOTEON)
;~ $msg = _midioutshortmsg($open,$F_NOTEON)
;~ sleep(500)
;~ $msg = _midioutshortmsg($open,$A_OCTAVEUP_NOTEON)
;~ $msg = _midioutshortmsg($open,$C_NOTEON)
;~ sleep(500)
;~ $msg = _midioutshortmsg($open,$G_OCTAVEUP_NOTEON)
;~ $msg = _midioutshortmsg($open,$E_NOTEON)
;~ sleep(500)
;~ $msg = _midioutshortmsg($open,$G_OCTAVEUP_NOTEON)
;~ $msg = _midioutshortmsg($open,$C_NOTEON)
;~ sleep(500)
;~ $msg = _midioutshortmsg($open,$F_OCTAVEUP_NOTEON)
;~ $msg = _midioutshortmsg($open,$D_NOTEON)
;~ sleep(500)
;~ $msg = _midioutshortmsg($open,$F_OCTAVEUP_NOTEON)
;~ $msg = _midioutshortmsg($open,$B_NOTEON)
;~ sleep(500)
;~ $msg = _midioutshortmsg($open,$E_OCTAVEUP_NOTEON)
;~ $msg = _midioutshortmsg($open,$C_NOTEON)
;~ sleep(500)
;~ $msg = _midioutshortmsg($open,$E_OCTAVEUP_NOTEON)
;~ $msg = _midioutshortmsg($open,$A_NOTEON)
;~ sleep(500)
;~ $msg = _midioutshortmsg($open,$D_OCTAVEUP_NOTEON)
;~ $msg = _midioutshortmsg($open,$FBASS_NOTEON)
;~ sleep(500)
;~ $msg = _midioutshortmsg($open,$D_OCTAVEUP_NOTEON)
;~ $msg = _midioutshortmsg($open,$GBASS_NOTEON)
;~ sleep(300)
;~ $msg = _midioutshortmsg($open,$E_OCTAVEUP_NOTEON)
;~ sleep(175)
;~ $msg = _midioutshortmsg($open,$C_OCTAVEUP_NOTEON)
;~ $msg = _midioutshortmsg($open,$CBASS_NOTEON)
;~ sleep(1000)
;~ $msg = _midioutshortmsg($open,$CBASS_NOTEOFF)
;~ NEXT
;~ $msg = _midioutshortmsg($open,$G_OCTAVEUP_NOTEON)
;~ $msg = _midioutshortmsg($open,$E_NOTEON)
;~ sleep(500)
;~ $msg = _midioutshortmsg($open,$G_OCTAVEUP_NOTEON)
;~ $msg = _midioutshortmsg($open,$GBASS_NOTEON)
;~ sleep(500)
;~ $msg = _midioutshortmsg($open,$F_OCTAVEUP_NOTEON)
;~ $msg = _midioutshortmsg($open,$D_NOTEON)
;~ sleep(500)
;~ $msg = _midioutshortmsg($open,$F_OCTAVEUP_NOTEON)
;~ $msg = _midioutshortmsg($open,$GBASS_NOTEON)
;~ sleep(500)
;~ $msg = _midioutshortmsg($open,$E_OCTAVEUP_NOTEON)
;~ $msg = _midioutshortmsg($open,$C_NOTEON)
;~ sleep(500)
;~ $msg = _midioutshortmsg($open,$E_OCTAVEUP_NOTEON)
;~ $msg = _midioutshortmsg($open,$GBASS_NOTEON)
;~ sleep(500)
;~ $msg = _midioutshortmsg($open,$D_OCTAVEUP_NOTEON)
;~ $msg = _midioutshortmsg($open,$B_NOTEON)
;~ sleep(500)
;~ $msg = _midioutshortmsg($open,$D_OCTAVEUP_NOTEON)
;~ $msg = _midioutshortmsg($open,$G_NOTEON)
;~ sleep(500)
;~ $msg = _midioutshortmsg($open,$G_OCTAVEUP_NOTEON)
;~ $msg = _midioutshortmsg($open,$E_NOTEON)
;~ sleep(500)
;~ $msg = _midioutshortmsg($open,$G_OCTAVEUP_NOTEON)
;~ $msg = _midioutshortmsg($open,$G_NOTEON)
;~ sleep(500)
;~ $msg = _midioutshortmsg($open,$F_OCTAVEUP_NOTEON)
;~ $msg = _midioutshortmsg($open,$D_NOTEON)
;~ sleep(500)
;~ $msg = _midioutshortmsg($open,$F_OCTAVEUP_NOTEON)
;~ $msg = _midioutshortmsg($open,$G_NOTEON)
;~ sleep(500)
;~ $msg = _midioutshortmsg($open,$E_OCTAVEUP_NOTEON)
;~ $msg = _midioutshortmsg($open,$C_NOTEON)
;~ sleep(400)
;~ $msg = _midioutshortmsg($open,$F_OCTAVEUP_NOTEON)
;~ sleep(50)
;~ $msg = _midioutshortmsg($open,$E_OCTAVEUP_NOTEON)
;~ sleep(50)
;~ $msg = _midioutshortmsg($open,$D_OCTAVEUP_NOTEON)
;~ sleep(50)
;~ $msg = _midioutshortmsg($open,$E_OCTAVEUP_NOTEON)
;~ sleep(250)
;~ $msg = _midioutshortmsg($open,$F_OCTAVEUP_NOTEON)
;~ $msg = _midioutshortmsg($open,$D_NOTEON)
;~ sleep(150)
;~ $msg = _midioutshortmsg($open,$E_OCTAVEUP_NOTEON)
;~ $msg = _midioutshortmsg($open,$C_NOTEON)
;~ $msg = _midioutshortmsg($open,$GBASS_NOTEON)
;~ sleep(500)
;~ $msg = _midioutshortmsg($open,$D_OCTAVEUP_NOTEON)
;~ $msg = _midioutshortmsg($open,$B_NOTEON)
;~ sleep(500)
;~ $msg = _midioutshortmsg($open,$C_OCTAVEUP_NOTEON)
;~ $msg = _midioutshortmsg($open,$CBASS_NOTEON)
;~ sleep(500)
;~ $msg = _midioutshortmsg($open,$C_OCTAVEUP_NOTEON)
;~ $msg = _midioutshortmsg($open,$C_NOTEON)
;~ sleep(500)
;~ $msg = _midioutshortmsg($open,$G_OCTAVEUP_NOTEON)
;~ $msg = _midioutshortmsg($open,$E_NOTEON)
;~ sleep(500)
;~ $msg = _midioutshortmsg($open,$G_OCTAVEUP_NOTEON)
;~ $msg = _midioutshortmsg($open,$C_NOTEON)
;~ sleep(500)
;~ $msg = _midioutshortmsg($open,$A_OCTAVEUP_NOTEON)
;~ $msg = _midioutshortmsg($open,$F_NOTEON)
;~ sleep(500)
;~ $msg = _midioutshortmsg($open,$A_OCTAVEUP_NOTEON)
;~ $msg = _midioutshortmsg($open,$C_NOTEON)
;~ sleep(500)
;~ $msg = _midioutshortmsg($open,$G_OCTAVEUP_NOTEON)
;~ $msg = _midioutshortmsg($open,$E_NOTEON)
;~ sleep(500)
;~ $msg = _midioutshortmsg($open,$G_OCTAVEUP_NOTEON)
;~ $msg = _midioutshortmsg($open,$C_NOTEON)
;~ sleep(500)
;~ $msg = _midioutshortmsg($open,$F_OCTAVEUP_NOTEON)
;~ $msg = _midioutshortmsg($open,$D_NOTEON)
;~ sleep(500)
;~ $msg = _midioutshortmsg($open,$F_OCTAVEUP_NOTEON)
;~ $msg = _midioutshortmsg($open,$B_NOTEON)
;~ sleep(500)
;~ $msg = _midioutshortmsg($open,$E_OCTAVEUP_NOTEON)
;~ $msg = _midioutshortmsg($open,$C_NOTEON)
;~ sleep(500)
;~ $msg = _midioutshortmsg($open,$E_OCTAVEUP_NOTEON)
;~ $msg = _midioutshortmsg($open,$A_NOTEON)
;~ sleep(500)
;~ $msg = _midioutshortmsg($open,$D_OCTAVEUP_NOTEON)
;~ $msg = _midioutshortmsg($open,$FBASS_NOTEON)
;~ sleep(400)
;~ $msg = _midioutshortmsg($open,$E_OCTAVEUP_NOTEON)
;~ sleep(50)
;~ $msg = _midioutshortmsg($open,$D_OCTAVEUP_NOTEON)
;~ sleep(50)
;~ $msg = _midioutshortmsg($open,$C_OCTAVEUP_NOTEON)
;~ sleep(50)
;~ $msg = _midioutshortmsg($open,$D_OCTAVEUP_NOTEON)
;~ sleep(250)
;~ $msg = _midioutshortmsg($open,$E_OCTAVEUP_NOTEON)
;~ $msg = _midioutshortmsg($open,$GBASS_NOTEON)
;~ sleep(150)
;~ $msg = _midioutshortmsg($open,$C_OCTAVEUP_NOTEON)
;~ $msg = _midioutshortmsg($open,$CBASS_NOTEON)
;~ sleep(1000)
;~ _MidiOutClose($open)
;=======================================================
;Retrieves the number of Midi Output devices which exist
;Parameters - None
;Author : Eynstyne
;Library : Microsoft winmm.dll
;=======================================================
Func _midiOutGetNumDevs()
$ret = DllCall("winmm.dll", "long", "midiOutGetNumDevs")
If Not @error Then Return $ret[0]
EndFunc ;==>_midiOutGetNumDevs
;=======================================================
;Retrieves the number of Midi Input devices which exist
;Parameters - None
;Author : Eynstyne
;Library : Microsoft winmm.dll
;=======================================================
Func _midiInGetNumDevs($ReturnErrorAsString = 0) ;Working
$ret = DllCall("winmm.dll", "long", "midiInGetNumDevs")
If Not @error Then Return $ret[0]
EndFunc ;==>_midiInGetNumDevs
;=======================================================
;Retrieves a MIDI handle and Opens the Device
;Parameters(Optional) - Device ID, Window Callback,
; instance, flags
;Author : Eynstyne
;Library : Microsoft winmm.dll
;=======================================================
Func _midiOutOpen($devid = 0, $callback = 0, $instance = 0, $flags = 0)
$struct = DllStructCreate("udword")
$ret = DllCall("winmm.dll", "long", "midiOutOpen", "ptr", DllStructGetPtr($struct), "int", $devid, "long", $callback, "long", $instance, "long", $flags)
If Not @error Then
$Get = DllStructGetData($struct, 1)
Return $Get
Else
Return $ret[0]
EndIf
EndFunc ;==>_midiOutOpen
;=======================================================
;Retrieves a MIDI handle and Opens the Device
;Parameters(Optional) - Device ID, Window Callback,
; instance, flags
;Author : Eynstyne
;Library : Microsoft winmm.dll
;=======================================================
Func _midiInOpen($devid = 0, $callback = 0, $instance = 0, $flags = 0)
$struct = DllStructCreate("udword")
$ret = DllCall("winmm.dll", "long", "midiInOpen", "ptr", DllStructGetPtr($struct), "int", $devid, "long", $callback, "long", $instance, "long", $flags)
If Not @error Then
$Get = DllStructGetData($struct, 1)
Return $Get
Else
Return $ret[0]
EndIf
EndFunc ;==>_midiInOpen
;=======================================================
;Sets the Mixer Volume for MIDI
;Parameters - Volume (0 - 65535)
;Author : Eynstyne
;Library : Microsoft winmm.dll
;=======================================================
Func _MidiOutSetVolume($volume, $devid = 0)
$ret = DllCall("winmm.dll", "long", "midiOutSetVolume", "long", $devid, "int", $volume)
If Not @error Then Return $ret[0]
EndFunc ;==>_MidiOutSetVolume
;=======================================================
;Gets the Mixer Volume for MIDI
;Parameters - None
;Author : Eynstyne
;Library : Microsoft winmm.dll
;=======================================================
Func _MidiOutGetVolume($devid = 0)
$struct = DllStructCreate("ushort")
$ret = DllCall("winmm.dll", "long", "midiOutGetVolume", "long", $devid, "ptr", DllStructGetPtr($struct))
If Not @error Then
$Get = DllStructGetData($struct, 1)
Return $Get
EndIf
EndFunc ;==>_MidiOutGetVolume
;=======================================================
;Resets MIDI Output/Input
;Parameters - MidiHandle
;Author : Eynstyne
;Library : Microsoft winmm.dll
;=======================================================
Func _MidiOutReset($hmidiout)
$ret = DllCall("winmm.dll", "long", "midiOutReset", "long", $hmidiout)
If Not @error Then Return $ret[0]
EndFunc ;==>_MidiOutReset
Func _MidiInReset($hmidiin)
$ret = DllCall("winmm.dll", "long", "midiInReset", "long", $hmidiin)
If Not @error Then Return $ret[0]
EndFunc ;==>_MidiInReset
;=======================================================
;Starts Midi Input
;Parameters - MidiHandle
;Author : Eynstyne
;Library : Microsoft winmm.dll
;=======================================================
Func _MidiInStart($hmidiin)
$ret = DllCall("winmm.dll", "long", "midiInStart", "long", $hmidiin)
If Not @error Then Return $ret[0]
EndFunc ;==>_MidiInStart
;=======================================================
;Stops Midi Input
;Parameters - MidiHandle
;Author : Eynstyne
;Library : Microsoft winmm.dll
;=======================================================
Func _MidiInStop($hmidiin)
$ret = DllCall("winmm.dll", "long", "midiInStop", "long", $hmidiin)
If Not @error Then Return $ret[0]
EndFunc ;==>_MidiInStop
;=======================================================
;Closes Midi Output/Input devices
;Parameters - MidiHandle
;Author : Eynstyne
;Library : Microsoft winmm.dll
;=======================================================
Func _MidiOutClose($hmidiout)
$ret = DllCall("winmm.dll", "long", "midiOutClose", "long", $hmidiout)
If Not @error Then Return $ret[0]
EndFunc ;==>_MidiOutClose
Func _MidiInClose($hmidiin)
$ret = DllCall("winmm.dll", "long", "midiInClose", "long", $hmidiin)
If Not @error Then Return $ret[0]
EndFunc ;==>_MidiInClose
;=======================================================
;Cache Drum Patches for Output
;Parameters - MidiHandle,Patch,Keynumber,Flag
;Author : Eynstyne
;Library : Microsoft winmm.dll
;=======================================================
Func _MidiOutCacheDrumPatches($hmidiout, $Patch, $keynumber, $flags = 0)
$struct = DllStructCreate("short")
$keyarray = _ArrayCreate($keynumber)
DllStructSetData($struct, 1, $keynumber)
$ret = DllCall("winmm.dll", "long", "midiOutCacheDrumPatches", "long", $hmidiout, "int", $Patch, "ptr", DllStructGetPtr($struct), "int", $flags)
If Not @error Then Return $ret[0]
EndFunc ;==>_MidiOutCacheDrumPatches
;=======================================================
;Caches MIDI Patches
;Parameters - MidiHandle, Bank, PatchNumber, Flags
;Author : Eynstyne
;Library : Microsoft winmm.dll
;=======================================================
Func _MidiOutCachePatches($hmidiout, $bank, $patchnumber, $flags = 0)
$struct = DllStructCreate("short")
$patcharray = _ArrayCreate($patchnumber)
DllStructSetData($struct, 1, $patchnumber)
$ret = DllCall("winmm.dll", "long", "midiOutCachePatches", "long", $hmidiout, "int", $bank, "ptr", DllStructGetPtr($struct), "int", $flags)
If Not @error Then Return $ret[0]
EndFunc ;==>_MidiOutCachePatches
;=======================================================
;Gets MIDI DeviceID
;Parameters - MidiHandle
;Author : Eynstyne
;Library : Microsoft winmm.dll
;=======================================================
Func _MidiInGetID($hmidiin)
$struct = DllStructCreate("uint")
$ret = DllCall("winmm.dll", "long", "midiInGetID", "long", $hmidiin, "ptr", DllStructGetPtr($struct))
If Not @error Then
$Get = DllStructGetData($struct, 1)
Return $Get
EndIf
EndFunc ;==>_MidiInGetID
Func _MidiOutGetID($hmidiout)
$struct = DllStructCreate("uint")
$ret = DllCall("winmm.dll", "long", "midiInGetID", "long", $hmidiout, "ptr", DllStructGetPtr($struct))
If Not @error Then
$Get = DllStructGetData($struct, 1)
Return $Get
EndIf
EndFunc ;==>_MidiOutGetID
;=======================================================
;Translates Error codes into Plaintext
;Parameters - Error number
;Author : Eynstyne
;Library : Microsoft winmm.dll
;=======================================================
Func _MidiInGetErrorText($error)
$struct = DllStructCreate("char[128]")
$ret = DllCall("winmm.dll", "long", "midiInGetErrorText", "int", $error, "ptr", DllStructGetPtr($struct), "int", 999)
$Get = DllStructGetData($struct, 1)
MsgBox(0, "", $Get)
EndFunc ;==>_MidiInGetErrorText
Func _MidiOutGetErrorText($error)
$struct = DllStructCreate("char[128]")
$ret = DllCall("winmm.dll", "long", "midiOutGetErrorText", "int", $error, "ptr", DllStructGetPtr($struct), "int", 999)
$Get = DllStructGetData($struct, 1)
MsgBox(0, "", $Get)
EndFunc ;==>_MidiOutGetErrorText
;=======================================================
;MIDI Message Send Function
;Parameters - Message as Hexcode or Constant
;Author : Eynstyne
;Library : Microsoft winmm.dll
;=======================================================
Func _MidiOutShortMsg($hmidiout, $msg)
$ret = DllCall("winmm.dll", "long", "midiOutShortMsg", "long", $hmidiout, "long", $msg)
If Not @error Then Return $ret[0]
EndFunc ;==>_MidiOutShortMsg
Func _MidiOutLongMsg($hmidiout, $data, $bufferlength, $bytesrecorded, $user, $flags, $next, $getmmsyserr = 0)
$struct = DllStructCreate("char[128];udword;udword;udword;udword;ushort;ushort")
DllStructSetData($struct, 1, $data)
DllStructSetData($struct, 2, $bufferlength)
DllStructSetData($struct, 3, $bytesrecorded)
DllStructSetData($struct, 4, $user)
DllStructSetData($struct, 5, $flags)
DllStructSetData($struct, 6, $next)
DllStructSetData($struct, 7, 0)
$ret = DllCall("winmm.dll", "long", "midiInPrepareHeader", "long", $hmidiout, "ptr", DllStructGetPtr($struct), "long", 999)
If Not @error Then
If $getmmsyserr = 1 Then
Return $ret[0]
ElseIf $getmmsyserr <> 1 Then
$array = _ArrayCreate($hmidiout, DllStructGetData($struct, 1), DllStructGetData($struct, 2), DllStructGetData($struct, 3), DllStructGetData($struct, 4), DllStructGetData($struct, 5), DllStructGetData($struct, 6), DllStructGetData($struct, 7))
Return $array
EndIf
EndIf
EndFunc ;==>_MidiOutLongMsg
;=======================================================
;Get the Capabilities of the MIDI Device
;Parameters - DeviceID
;Author : Eynstyne
;Library : Microsoft winmm.dll
;First Value - Manufacturer ID
;Second Value - Product ID
;Third Value - Driver Version
;Fourth Value - Driver Name
;Fifth Value - Type of Device
;Sixth Value - Voices
;Seventh Value - Notes
;eighth Value - Channel Mask
;Ninth Value - Capabilities
;=======================================================
Func _MidiOutGetDevCaps($deviceid = 0, $getmmsyserr = 0)
$struct = DllStructCreate("ushort;ushort;uint;char[128];ushort;ushort;ushort;ushort;uint")
$ret = DllCall("winmm.dll", "long", "midiOutGetDevCapsA", "long", $deviceid, "ptr", DllStructGetPtr($struct), "int", 999)
If Not @error Then
If $getmmsyserr = 1 Then
Return $ret[0]
ElseIf $getmmsyserr <> 1 Then
$array = _ArrayCreate(DllStructGetData($struct, 1), DllStructGetData($struct, 2), DllStructGetData($struct, 3), DllStructGetData($struct, 4), DllStructGetData($struct, 5), DllStructGetData($struct, 6), DllStructGetData($struct, 7), DllStructGetData($struct, 8), DllStructGetData($struct, 9))
Return $array
EndIf
EndIf
EndFunc ;==>_MidiOutGetDevCaps
;=======================================================
;Get the Capabilities of the MIDI Device Input
;Parameters - DeviceID
;Author : Eynstyne
;Library : Microsoft winmm.dll
;First Value - Manufacturer ID
;Second Value - Product ID
;Third Value - Driver Version
;Fourth Value - Driver Name
;=======================================================
Func _MidiInGetDevCaps($deviceid = 0, $getmmsyserr = 0)
$struct = DllStructCreate("ushort;ushort;uint;char[128]")
$ret = DllCall("winmm.dll", "long", "midiInGetDevCapsA", "long", $deviceid, "ptr", DllStructGetPtr($struct), "int", 999)
If Not @error Then
If $getmmsyserr = 1 Then
Return $ret[0]
ElseIf $getmmsyserr <> 1 Then
$array = _ArrayCreate(DllStructGetData($struct, 1), DllStructGetData($struct, 2), DllStructGetData($struct, 3), DllStructGetData($struct, 4))
Return $array
EndIf
EndIf
EndFunc ;==>_MidiInGetDevCaps
;========================================================
;Connect/Disconnect the MIDI Device to Application Source
; / Dest.
;Parameters - MidiHandleIn, MidiHandleOut
;Author: Eynstyne
;Library : Microsoft winmm.dll
;========================================================
Func _MidiConnect($hmidiin, $hmidiout)
$ret = DllCall("winmm.dll", "long", "midiConnect", "long", $hmidiin, "long", $hmidiout, "int", 0)
If Not @error Then Return $ret[0]
EndFunc ;==>_MidiConnect
Func _MidiDisconnect($hmidiin, $hmidiout)
$ret = DllCall("winmm.dll", "long", "midiDisconnect", "long", $hmidiin, "long", $hmidiout, "int", 0)
If Not @error Then Return $ret[0]
EndFunc ;==>_MidiDisconnect
;========================================================
;Prepare/Unprepare the MIDI header
;Parameters - MidiInHandle,Data,Bufferlength,
; BytesRecorded,User,Flags,Next,Getmmsystemerror
;Author:Eynstyne
;Library:Microsoft winmm.dll
;========================================================
Func _MidiInPrepareHeader($hmidiin, $data, $bufferlength, $bytesrecorded, $user, $flags, $next, $getmmsyserr = 0)
$struct = DllStructCreate("char[128];udword;udword;udword;udword;ushort;ushort")
DllStructSetData($struct, 1, $data)
DllStructSetData($struct, 2, $bufferlength)
DllStructSetData($struct, 3, $bytesrecorded)
DllStructSetData($struct, 4, $user)
DllStructSetData($struct, 5, $flags)
DllStructSetData($struct, 6, $next)
DllStructSetData($struct, 7, 0)
$ret = DllCall("winmm.dll", "long", "midiInPrepareHeader", "long", $hmidiin, "ptr", DllStructGetPtr($struct), "long", 999)
If Not @error Then
If $getmmsyserr = 1 Then
Return $ret[0]
ElseIf $getmmsyserr <> 1 Then
$array = _ArrayCreate($hmidiin, DllStructGetData($struct, 1), DllStructGetData($struct, 2), DllStructGetData($struct, 3), DllStructGetData($struct, 4), DllStructGetData($struct, 5), DllStructGetData($struct, 6), DllStructGetData($struct, 7))
Return $array
EndIf
EndIf
EndFunc ;==>_MidiInPrepareHeader
Func _MidiInUnprepareHeader($hmidiin, $data, $bufferlength, $bytesrecorded, $user, $flags, $next, $getmmsyserr = 0)
$struct = DllStructCreate("char[128];udword;udword;udword;udword;ushort;ushort")
DllStructSetData($struct, 1, $data)
DllStructSetData($struct, 2, $bufferlength)
DllStructSetData($struct, 3, $bytesrecorded)
DllStructSetData($struct, 4, $user)
DllStructSetData($struct, 5, $flags)
DllStructSetData($struct, 6, $next)
DllStructSetData($struct, 7, 0)
$ret = DllCall("winmm.dll", "long", "midiInUnprepareHeader", "long", $hmidiin, "ptr", DllStructGetPtr($struct), "long", 999)
If Not @error Then
If $getmmsyserr = 1 Then
Return $ret[0]
ElseIf $getmmsyserr <> 1 Then
$array = _ArrayCreate($hmidiin, DllStructGetData($struct, 1), DllStructGetData($struct, 2), DllStructGetData($struct, 3), DllStructGetData($struct, 4), DllStructGetData($struct, 5), DllStructGetData($struct, 6), DllStructGetData($struct, 7))
Return $array
EndIf
EndIf
EndFunc ;==>_MidiInUnprepareHeader
;========================================================
;Add buffer to Midi Header
;Parameters - MidiInHandle,Data,Bufferlength,
; BytesRecorded,User,Flags,Next,Getmmsystemerror
;Author:Eynstyne
;Library:Microsoft winmm.dll
;========================================================
Func _MidiInAddBuffer($hmidiin, $data, $bufferlength, $bytesrecorded, $user, $flags, $next, $getmmsyserr = 0)
$struct = DllStructCreate("char[128];udword;udword;udword;udword;ushort;ushort")
DllStructSetData($struct, 1, $data)
DllStructSetData($struct, 2, $bufferlength)
DllStructSetData($struct, 3, $bytesrecorded)
DllStructSetData($struct, 4, $user)
DllStructSetData($struct, 5, $flags)
DllStructSetData($struct, 6, $next)
DllStructSetData($struct, 7, 0)
$ret = DllCall("winmm.dll", "long", "midiInAddBuffer", "long", $hmidiin, "ptr", DllStructGetPtr($struct), "long", 999)
If Not @error Then
If $getmmsyserr = 1 Then
Return $ret[0]
ElseIf $getmmsyserr <> 1 Then
$array = _ArrayCreate($hmidiin, DllStructGetData($struct, 1), DllStructGetData($struct, 2), DllStructGetData($struct, 3), DllStructGetData($struct, 4), DllStructGetData($struct, 5), DllStructGetData($struct, 6), DllStructGetData($struct, 7))
Return $array
EndIf
EndIf
EndFunc ;==>_MidiInAddBuffer
;========================================================
;Sends Internal MIDI Info to Input / Output device
;Parameters - MidiInHandle,message, parameter1, parameter2
;Author:Eynstyne
;Library:Microsoft winmm.dll
;========================================================
Func _MidiInMessage($hmidiin, $msg, $dw1 = 0, $dw2 = 0)
$ret = DllCall("winmm.dll", "long", "midiInMessage", "long", $hmidiin, "long", $msg, "long", $dw1, "long", $dw2)
If Not @error Then Return $ret[0]
EndFunc ;==>_MidiInMessage
Func _MidiOutMessage($hmidiout, $msg, $dw1 = 0, $dw2 = 0)
$ret = DllCall("winmm.dll", "long", "midiOutMessage", "long", $hmidiout, "long", $msg, "long", $dw1, "long", $dw2)
If Not @error Then Return $ret[0]
EndFunc ;==>_MidiOutMessage
;====================
;Stream Functions
;====================
Func _midiStreamClose($hmidiStream)
$ret = DllCall("winmm.dll", "long", "midiStreamClose", "long", $hmidiStream)
If Not @error Then Return $ret[0]
EndFunc ;==>_midiStreamClose
Func _midiStreamOpen($cMidi = 0, $callback = 0, $instance = 0, $fdwopen = 0, $getmmsyserr = 0)
$struct = DllStructCreate("udword;uint")
$ret = DllCall("winmm.dll", "long", "midiStreamOpen", "ptr", DllStructGetPtr($struct, 1), "ptr", DllStructGetPtr($struct, 2), "long", $cMidi, "long", $callback, "long", $instance, "long", $fdwopen)
If Not @error Then
If $getmmsyserr = 1 Then
Return $ret[0]
ElseIf $getmmsyserr <> 1 Then
$array = _ArrayCreate(DllStructGetData($struct, 1), DllStructGetData($struct, 2))
Return $array
EndIf
EndIf
EndFunc ;==>_midiStreamOpen
Func _midiStreamPause($hmidiStream)
$ret = DllCall("winmm.dll", "long", "midiStreamPause", "long", $hmidiStream)
If Not @error Then Return $ret[0]
EndFunc ;==>_midiStreamPause
Func _midiStreamPos($hmidiStream, $cbmmt = 0, $getmmsyserr = 0)
$struct = DllStructCreate("ushort;ushort")
$ret = DllCall("winmm.dll", "long", "midiStreamPause", "long", $hmidiStream, "ptr", DllStructGetPtr($struct), "long", $cbmmt)
If Not @error Then
If $getmmsyserr = 1 Then
Return $ret[0]
ElseIf $getmmsyserr <> 1 Then
$array = _ArrayCreate(DllStructGetData($struct, 1), DllStructGetData($struct, 2))
Return $array
EndIf
EndIf
EndFunc ;==>_midiStreamPos
Func _midiStreamRestart($hmidiStream)
$ret = DllCall("winmm.dll", "long", "midiStreamRestart", "long", $hmidiStream)
If Not @error Then Return $ret[0]
EndFunc ;==>_midiStreamRestart
Func _midiStreamStop($hmidiStream)
$ret = DllCall("winmm.dll", "long", "midiStreamStop", "long", $hmidiStream)
If Not @error Then Return $ret[0]
EndFunc ;==>_midiStreamStop
Func _midiStreamProperty($hmidiStream, $property = 0, $getmmsyserr = 0)
;~ Local $getmmsyserr
$struct = DllStructCreate("byte")
$ret = DllCall("winmm.dll", "long", "midiStreamProperty", "long", $hmidiStream, "ptr", DllStructGetPtr($struct), "long", $property)
If Not @error Then
If $getmmsyserr = 1 Then
Return $ret[0]
ElseIf $getmmsyserr <> 1 Then
$Get = DllStructGetData($struct, 1)
Return $Get
EndIf
EndIf
EndFunc ;==>_midiStreamProperty