MIDI Programming in .NET

Here’s the code I use in the Sends on Fader Application to Read and Write MIDI From/To the Yamaha consoles. Should work for any MIDI messages.


[SIZE=2]Module[/SIZE] MidiFunctions
[SIZE=2]' MIDI input device capabilities structure
[/SIZE]<StructLayout(LayoutKind.Sequential)> _
[SIZE=2]Public[/SIZE][SIZE=2]Structure[/SIZE] MIDIINCAPS
[SIZE=2] Dim[/SIZE] wMid [SIZE=2]As [/SIZE][SIZE=2]Short[/SIZE][SIZE=2]' Manufacturer ID
[/SIZE][SIZE=2] Dim[/SIZE] wPid [SIZE=2]As [/SIZE][SIZE=2]Short[/SIZE][SIZE=2]' Product ID
[/SIZE][SIZE=2] Dim[/SIZE] vDriverVersion [SIZE=2]As [/SIZE][SIZE=2]Integer[/SIZE][SIZE=2]' Driver version
[/SIZE] <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=32)> [SIZE=2]Dim[/SIZE] szPname[SIZE=2] As [/SIZE][SIZE=2]String[/SIZE][SIZE=2]' Product Name
[/SIZE][SIZE=2] Dim[/SIZE] dwSupport [SIZE=2]As [/SIZE][SIZE=2]Integer[/SIZE][SIZE=2]' Supported extras
[/SIZE][SIZE=2]End[/SIZE][SIZE=2]Structure[/SIZE]
 
[SIZE=2]' MIDI output device capabilities structure
[/SIZE]<StructLayout(LayoutKind.Sequential)> _
[SIZE=2]Public [/SIZE][SIZE=2]Structure[/SIZE] MIDIOUTCAPS
[SIZE=2] Dim[/SIZE] wMid [SIZE=2]As [/SIZE][SIZE=2]Short      [/SIZE][SIZE=2]' Manufacturer ID
[/SIZE][SIZE=2] Dim[/SIZE] wPid [SIZE=2]As [/SIZE][SIZE=2]Short      [/SIZE][SIZE=2]' Product ID
[/SIZE][SIZE=2] Dim[/SIZE] vDriverVersion [SIZE=2]As [/SIZE][SIZE=2]Integer      [/SIZE][SIZE=2]' Driver version
[/SIZE] <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=32)> [SIZE=2]Dim[/SIZE] szPname [SIZE=2]As [/SIZE][SIZE=2]String      [/SIZE][SIZE=2]' Product Name
[/SIZE][SIZE=2] Dim[/SIZE] wTechnology [SIZE=2]As [/SIZE][SIZE=2]Short      [/SIZE][SIZE=2]' Device type
[/SIZE][SIZE=2] Dim[/SIZE] wVoices [SIZE=2]As [/SIZE][SIZE=2]Short      [/SIZE][SIZE=2]' n. of voices (internal synth only)
[/SIZE][SIZE=2] Dim[/SIZE] wNotes [SIZE=2]As [/SIZE][SIZE=2]Short      [/SIZE][SIZE=2]' max n. of notes (internal synth only)
[/SIZE][SIZE=2] Dim[/SIZE] wChannelMask [SIZE=2]As [/SIZE][SIZE=2]Short      [/SIZE][SIZE=2]' n. of Midi channels (internal synth only)
[/SIZE][SIZE=2] Dim[/SIZE] dwSupport [SIZE=2]As [/SIZE][SIZE=2]Integer      [/SIZE][SIZE=2]' Supported extra controllers (volume, etc)
[/SIZE][SIZE=2]End[/SIZE][SIZE=2]Structure[/SIZE]
 
