

- #WINDOWS 7 MIDI MONITOR HOW TO#
- #WINDOWS 7 MIDI MONITOR DRIVER#
- #WINDOWS 7 MIDI MONITOR CODE#
- #WINDOWS 7 MIDI MONITOR WINDOWS 7#
- #WINDOWS 7 MIDI MONITOR PROFESSIONAL#
#WINDOWS 7 MIDI MONITOR WINDOWS 7#
It runs on Win XP and Windows 7 32 & 64 bit. In the ZIP file, you will also find a ready-to-run EXE file (in \bin\Release).
#WINDOWS 7 MIDI MONITOR PROFESSIONAL#
I'm sure a professional programmer will see improvements, so shoot! Writing this little program was an interesting exercise in dealing with delegates and callback functions in VB. If anyone knows a solution for the midiInClose issue, please feel free to comment! Final Words

#WINDOWS 7 MIDI MONITOR HOW TO#
I have no idea how to solve or workaround this issue.īut Application.Exit() definitely ends the program without complaints or leaving threads/callback functions running in the background. My guess is that midiInClose hangs because MidiInProc is still processing incoming MIDI data. I found an interesting and indepth article here on this issue. The hanging situation only occurs when a lot of MIDI data is generated by the MIDI keyboard while trying to execute midiInClose. The error shown by the debugger is "Argument not specified for parameter ' hMidiIn' of ' Public Shared Function midiInClose(hMidiIn As Integer) As Integer" (?) This line is commented out because sometimes midiInClose(hMidiIn) hangs (meaning: it does not return with or without an error, just hangs).

You might want to check out the MIDI reference on the MSDN website for in-depth information for details on the different functions.īelow, I highlighted the parts that took me a while to figure out:
#WINDOWS 7 MIDI MONITOR CODE#
The source code is rather self-explanatory. Object, e As System.EventArgs) _īutton3.Text = " Show System messages" Elseīutton3.Text = " Hide System messages" End If End Sub Private Sub Form1_FormClosed( ByVal sender As Object, _īyVal e As ) Handles Me.FormClosed Object, e As System.EventArgs) _īutton2.Text = " Start monitor" End If End Sub Private Sub Button3_Click(sender As System. Object, e As System.EventArgs) _Įnd Sub Private Sub Button2_Click(sender As System.

MidiInOpen(hMidiIn, DeviceID, ptrCallback, 0, CALLBACK_FUNCTION Or MIDI_IO_STATUS)īutton2.Text = " Stop monitor" End Sub Private Sub Button1_Click(sender As System. Object, _Į As System.EventArgs) Handles ComboBox1.SelectedIndexChangedĬomboBox1.Enabled = False Dim DeviceID As Integer = ComboBox1.SelectedIndex MidiInGetDevCaps(DevCnt, InCaps, Len(InCaps))Įnd Sub Private Sub ComboBox1_SelectedIndexChanged(sender As System. StatusByte, DataByte1, DataByte2, vbCrLf))Įnd If End Sub Private Sub Form1_Load( ByVal sender As Object, _īyVal e As System.EventArgs) Handles Me.Loadĭim DevCnt As Integer For DevCnt = 0 To (midiInGetNumDevs - 1) TextBox1.AppendText( String.Format( " ", _ If ((HideMidiSysMessages = True) And ((dwParam1 And &HF0) = &HF0)) Then Exit Sub ElseĭataByte2 = (dwParam1 And &HFF0000) > 16 TextBox1.Invoke( New DisplayDataDelegate( AddressOf DisplayData), _Įnd If End Function Private Sub DisplayData(dwParam1)
#WINDOWS 7 MIDI MONITOR DRIVER#
Public Delegate Sub DisplayDataDelegate(dwParam1)ĭim wMid As Int16 ' Manufacturer ID Dim wPid As Int16 ' Product ID Dim vDriverVersion As Integer ' Driver versionĭim szPname As String ' Product Name Dim dwSupport As Integer ' Reserved End Structure Dim hMidiIn As Integer Dim StatusByte As Byte Dim DataByte1 As Byte Dim DataByte2 As Byte Dim MonitorActive As Boolean = False Dim HideMidiSysMessages As Boolean = False Function MidiInProc( ByVal hMidiIn As Integer, _īyVal dwParam1 As Integer, ByVal dwParam2 As Integer) As Integer If MonitorActive = True Then Public Const CALLBACK_FUNCTION As Integer = &H30000 ( ByRef hMidiIn As Integer, ByVal uDeviceID As Integer, _īyVal dwCallback As MidiInCallback, ByVal dwInstance As Integer, _īyVal dwFlags As Integer) As Integer Public Declare Function midiInStart Lib " winmm.dll" ( ByVal hMidiIn As Integer) As Integer Public Declare Function midiInStop Lib " winmm.dll" ( ByVal hMidiIn As Integer) As Integer Public Declare Function midiInReset Lib " winmm.dll" ( ByVal hMidiIn As Integer) As Integer Public Declare Function midiInClose Lib " winmm.dll" ( ByVal hMidiIn As Integer) As Integer Public Delegate Function MidiInCallback( ByVal hMidiIn As Integer, _īyVal wMsg As UInteger, ByVal dwInstance As Integer, _īyVal dwParam1 As Integer, ByVal dwParam2 As Integer) As Integer Public ptrCallback As New MidiInCallback( AddressOf MidiInProc) Public Declare Function midiInGetNumDevs Lib " winmm.dll" () As Integer Public Declare Function midiInGetDevCaps Lib " winmm.dll" _Īlias " midiInGetDevCapsA" ( ByVal uDeviceID As Integer, _īyRef lpCaps As MIDIINCAPS, ByVal uSize As Integer) As Integer Public Declare Function midiInOpen Lib " winmm.dll" _