[SIZE=2]' MIDI data block header
[/SIZE]<StructLayout(LayoutKind.Sequential)> _
[SIZE=2]Public [/SIZE][SIZE=2]Structure[/SIZE] MIDIHDR
[SIZE=2] Dim[/SIZE] lpData [SIZE=2]As[/SIZE] IntPtr      [SIZE=2]' pointer to locked data block
[/SIZE][SIZE=2] Dim[/SIZE] dwBufferLength [SIZE=2]As [/SIZE][SIZE=2]Integer      [/SIZE][SIZE=2]' length of data in data block
[/SIZE][SIZE=2] Dim[/SIZE] dwBytesRecorded [SIZE=2]As [/SIZE][SIZE=2]Integer      [/SIZE][SIZE=2]' used for input only
[/SIZE][SIZE=2] Dim[/SIZE] dwUser [SIZE=2]As [/SIZE][SIZE=2]Integer      [/SIZE][SIZE=2]' for client's use
[/SIZE][SIZE=2] Dim[/SIZE] dwFlags [SIZE=2]As [/SIZE][SIZE=2]Integer      [/SIZE][SIZE=2]' assorted flags (see defines)
[/SIZE][SIZE=2] Dim[/SIZE] lpNext [SIZE=2]As [/SIZE][SIZE=2]Integer      [/SIZE][SIZE=2]' reserved for driver
[/SIZE][SIZE=2] Dim[/SIZE] reserved [SIZE=2]As [/SIZE][SIZE=2]Integer      [/SIZE][SIZE=2]' reserved for driver
[/SIZE][SIZE=2] Dim[/SIZE] dwOffset [SIZE=2]As [/SIZE][SIZE=2]Integer
[/SIZE][SIZE=2] Dim[/SIZE] reserved1 [SIZE=2]As [/SIZE][SIZE=2]Integer
[/SIZE][SIZE=2] Dim[/SIZE] reserved2 [SIZE=2]As [/SIZE][SIZE=2]Integer
[/SIZE][SIZE=2] Dim[/SIZE] reserved3 [SIZE=2]As [/SIZE][SIZE=2]Integer
[/SIZE][SIZE=2] Dim[/SIZE] reserved4 [SIZE=2]As [/SIZE][SIZE=2]Integer
[/SIZE][SIZE=2]End [/SIZE][SIZE=2]Structure[/SIZE]
 
[SIZE=2]'Input functions
[/SIZE][SIZE=2]Declare [/SIZE][SIZE=2]Function[/SIZE] midiInGetNumDevs [SIZE=2]Lib [/SIZE][SIZE=2]"winmm.dll"[/SIZE] () [SIZE=2]As [/SIZE][SIZE=2]Short
[/SIZE][SIZE=2]Declare [/SIZE][SIZE=2]Function[/SIZE] midiInGetDevCaps [SIZE=2]Lib [/SIZE][SIZE=2]"winmm.dll" [/SIZE][SIZE=2]Alias [/SIZE][SIZE=2]"midiInGetDevCapsA"[/SIZE] ([SIZE=2]ByVal[/SIZE] uDeviceID [SIZE=2]As [/SIZE][SIZE=2]Integer[/SIZE], [SIZE=2]ByRef[/SIZE] lpCaps [SIZE=2]As[/SIZE] MIDIINCAPS, [SIZE=2]ByVal[/SIZE] uSize [SIZE=2]As [/SIZE][SIZE=2]Integer[/SIZE]) [SIZE=2]As [/SIZE][SIZE=2]Integer
[/SIZE][SIZE=2]Declare [/SIZE][SIZE=2]Function[/SIZE] midiInGetErrorText [SIZE=2]Lib [/SIZE][SIZE=2]"winmm.dll" [/SIZE][SIZE=2]Alias[/SIZE][SIZE=2] "midiInGetErrorTextA"[/SIZE] ([SIZE=2]ByVal[/SIZE] err_Renamed [SIZE=2]As [/SIZE][SIZE=2]Integer[/SIZE], [SIZE=2]ByVal[/SIZE] lpText [SIZE=2]As [/SIZE][SIZE=2]String[/SIZE], [SIZE=2]ByVal[/SIZE] uSize [SIZE=2]As [/SIZE][SIZE=2]Integer[/SIZE]) [SIZE=2]As [/SIZE][SIZE=2]Integer
[/SIZE][SIZE=2]Declare [/SIZE][SIZE=2]Function[/SIZE] midiInOpen [SIZE=2]Lib [/SIZE][SIZE=2]"winmm.dll"[/SIZE] ([SIZE=2]ByRef[/SIZE] lphMidiIn [SIZE=2]As [/SIZE][SIZE=2]Integer[/SIZE], [SIZE=2]ByVal[/SIZE] uDeviceID [SIZE=2]As [/SIZE][SIZE=2]Integer[/SIZE], [SIZE=2]ByVal[/SIZE] dwCallback [SIZE=2]As[/SIZE] MidiDelegate, _
[SIZE=2]ByVal[/SIZE] dwInstance [SIZE=2]As [/SIZE][SIZE=2]Integer[/SIZE], [SIZE=2]ByVal[/SIZE] dwFlags [SIZE=2]As [/SIZE][SIZE=2]Integer[/SIZE]) [SIZE=2]As [/SIZE][SIZE=2]Integer
[/SIZE][SIZE=2]Declare [/SIZE][SIZE=2]Function[/SIZE] midiInClose [SIZE=2]Lib [/SIZE][SIZE=2]"winmm.dll"[/SIZE] ([SIZE=2]ByVal[/SIZE] hMidiIN [SIZE=2]As [/SIZE][SIZE=2]Integer[/SIZE]) [SIZE=2]As [/SIZE][SIZE=2]Integer
[/SIZE][SIZE=2]Declare [/SIZE][SIZE=2]Function[/SIZE] midiInPrepareHeader [SIZE=2]Lib [/SIZE][SIZE=2]"winmm.dll"[/SIZE] ([SIZE=2]ByVal[/SIZE] hMidiIN [SIZE=2]As [/SIZE][SIZE=2]Integer[/SIZE], [SIZE=2]ByRef[/SIZE] lpMidiInHdr [SIZE=2]As[/SIZE] MIDIHDR, [SIZE=2]ByVal[/SIZE] uSize [SIZE=2]As [/SIZE][SIZE=2]Integer[/SIZE]) [SIZE=2]As [/SIZE][SIZE=2]Integer
[/SIZE][SIZE=2]Declare [/SIZE][SIZE=2]Function[/SIZE] midiInUnprepareHeader [SIZE=2]Lib [/SIZE][SIZE=2]"winmm.dll"[/SIZE] ([SIZE=2]ByVal[/SIZE] hMidiIN [SIZE=2]As [/SIZE][SIZE=2]Integer[/SIZE], [SIZE=2]ByRef[/SIZE] lpMidiInHdr [SIZE=2]As[/SIZE] MIDIHDR, [SIZE=2]ByVal[/SIZE] uSize [SIZE=2]As [/SIZE][SIZE=2]Integer[/SIZE]) [SIZE=2]As [/SIZE][SIZE=2]Integer
[/SIZE][SIZE=2]Declare [/SIZE][SIZE=2]Function[/SIZE] midiInAddBuffer [SIZE=2]Lib [/SIZE][SIZE=2]"winmm.dll"[/SIZE] ([SIZE=2]ByVal[/SIZE] hMidiIN [SIZE=2]As [/SIZE][SIZE=2]Integer[/SIZE], [SIZE=2]ByRef[/SIZE] lpMidiInHdr [SIZE=2]As[/SIZE] MIDIHDR, [SIZE=2]ByVal[/SIZE] uSize [SIZE=2]As [/SIZE][SIZE=2]Integer[/SIZE]) [SIZE=2]As [/SIZE][SIZE=2]Integer
[/SIZE][SIZE=2]Declare [/SIZE][SIZE=2]Function[/SIZE] midiInReset [SIZE=2]Lib [/SIZE][SIZE=2]"winmm.dll"[/SIZE] ([SIZE=2]ByVal[/SIZE] hMidiIN [SIZE=2]As [/SIZE][SIZE=2]Integer[/SIZE]) [SIZE=2]As [/SIZE][SIZE=2]Integer
[/SIZE][SIZE=2]Declare [/SIZE][SIZE=2]Function[/SIZE] midiInStart [SIZE=2]Lib [/SIZE][SIZE=2]"winmm.dll"[/SIZE] ([SIZE=2]ByVal[/SIZE] hMidiIN [SIZE=2]As [/SIZE][SIZE=2]Integer[/SIZE]) [SIZE=2]As [/SIZE][SIZE=2]Integer
[/SIZE][SIZE=2]Declare [/SIZE][SIZE=2]Function[/SIZE] midiInStop [SIZE=2]Lib [/SIZE][SIZE=2]"winmm.dll"[/SIZE] ([SIZE=2]ByVal[/SIZE] hMidiIN [SIZE=2]As [/SIZE][SIZE=2]Integer[/SIZE]) [SIZE=2]As [/SIZE][SIZE=2]Integer[/SIZE]
 
[SIZE=2]'Output functions
[/SIZE][SIZE=2]Declare [/SIZE][SIZE=2]Function[/SIZE] midiOutGetNumDevs [SIZE=2]Lib [/SIZE][SIZE=2]"winmm.dll"[/SIZE] () [SIZE=2]As [/SIZE][SIZE=2]Short
[/SIZE][SIZE=2]Declare [/SIZE][SIZE=2]Function[/SIZE] midiOutGetDevCaps [SIZE=2]Lib [/SIZE][SIZE=2]"winmm.dll" [/SIZE][SIZE=2]Alias [/SIZE][SIZE=2]"midiOutGetDevCapsA"[/SIZE] ([SIZE=2]ByVal[/SIZE] uDeviceID [SIZE=2]As [/SIZE][SIZE=2]Integer[/SIZE], [SIZE=2]ByRef[/SIZE] lpCaps [SIZE=2]As[/SIZE] MIDIOUTCAPS, [SIZE=2]ByVal[/SIZE] uSize [SIZE=2]As [/SIZE][SIZE=2]Integer[/SIZE]) [SIZE=2]As [/SIZE][SIZE=2]Integer
[/SIZE][SIZE=2]Declare [/SIZE][SIZE=2]Function[/SIZE] midiOutGetErrorText [SIZE=2]Lib [/SIZE][SIZE=2]"winmm.dll" [/SIZE][SIZE=2]Alias [/SIZE][SIZE=2]"midiOutGetErrorTextA"[/SIZE] ([SIZE=2]ByVal[/SIZE] errcode [SIZE=2]As [/SIZE][SIZE=2]Integer[/SIZE], [SIZE=2]ByVal[/SIZE] lpText [SIZE=2]As [/SIZE][SIZE=2]String[/SIZE], [SIZE=2]ByVal[/SIZE] uSize [SIZE=2]As [/SIZE][SIZE=2]Integer[/SIZE]) [SIZE=2]As [/SIZE][SIZE=2]Integer
[/SIZE][SIZE=2]Declare [/SIZE][SIZE=2]Function[/SIZE] midiOutOpen [SIZE=2]Lib [/SIZE][SIZE=2]"winmm.dll"[/SIZE] ([SIZE=2]ByRef[/SIZE] lphMidiOut [SIZE=2]As [/SIZE][SIZE=2]Integer[/SIZE], [SIZE=2]ByVal[/SIZE] uDeviceID [SIZE=2]As [/SIZE][SIZE=2]Integer[/SIZE], [SIZE=2]ByVal[/SIZE] dwCallback [SIZE=2]As [/SIZE][SIZE=2]Integer[/SIZE], _
[SIZE=2]ByVal[/SIZE] dwInstance [SIZE=2]As [/SIZE][SIZE=2]Integer[/SIZE], [SIZE=2]ByVal[/SIZE] dwFlags [SIZE=2]As [/SIZE][SIZE=2]Integer[/SIZE]) [SIZE=2]As [/SIZE][SIZE=2]Integer
[/SIZE][SIZE=2]Declare [/SIZE][SIZE=2]Function[/SIZE] midiOutClose [SIZE=2]Lib [/SIZE][SIZE=2]"winmm.dll"[/SIZE] ([SIZE=2]ByVal[/SIZE] hMidiOut [SIZE=2]As [/SIZE][SIZE=2]Integer[/SIZE]) [SIZE=2]As [/SIZE][SIZE=2]Integer
[/SIZE][SIZE=2]Declare [/SIZE][SIZE=2]Function[/SIZE] midiOutPrepareHeader [SIZE=2]Lib [/SIZE][SIZE=2]"winmm.dll"[/SIZE] ([SIZE=2]ByVal[/SIZE] hMidiOut [SIZE=2]As [/SIZE][SIZE=2]Integer[/SIZE], [SIZE=2]ByRef[/SIZE] lpMidiOutHdr [SIZE=2]As[/SIZE] MIDIHDR, [SIZE=2]ByVal[/SIZE] uSize [SIZE=2]As [/SIZE][SIZE=2]Integer[/SIZE]) [SIZE=2]As [/SIZE][SIZE=2]Integer
[/SIZE][SIZE=2]Declare [/SIZE][SIZE=2]Function[/SIZE] midiOutUnprepareHeader [SIZE=2]Lib [/SIZE][SIZE=2]"winmm.dll"[/SIZE] ([SIZE=2]ByVal[/SIZE] hMidiOut [SIZE=2]As [/SIZE][SIZE=2]Integer[/SIZE], [SIZE=2]ByRef[/SIZE] lpMidiOutHdr [SIZE=2]As[/SIZE] MIDIHDR, [SIZE=2]ByVal[/SIZE] uSize [SIZE=2]As [/SIZE][SIZE=2]Integer[/SIZE]) [SIZE=2]As [/SIZE][SIZE=2]Integer
[/SIZE][SIZE=2]Declare [/SIZE][SIZE=2]Function[/SIZE] midiOutShortMsg [SIZE=2]Lib [/SIZE][SIZE=2]"winmm.dll"[/SIZE] ([SIZE=2]ByVal[/SIZE] hMidiOut [SIZE=2]As [/SIZE][SIZE=2]Integer[/SIZE], [SIZE=2]ByVal[/SIZE] dwMsg [SIZE=2]As [/SIZE][SIZE=2]Integer[/SIZE]) [SIZE=2]As [/SIZE][SIZE=2]Integer
[/SIZE][SIZE=2]Declare [/SIZE][SIZE=2]Function[/SIZE] midiOutLongMsg [SIZE=2]Lib [/SIZE][SIZE=2]"winmm.dll"[/SIZE] ([SIZE=2]ByVal[/SIZE] hMidiOut [SIZE=2]As [/SIZE][SIZE=2]Integer[/SIZE], [SIZE=2]ByRef[/SIZE] lpMidiOutHdr [SIZE=2]As[/SIZE] MIDIHDR, [SIZE=2]ByVal[/SIZE] uSize [SIZE=2]As [/SIZE][SIZE=2]Integer[/SIZE]) [SIZE=2]As [/SIZE][SIZE=2]Integer
[/SIZE][SIZE=2]Public [/SIZE][SIZE=2]Delegate [/SIZE][SIZE=2]Sub[/SIZE] MidiDelegate([SIZE=2]ByVal[/SIZE] MidiHandle [SIZE=2]As[/SIZE] Int32, [SIZE=2]ByVal[/SIZE] wMsg [SIZE=2]As[/SIZE] Int32, [SIZE=2]ByVal[/SIZE] Instance [SIZE=2]As[/SIZE] Int32, [SIZE=2]ByVal[/SIZE] wParam [SIZE=2]As[/SIZE] Int32, [SIZE=2]ByVal[/SIZE] lParam [SIZE=2]As[/SIZE] Int32)
 
[SIZE=2]' Callback Function constants
[/SIZE][SIZE=2]Public [/SIZE][SIZE=2]Const[/SIZE] CALLBACK_FUNCTION [SIZE=2]As [/SIZE][SIZE=2]Integer[/SIZE] = &H30000      [SIZE=2]' dwCallback is a FARPROC
[/SIZE][SIZE=2]Public [/SIZE][SIZE=2]Const[/SIZE] MIM_OPEN [SIZE=2]As [/SIZE][SIZE=2]Short[/SIZE] = &H3C1S      [SIZE=2]' MIDI In Port Opened
[/SIZE][SIZE=2]Public [/SIZE][SIZE=2]Const[/SIZE] MIM_CLOSE [SIZE=2]As [/SIZE][SIZE=2]Short[/SIZE] = &H3C2S      [SIZE=2]' MIDI In Port Closed
[/SIZE][SIZE=2]Public [/SIZE][SIZE=2]Const[/SIZE] MIM_DATA [SIZE=2]As [/SIZE][SIZE=2]Short[/SIZE] = &H3C3S      [SIZE=2]' MIDI In Short Data (e.g. Notes & CC)
[/SIZE][SIZE=2]Public [/SIZE][SIZE=2]Const[/SIZE] MIM_LONGDATA [SIZE=2]As [/SIZE][SIZE=2]Short[/SIZE] = &H3C4S      [SIZE=2]' MIDI In Long Data (i.e. SYSEX)
[/SIZE][SIZE=2]Public [/SIZE][SIZE=2]Const[/SIZE] MIM_ERROR [SIZE=2]As [/SIZE][SIZE=2]Short[/SIZE] = &H3C5S      [SIZE=2]' MIDI In Error
[/SIZE][SIZE=2]Public [/SIZE][SIZE=2]Const[/SIZE] MIM_LONGERROR [SIZE=2]As [/SIZE][SIZE=2]Short[/SIZE] = &H3C6S      [SIZE=2]' MIDI In Long Error
[/SIZE][SIZE=2]Public [/SIZE][SIZE=2]Const[/SIZE] MIM_MOREDATA [SIZE=2]As [/SIZE][SIZE=2]Short[/SIZE] = &H3CCS      [SIZE=2]' MIDI Header Buffer is Full
[/SIZE][SIZE=2]Public [/SIZE][SIZE=2]Const[/SIZE] MOM_OPEN [SIZE=2]As [/SIZE][SIZE=2]Short[/SIZE] = &H3C7S      [SIZE=2]' MIDI Out Port Opened
[/SIZE][SIZE=2]Public [/SIZE][SIZE=2]Const[/SIZE] MOM_CLOSE [SIZE=2]As [/SIZE][SIZE=2]Short[/SIZE] = &H3C8S      [SIZE=2]' MIDI Out Port Closed
[/SIZE][SIZE=2]Public [/SIZE][SIZE=2]Const[/SIZE] MOM_DONE [SIZE=2]As [/SIZE][SIZE=2]Short[/SIZE] = &H3C9S      [SIZE=2]' MIDI Out Data sending completed
[/SIZE][SIZE=2]Public [/SIZE][SIZE=2]Const[/SIZE] MOM_POSITIONCB [SIZE=2]As [/SIZE][SIZE=2]Short[/SIZE] = &HCAS      [SIZE=2]' MIDI Out Position requested
 
[/SIZE][SIZE=2]' Midi Error Constants
[/SIZE][SIZE=2]Public [/SIZE][SIZE=2]Const[/SIZE] MMSYSERR_NOERROR [SIZE=2]As [/SIZE][SIZE=2]Short[/SIZE] = 0
[SIZE=2]Public [/SIZE][SIZE=2]Const[/SIZE] MMSYSERR_ERROR [SIZE=2]As [/SIZE][SIZE=2]Short[/SIZE] = 1
[SIZE=2]Public [/SIZE][SIZE=2]Const[/SIZE] MMSYSERR_BADDEVICEID [SIZE=2]As [/SIZE][SIZE=2]Short[/SIZE] = 2
[SIZE=2]Public [/SIZE][SIZE=2]Const[/SIZE] MMSYSERR_NOTENABLED [SIZE=2]As [/SIZE][SIZE=2]Short[/SIZE] = 3
[SIZE=2]Public [/SIZE][SIZE=2]Const[/SIZE] MMSYSERR_ALLOCATED [SIZE=2]As [/SIZE][SIZE=2]Short[/SIZE] = 4
[SIZE=2]Public [/SIZE][SIZE=2]Const[/SIZE] MMSYSERR_INVALHANDLE [SIZE=2]As [/SIZE][SIZE=2]Short[/SIZE] = 5
[SIZE=2]Public [/SIZE][SIZE=2]Const[/SIZE] MMSYSERR_NODRIVER [SIZE=2]As [/SIZE][SIZE=2]Short[/SIZE] = 6
[SIZE=2]Public [/SIZE][SIZE=2]Const[/SIZE] MMSYSERR_NOMEM [SIZE=2]As [/SIZE][SIZE=2]Short[/SIZE] = 7
[SIZE=2]Public [/SIZE][SIZE=2]Const[/SIZE] MMSYSERR_NOTSUPPORTED [SIZE=2]As [/SIZE][SIZE=2]Short[/SIZE] = 8
[SIZE=2]Public [/SIZE][SIZE=2]Const[/SIZE] MMSYSERR_BADERRNUM [SIZE=2]As [/SIZE][SIZE=2]Short[/SIZE] = 9
[SIZE=2]Public [/SIZE][SIZE=2]Const[/SIZE] MMSYSERR_INVALFLAG [SIZE=2]As [/SIZE][SIZE=2]Short[/SIZE] = 10
[SIZE=2]Public [/SIZE][SIZE=2]Const[/SIZE] MMSYSERR_INVALPARAM [SIZE=2]As [/SIZE][SIZE=2]Short[/SIZE] = 11
[SIZE=2]Public [/SIZE][SIZE=2]Const[/SIZE] MMSYSERR_HANDLEBUSY [SIZE=2]As [/SIZE][SIZE=2]Short[/SIZE] = 12
[SIZE=2]Public [/SIZE][SIZE=2]Const[/SIZE] MMSYSERR_INVALIDALIAS [SIZE=2]As [/SIZE][SIZE=2]Short[/SIZE] = 13
[SIZE=2]Public [/SIZE][SIZE=2]Const[/SIZE] MMSYSERR_BADDB [SIZE=2]As [/SIZE][SIZE=2]Short[/SIZE] = 14
[SIZE=2]Public [/SIZE][SIZE=2]Const[/SIZE] MMSYSERR_KEYNOTFOUND [SIZE=2]As [/SIZE][SIZE=2]Short[/SIZE] = 15
[SIZE=2]Public [/SIZE][SIZE=2]Const[/SIZE] MMSYSERR_READERROR [SIZE=2]As [/SIZE][SIZE=2]Short[/SIZE] = 16
[SIZE=2]Public [/SIZE][SIZE=2]Const[/SIZE] MMSYSERR_WRITEERROR [SIZE=2]As [/SIZE][SIZE=2]Short[/SIZE] = 17
[SIZE=2]Public [/SIZE][SIZE=2]Const[/SIZE] MMSYSERR_DELETEERROR [SIZE=2]As [/SIZE][SIZE=2]Short[/SIZE] = 18
[SIZE=2]Public [/SIZE][SIZE=2]Const[/SIZE] MMSYSERR_VALNOTFOUND [SIZE=2]As [/SIZE][SIZE=2]Short[/SIZE] = 19
[SIZE=2]Public [/SIZE][SIZE=2]Const[/SIZE] MMSYSERR_NODRIVERCB [SIZE=2]As [/SIZE][SIZE=2]Short[/SIZE] = 20
[SIZE=2]Public [/SIZE][SIZE=2]Const[/SIZE] MMSYSERR_LASTERROR [SIZE=2]As [/SIZE][SIZE=2]Short[/SIZE] = 20
[SIZE=2]Public [/SIZE][SIZE=2]Const[/SIZE] MIDIERR_UNPREPARED [SIZE=2]As [/SIZE][SIZE=2]Short[/SIZE] = 64 [SIZE=2]' header not prepared
[/SIZE][SIZE=2]Public [/SIZE][SIZE=2]Const[/SIZE] MIDIERR_STILLPLAYING [SIZE=2]As [/SIZE][SIZE=2]Short[/SIZE] = 65 [SIZE=2]' still something playing
[/SIZE][SIZE=2]Public [/SIZE][SIZE=2]Const[/SIZE] MIDIERR_NOMAP [SIZE=2]As [/SIZE][SIZE=2]Short[/SIZE] = 66 [SIZE=2]' no current map
[/SIZE][SIZE=2]Public [/SIZE][SIZE=2]Const[/SIZE] MIDIERR_NOTREADY [SIZE=2]As [/SIZE][SIZE=2]Short[/SIZE] = 67 [SIZE=2]' hardware is still busy
[/SIZE][SIZE=2]Public [/SIZE][SIZE=2]Const[/SIZE] MIDIERR_NODEVICE [SIZE=2]As [/SIZE][SIZE=2]Short[/SIZE] = 68 [SIZE=2]' port no longer connected
[/SIZE][SIZE=2]Public [/SIZE][SIZE=2]Const[/SIZE] MIDIERR_INVALIDSETUP [SIZE=2]As [/SIZE][SIZE=2]Short[/SIZE] = 69 [SIZE=2]' invalid setup
[/SIZE][SIZE=2]Public [/SIZE][SIZE=2]Const[/SIZE] MIDIERR_LASTERROR [SIZE=2]As [/SIZE][SIZE=2]Short[/SIZE] = 69 [SIZE=2]' last error in range
[/SIZE]
[SIZE=2]' Midi Header flags
[/SIZE][SIZE=2]Public [/SIZE][SIZE=2]Const[/SIZE] MHDR_DONE [SIZE=2]As [/SIZE][SIZE=2]Short[/SIZE] = 1 [SIZE=2]' Set by the device driver to indicate that it is finished with the buffer and is returning it to the application.
[/SIZE][SIZE=2]Public [/SIZE][SIZE=2]Const[/SIZE] MHDR_PREPARED [SIZE=2]As [/SIZE][SIZE=2]Short[/SIZE] = 2 [SIZE=2]' Set by Windows to indicate that the buffer has been prepared
[/SIZE][SIZE=2]Public [/SIZE][SIZE=2]Const[/SIZE] MHDR_INQUEUE [SIZE=2]As [/SIZE][SIZE=2]Short[/SIZE] = 4 [SIZE=2]' Set by Windows to indicate that the buffer is queued for playback
[/SIZE][SIZE=2]Public [/SIZE][SIZE=2]Const[/SIZE] MHDR_ISSTRM [SIZE=2]As [/SIZE][SIZE=2]Short[/SIZE] = 8 [SIZE=2]' Set to indicate that the buffer is a stream buffer
[/SIZE][SIZE=2]End[/SIZE][SIZE=2]Module
[/SIZE]