Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. MIDI and USB Keyboard!

MIDI and USB Keyboard!

Scheduled Pinned Locked Moved Visual Basic
tutorialquestion
46 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Sascha Lefevre

    Alienoiz wrote:

    i am not a coder..i just make these small gadgets to keep my head busy...

    Why don't you start to learn it properly? Open the form designer. Right-click the CombBox for the note-duration and select Properties. In the properties pane click on the events-icon (small and easy to miss). Search for the SelectedIndexChanged-event in the list and make a double-click into the empty column to the right of it. Visual Studio switches to the source code and you will see a stub for the event-handler-function where you will only have to insert that one line from my previous message. Remove that line I underlined in the other function in my previous message. That should be it.

    If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson

    L Offline
    L Offline
    Lost User
    wrote on last edited by
    #22

    may i ask for your attention once again? my code has changed....i am now able to do everything i want from it...but i am just having a small problem... When i press the midi key of my controller it plays the note and when i unpress it it also plays the same note! I have tried the .StopMIDINote() function but i do not know where to insert it?!!! If i was using a button i would know..mousedown play..mouseup stop..but i am using my MIDI hardware keyboard! Below i show the code....if you have some advice i would appreciate it?!!?!? Thanks You!

    Public Class Form1
    Dim m As New clsMIDI
    Dim hMidiIn As Integer

    Private Sub Form1\_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        FillInstrumentCombo()
    
        If midiInGetNumDevs() = 0 Then
            MsgBox("No MIDI devices connected")
        End If
    
        Dim InCaps As New MIDIINCAPS
        Dim DevCnt As Integer
    
        For DevCnt = 0 To (midiInGetNumDevs - 1)
            midiInGetDevCaps(DevCnt, InCaps, Len(InCaps))
            ComboBox1.Items.Add(InCaps.szPname)
        Next DevCnt
    
    
    End Sub
    
    Private Sub Form1\_Closed(sender As Object, e As EventArgs) Handles Me.Closed
        midiInStop(hMidiIn)
        midiInReset(hMidiIn)
        midiInClose(hMidiIn)
    End Sub
    Public Declare Function midiInOpen Lib "winmm.dll" (ByRef hMidiIn As Integer, ByVal uDeviceID As Integer, ByVal dwCallback As MidiInCallback, ByVal dwInstance As Integer, ByVal dwFlags As Integer) As Integer
    Public Delegate Function MidiInCallback(ByVal hMidiIn As Integer, ByVal wMsg As UInteger, ByVal dwInstance As Integer, ByVal dwParam1 As Integer, ByVal dwParam2 As Integer) As Integer
    Public ptrCallback As New MidiInCallback(AddressOf MidiInProc)
    Public Const CALLBACK\_FUNCTION As Integer = &H30000
    Public Const MIDI\_IO\_STATUS = &H20
    
    Public Delegate Sub DisplayDataDelegate(dwParam1)
    
    Private Sub ComboBox1\_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
        Dim DeviceID As Integer = ComboBox1.SelectedIndex
        midiInOpen(hMidiIn, DeviceID, ptrCallback, 0, CALLBACK\_FUNCTION Or MIDI\_IO\_STATUS)
        midiInStart(hMidiIn)
        Dim duration = CInt(cboduration.Text)
        m.NoteDuration = duration
    End Sub
    
    Dim DataByte1 As Byte
    
    Function MidiInProc(ByVal hMidiIn As Integer, ByVal wMsg As UInteger, ByVal dwInstance As Integer, ByVal dwParam1 As Integer, ByVal dwParam2 As Integer) As Integer
    
    1 Reply Last reply
    0
    • S Sascha Lefevre

      Alienoiz wrote:

      i am not a coder..i just make these small gadgets to keep my head busy...

      Why don't you start to learn it properly? Open the form designer. Right-click the CombBox for the note-duration and select Properties. In the properties pane click on the events-icon (small and easy to miss). Search for the SelectedIndexChanged-event in the list and make a double-click into the empty column to the right of it. Visual Studio switches to the source code and you will see a stub for the event-handler-function where you will only have to insert that one line from my previous message. Remove that line I underlined in the other function in my previous message. That should be it.

      If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #23

      may you help me or not?..i just wanna know so i can quit the gadget or not!! Thank you!

      S 1 Reply Last reply
      0
      • L Lost User

        may you help me or not?..i just wanna know so i can quit the gadget or not!! Thank you!

        S Offline
        S Offline
        Sascha Lefevre
        wrote on last edited by
        #24

        On the page you linked in another post (Visual Basic MIDI Piano[^]) there are these two subs which I assume are still somewhere in your code:

        Private Sub Down(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseDown, Button2.MouseDown, Button3.MouseDown, Button4.MouseDown, Button5.MouseDown, Button6.MouseDown, Button7.MouseDown, Button8.MouseDown, Button9.MouseDown, Button10.MouseDown, Button11.MouseDown, Button12.MouseDown, Button13.MouseDown, Button14.MouseDown, Button15.MouseDown, Button16.MouseDown, Button17.MouseDown, Button18.MouseDown, Button19.MouseDown, Button20.MouseDown, Button21.MouseDown, Button22.MouseDown, Button23.MouseDown, Button24.MouseDown
            Jazz.MidiOut(&H90 + chan, Note(sender), 100)
        End Sub
        
        Private Sub Up(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseUp, Button2.MouseUp, Button3.MouseUp, Button4.MouseUp, Button5.MouseUp, Button6.MouseUp, Button7.MouseUp, Button8.MouseUp, Button9.MouseUp, Button10.MouseUp, Button11.MouseUp, Button12.MouseUp, Button13.MouseUp, Button14.MouseUp, Button15.MouseUp, Button16.MouseUp, Button17.MouseUp, Button18.MouseUp, Button19.MouseUp, Button20.MouseUp, Button21.MouseUp, Button22.MouseUp, Button23.MouseUp, Button24.MouseUp
            Jazz.MidiOut(&H80 + chan, Note(sender), 0)
        End Sub
        

        Looks like it's supposed to start playing a note on KeyDown and stop playing it on KeyUp, without a predetermined duration, which you seem to have added. So I'm guessing all you need to do is to either remove the "Up"-sub and the event-wiring for it or comment out the single line it it. If it doesn't work then I have no idea.

        If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson

        L 3 Replies Last reply
        0
        • S Sascha Lefevre

          On the page you linked in another post (Visual Basic MIDI Piano[^]) there are these two subs which I assume are still somewhere in your code:

          Private Sub Down(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseDown, Button2.MouseDown, Button3.MouseDown, Button4.MouseDown, Button5.MouseDown, Button6.MouseDown, Button7.MouseDown, Button8.MouseDown, Button9.MouseDown, Button10.MouseDown, Button11.MouseDown, Button12.MouseDown, Button13.MouseDown, Button14.MouseDown, Button15.MouseDown, Button16.MouseDown, Button17.MouseDown, Button18.MouseDown, Button19.MouseDown, Button20.MouseDown, Button21.MouseDown, Button22.MouseDown, Button23.MouseDown, Button24.MouseDown
              Jazz.MidiOut(&H90 + chan, Note(sender), 100)
          End Sub
          
          Private Sub Up(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseUp, Button2.MouseUp, Button3.MouseUp, Button4.MouseUp, Button5.MouseUp, Button6.MouseUp, Button7.MouseUp, Button8.MouseUp, Button9.MouseUp, Button10.MouseUp, Button11.MouseUp, Button12.MouseUp, Button13.MouseUp, Button14.MouseUp, Button15.MouseUp, Button16.MouseUp, Button17.MouseUp, Button18.MouseUp, Button19.MouseUp, Button20.MouseUp, Button21.MouseUp, Button22.MouseUp, Button23.MouseUp, Button24.MouseUp
              Jazz.MidiOut(&H80 + chan, Note(sender), 0)
          End Sub
          

          Looks like it's supposed to start playing a note on KeyDown and stop playing it on KeyUp, without a predetermined duration, which you seem to have added. So I'm guessing all you need to do is to either remove the "Up"-sub and the event-wiring for it or comment out the single line it it. If it doesn't work then I have no idea.

          If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #25

          hi..i am not using the jazzmidi control anymore! Now i am using a module called clsMIDI! You can check it in the concorrence : ) (sorry) https://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=8305&lngWId=10 Thanks!

          1 Reply Last reply
          0
          • S Sascha Lefevre

            On the page you linked in another post (Visual Basic MIDI Piano[^]) there are these two subs which I assume are still somewhere in your code:

            Private Sub Down(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseDown, Button2.MouseDown, Button3.MouseDown, Button4.MouseDown, Button5.MouseDown, Button6.MouseDown, Button7.MouseDown, Button8.MouseDown, Button9.MouseDown, Button10.MouseDown, Button11.MouseDown, Button12.MouseDown, Button13.MouseDown, Button14.MouseDown, Button15.MouseDown, Button16.MouseDown, Button17.MouseDown, Button18.MouseDown, Button19.MouseDown, Button20.MouseDown, Button21.MouseDown, Button22.MouseDown, Button23.MouseDown, Button24.MouseDown
                Jazz.MidiOut(&H90 + chan, Note(sender), 100)
            End Sub
            
            Private Sub Up(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseUp, Button2.MouseUp, Button3.MouseUp, Button4.MouseUp, Button5.MouseUp, Button6.MouseUp, Button7.MouseUp, Button8.MouseUp, Button9.MouseUp, Button10.MouseUp, Button11.MouseUp, Button12.MouseUp, Button13.MouseUp, Button14.MouseUp, Button15.MouseUp, Button16.MouseUp, Button17.MouseUp, Button18.MouseUp, Button19.MouseUp, Button20.MouseUp, Button21.MouseUp, Button22.MouseUp, Button23.MouseUp, Button24.MouseUp
                Jazz.MidiOut(&H80 + chan, Note(sender), 0)
            End Sub
            

            Looks like it's supposed to start playing a note on KeyDown and stop playing it on KeyUp, without a predetermined duration, which you seem to have added. So I'm guessing all you need to do is to either remove the "Up"-sub and the event-wiring for it or comment out the single line it it. If it doesn't work then I have no idea.

            If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #26

            I think the solution is somewhere in these lines of code:

            Dim DataByte1 = (dwParam1 And &HFF00) >> 8
            m.PlayMIDINote(DataByte1, 127)

            If i leave like that, when i press the key of my MIDI Controller the note plays and when i unpress it it plays again! But if i set it like this:

            Dim DataByte1 = (dwParam1) >> 8
            m.PlayMIDINote(DataByte1, 127)

            It only plays when i unpress the key.... Well.... it is the opposite of what i need...i need it to play when i press and silent when i unpress!!

            1 Reply Last reply
            0
            • S Sascha Lefevre

              On the page you linked in another post (Visual Basic MIDI Piano[^]) there are these two subs which I assume are still somewhere in your code:

              Private Sub Down(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseDown, Button2.MouseDown, Button3.MouseDown, Button4.MouseDown, Button5.MouseDown, Button6.MouseDown, Button7.MouseDown, Button8.MouseDown, Button9.MouseDown, Button10.MouseDown, Button11.MouseDown, Button12.MouseDown, Button13.MouseDown, Button14.MouseDown, Button15.MouseDown, Button16.MouseDown, Button17.MouseDown, Button18.MouseDown, Button19.MouseDown, Button20.MouseDown, Button21.MouseDown, Button22.MouseDown, Button23.MouseDown, Button24.MouseDown
                  Jazz.MidiOut(&H90 + chan, Note(sender), 100)
              End Sub
              
              Private Sub Up(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseUp, Button2.MouseUp, Button3.MouseUp, Button4.MouseUp, Button5.MouseUp, Button6.MouseUp, Button7.MouseUp, Button8.MouseUp, Button9.MouseUp, Button10.MouseUp, Button11.MouseUp, Button12.MouseUp, Button13.MouseUp, Button14.MouseUp, Button15.MouseUp, Button16.MouseUp, Button17.MouseUp, Button18.MouseUp, Button19.MouseUp, Button20.MouseUp, Button21.MouseUp, Button22.MouseUp, Button23.MouseUp, Button24.MouseUp
                  Jazz.MidiOut(&H80 + chan, Note(sender), 0)
              End Sub
              

              Looks like it's supposed to start playing a note on KeyDown and stop playing it on KeyUp, without a predetermined duration, which you seem to have added. So I'm guessing all you need to do is to either remove the "Up"-sub and the event-wiring for it or comment out the single line it it. If it doesn't work then I have no idea.

              If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #27

              Well...do you have any tip? Thanks you!

              S 1 Reply Last reply
              0
              • L Lost User

                Well...do you have any tip? Thanks you!

                S Offline
                S Offline
                Sascha Lefevre
                wrote on last edited by
                #28

                In the code you linked a note gets played by a mouse left click. You say you play notes by pressing keys but I don't see any of that in your code. Can you show the code that handles key presses?

                If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson

                L 1 Reply Last reply
                0
                • S Sascha Lefevre

                  In the code you linked a note gets played by a mouse left click. You say you play notes by pressing keys but I don't see any of that in your code. Can you show the code that handles key presses?

                  If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #29

                  The keys i say are the keys from my piano MIDI keyboard (hardware piano keyboard)!... Not from PC´s keyboard!!! This is all the code i have now....plus the clsMIDI module:

                  Imports System.Runtime.InteropServices

                  Public Class Form1
                  Dim m As New clsMIDI
                  Dim hMidiIn As Integer

                  Private Sub Form1\_Load(sender As Object, e As EventArgs) Handles MyBase.Load
                      FillInstrumentCombo()
                  
                      If midiInGetNumDevs() = 0 Then
                          MsgBox("No MIDI devices connected!")
                      End If
                  
                      Dim InCaps As New MIDIINCAPS
                      Dim DevCnt As Integer
                  
                      For DevCnt = 0 To (midiInGetNumDevs - 1)
                          midiInGetDevCaps(DevCnt, InCaps, Len(InCaps))
                          ComboBox1.Items.Add(InCaps.szPname)
                      Next DevCnt
                  
                  
                  End Sub
                  
                  Declare Function midiInOpen Lib "winmm.dll" (ByRef lphMidiIn As Integer,
                      ByVal uDeviceID As Integer,  ByVal dwCallback As MidiDelegate,
                      ByVal dwInstance As Integer, ByVal dwFlags As Integer) As Integer
                  Public Delegate Sub MidiDelegate(ByVal MidiInHandle As Int32, ByVal wMsg As Int32, ByVal Instance As Int32, ByVal wParam As Int32, ByVal lParam As Int32)
                  Public ptrCallback As New MidiDelegate(AddressOf MidiInProc)
                  
                  Public Delegate Sub DisplayDataDelegate(wParam)
                  
                  Private Sub ComboBox1\_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
                      midiInStop(hMidiIn)
                      midiInReset(hMidiIn)
                      midiInClose(hMidiIn)
                      Dim DeviceID As Integer = ComboBox1.SelectedIndex
                      midiInOpen(hMidiIn, DeviceID, ptrCallback, 0, CALLBACK\_FUNCTION Or MIDI\_IO\_STATUS)
                      midiInStart(hMidiIn)
                      Dim duration = CInt(cboduration.Text)
                      m.NoteDuration = duration
                  End Sub
                  
                  
                  
                  Function MidiInProc(ByVal MidiInHandle As Int32, ByVal wMsg As Int32, ByVal Instance As Int32, ByVal wParam As Int32, ByVal lParam As Int32) As Integer
                      TextBox1.Invoke(New DisplayDataDelegate(AddressOf DisplayData), New Object() {wParam})
                      Dim DataByte3 = (wParam And &HFF00) >> 8
                      m.PlayMIDINote(DataByte3, 127)
                  End Function
                  
                  Private Sub DisplayData(wParam)
                      Dim StatusByte As Byte
                      Dim DataByte1 As Byte
                      Dim DataByte2 As Byte
                      StatusByte = (wParam And &HFF)
                      DataByte1 = (wParam And &HFF00) >> 8
                      DataByte2 = (wParam And &HFF0000) >> 16
                      TextBox1.AppendText(String.Format("{0:X2} {1:X2} {2:X2}{3}", StatusByte, DataByte1, D
                  
                  S 2 Replies Last reply
                  0
                  • L Lost User

                    The keys i say are the keys from my piano MIDI keyboard (hardware piano keyboard)!... Not from PC´s keyboard!!! This is all the code i have now....plus the clsMIDI module:

                    Imports System.Runtime.InteropServices

                    Public Class Form1
                    Dim m As New clsMIDI
                    Dim hMidiIn As Integer

                    Private Sub Form1\_Load(sender As Object, e As EventArgs) Handles MyBase.Load
                        FillInstrumentCombo()
                    
                        If midiInGetNumDevs() = 0 Then
                            MsgBox("No MIDI devices connected!")
                        End If
                    
                        Dim InCaps As New MIDIINCAPS
                        Dim DevCnt As Integer
                    
                        For DevCnt = 0 To (midiInGetNumDevs - 1)
                            midiInGetDevCaps(DevCnt, InCaps, Len(InCaps))
                            ComboBox1.Items.Add(InCaps.szPname)
                        Next DevCnt
                    
                    
                    End Sub
                    
                    Declare Function midiInOpen Lib "winmm.dll" (ByRef lphMidiIn As Integer,
                        ByVal uDeviceID As Integer,  ByVal dwCallback As MidiDelegate,
                        ByVal dwInstance As Integer, ByVal dwFlags As Integer) As Integer
                    Public Delegate Sub MidiDelegate(ByVal MidiInHandle As Int32, ByVal wMsg As Int32, ByVal Instance As Int32, ByVal wParam As Int32, ByVal lParam As Int32)
                    Public ptrCallback As New MidiDelegate(AddressOf MidiInProc)
                    
                    Public Delegate Sub DisplayDataDelegate(wParam)
                    
                    Private Sub ComboBox1\_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
                        midiInStop(hMidiIn)
                        midiInReset(hMidiIn)
                        midiInClose(hMidiIn)
                        Dim DeviceID As Integer = ComboBox1.SelectedIndex
                        midiInOpen(hMidiIn, DeviceID, ptrCallback, 0, CALLBACK\_FUNCTION Or MIDI\_IO\_STATUS)
                        midiInStart(hMidiIn)
                        Dim duration = CInt(cboduration.Text)
                        m.NoteDuration = duration
                    End Sub
                    
                    
                    
                    Function MidiInProc(ByVal MidiInHandle As Int32, ByVal wMsg As Int32, ByVal Instance As Int32, ByVal wParam As Int32, ByVal lParam As Int32) As Integer
                        TextBox1.Invoke(New DisplayDataDelegate(AddressOf DisplayData), New Object() {wParam})
                        Dim DataByte3 = (wParam And &HFF00) >> 8
                        m.PlayMIDINote(DataByte3, 127)
                    End Function
                    
                    Private Sub DisplayData(wParam)
                        Dim StatusByte As Byte
                        Dim DataByte1 As Byte
                        Dim DataByte2 As Byte
                        StatusByte = (wParam And &HFF)
                        DataByte1 = (wParam And &HFF00) >> 8
                        DataByte2 = (wParam And &HFF0000) >> 16
                        TextBox1.AppendText(String.Format("{0:X2} {1:X2} {2:X2}{3}", StatusByte, DataByte1, D
                    
                    S Offline
                    S Offline
                    Sascha Lefevre
                    wrote on last edited by
                    #30

                    Alienoiz wrote:

                    The keys i say are the keys from my piano MIDI keyboard (hardware piano keyboard)!... Not from PC´s keyboard!!!

                    Alright :laugh: Please post the contents of your TextBox1 after pressing and releasing a single key.

                    If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson

                    1 Reply Last reply
                    0
                    • L Lost User

                      The keys i say are the keys from my piano MIDI keyboard (hardware piano keyboard)!... Not from PC´s keyboard!!! This is all the code i have now....plus the clsMIDI module:

                      Imports System.Runtime.InteropServices

                      Public Class Form1
                      Dim m As New clsMIDI
                      Dim hMidiIn As Integer

                      Private Sub Form1\_Load(sender As Object, e As EventArgs) Handles MyBase.Load
                          FillInstrumentCombo()
                      
                          If midiInGetNumDevs() = 0 Then
                              MsgBox("No MIDI devices connected!")
                          End If
                      
                          Dim InCaps As New MIDIINCAPS
                          Dim DevCnt As Integer
                      
                          For DevCnt = 0 To (midiInGetNumDevs - 1)
                              midiInGetDevCaps(DevCnt, InCaps, Len(InCaps))
                              ComboBox1.Items.Add(InCaps.szPname)
                          Next DevCnt
                      
                      
                      End Sub
                      
                      Declare Function midiInOpen Lib "winmm.dll" (ByRef lphMidiIn As Integer,
                          ByVal uDeviceID As Integer,  ByVal dwCallback As MidiDelegate,
                          ByVal dwInstance As Integer, ByVal dwFlags As Integer) As Integer
                      Public Delegate Sub MidiDelegate(ByVal MidiInHandle As Int32, ByVal wMsg As Int32, ByVal Instance As Int32, ByVal wParam As Int32, ByVal lParam As Int32)
                      Public ptrCallback As New MidiDelegate(AddressOf MidiInProc)
                      
                      Public Delegate Sub DisplayDataDelegate(wParam)
                      
                      Private Sub ComboBox1\_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
                          midiInStop(hMidiIn)
                          midiInReset(hMidiIn)
                          midiInClose(hMidiIn)
                          Dim DeviceID As Integer = ComboBox1.SelectedIndex
                          midiInOpen(hMidiIn, DeviceID, ptrCallback, 0, CALLBACK\_FUNCTION Or MIDI\_IO\_STATUS)
                          midiInStart(hMidiIn)
                          Dim duration = CInt(cboduration.Text)
                          m.NoteDuration = duration
                      End Sub
                      
                      
                      
                      Function MidiInProc(ByVal MidiInHandle As Int32, ByVal wMsg As Int32, ByVal Instance As Int32, ByVal wParam As Int32, ByVal lParam As Int32) As Integer
                          TextBox1.Invoke(New DisplayDataDelegate(AddressOf DisplayData), New Object() {wParam})
                          Dim DataByte3 = (wParam And &HFF00) >> 8
                          m.PlayMIDINote(DataByte3, 127)
                      End Function
                      
                      Private Sub DisplayData(wParam)
                          Dim StatusByte As Byte
                          Dim DataByte1 As Byte
                          Dim DataByte2 As Byte
                          StatusByte = (wParam And &HFF)
                          DataByte1 = (wParam And &HFF00) >> 8
                          DataByte2 = (wParam And &HFF0000) >> 16
                          TextBox1.AppendText(String.Format("{0:X2} {1:X2} {2:X2}{3}", StatusByte, DataByte1, D
                      
                      S Offline
                      S Offline
                      Sascha Lefevre
                      wrote on last edited by
                      #31

                      No - not for a single key but for two different keys please, in sequence.

                      If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson

                      L 1 Reply Last reply
                      0
                      • S Sascha Lefevre

                        No - not for a single key but for two different keys please, in sequence.

                        If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson

                        L Offline
                        L Offline
                        Lost User
                        wrote on last edited by
                        #32

                        i am not understanding : (((( can you set an example?... i guess the textbox1 is not affecting the MIDI playing!!! What is making the play its the "m.playMIDINote" function!!! The textbox1 is just for showing the data that is being sent from the MIDI Keyboard into the PC!

                        S 1 Reply Last reply
                        0
                        • L Lost User

                          i am not understanding : (((( can you set an example?... i guess the textbox1 is not affecting the MIDI playing!!! What is making the play its the "m.playMIDINote" function!!! The textbox1 is just for showing the data that is being sent from the MIDI Keyboard into the PC!

                          S Offline
                          S Offline
                          Sascha Lefevre
                          wrote on last edited by
                          #33

                          Alienoiz wrote:

                          The textbox1 is just for showing the data that is being sent from the MIDI Keyboard into the PC!

                          Yes and I want to see that

                          If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson

                          L 1 Reply Last reply
                          0
                          • S Sascha Lefevre

                            Alienoiz wrote:

                            The textbox1 is just for showing the data that is being sent from the MIDI Keyboard into the PC!

                            Yes and I want to see that

                            If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson

                            L Offline
                            L Offline
                            Lost User
                            wrote on last edited by
                            #34

                            ouch..i am sorry..i understood something else.. here...00 00 00 appears when i select the MIDI keyboard from combobox1..next is the data from 3 followed keys: 00 00 00 90 30 36 80 30 00 90 31 38 80 31 00 90 32 22 80 32 00

                            S 1 Reply Last reply
                            0
                            • L Lost User

                              ouch..i am sorry..i understood something else.. here...00 00 00 appears when i select the MIDI keyboard from combobox1..next is the data from 3 followed keys: 00 00 00 90 30 36 80 30 00 90 31 38 80 31 00 90 32 22 80 32 00

                              S Offline
                              S Offline
                              Sascha Lefevre
                              wrote on last edited by
                              #35

                              OK - try this:

                              Function MidiInProc(ByVal MidiInHandle As Int32, ByVal wMsg As Int32, ByVal Instance As Int32, ByVal wParam As Int32, ByVal lParam As Int32) As Integer
                                  Dim Status As Byte
                                  Dim Note As Byte
                                  Dim Velocity As Byte
                                  TextBox1.Invoke(New DisplayDataDelegate(AddressOf DisplayData), New Object() {wParam})
                                  Status = (wParam And &HFF)
                                  If Status = 90 Then
                                      Note = (wParam And &HFF00) >> 8
                                      Velocity = (wParam And &HFF0000) >> 16
                                      m.PlayMIDINote(Note, Velocity)
                                  End If
                              End Function
                              

                              If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson

                              L 1 Reply Last reply
                              0
                              • S Sascha Lefevre

                                OK - try this:

                                Function MidiInProc(ByVal MidiInHandle As Int32, ByVal wMsg As Int32, ByVal Instance As Int32, ByVal wParam As Int32, ByVal lParam As Int32) As Integer
                                    Dim Status As Byte
                                    Dim Note As Byte
                                    Dim Velocity As Byte
                                    TextBox1.Invoke(New DisplayDataDelegate(AddressOf DisplayData), New Object() {wParam})
                                    Status = (wParam And &HFF)
                                    If Status = 90 Then
                                        Note = (wParam And &HFF00) >> 8
                                        Velocity = (wParam And &HFF0000) >> 16
                                        m.PlayMIDINote(Note, Velocity)
                                    End If
                                End Function
                                

                                If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson

                                L Offline
                                L Offline
                                Lost User
                                wrote on last edited by
                                #36

                                i understand the code..yes..but it is not working! : (

                                S 1 Reply Last reply
                                0
                                • L Lost User

                                  i understand the code..yes..but it is not working! : (

                                  S Offline
                                  S Offline
                                  Sascha Lefevre
                                  wrote on last edited by
                                  #37

                                  You need to go into more detail with problem descriptions. "Not working" is not helping me understand. Does it not do anything any more or still the same problem as before or what?

                                  If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson

                                  L 2 Replies Last reply
                                  0
                                  • S Sascha Lefevre

                                    You need to go into more detail with problem descriptions. "Not working" is not helping me understand. Does it not do anything any more or still the same problem as before or what?

                                    If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson

                                    L Offline
                                    L Offline
                                    Lost User
                                    wrote on last edited by
                                    #38

                                    sorry..everything works except the sound ... no sound!!

                                    1 Reply Last reply
                                    0
                                    • S Sascha Lefevre

                                      You need to go into more detail with problem descriptions. "Not working" is not helping me understand. Does it not do anything any more or still the same problem as before or what?

                                      If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson

                                      L Offline
                                      L Offline
                                      Lost User
                                      wrote on last edited by
                                      #39

                                      if i set it like this:

                                      If Status <> 90 Then

                                      it seems to work...the 90/80 might not be the "correct" value!

                                      S 1 Reply Last reply
                                      0
                                      • L Lost User

                                        if i set it like this:

                                        If Status <> 90 Then

                                        it seems to work...the 90/80 might not be the "correct" value!

                                        S Offline
                                        S Offline
                                        Sascha Lefevre
                                        wrote on last edited by
                                        #40

                                        I missed that you formatted the output as hexadecimal. Change that line to:

                                        If Status = 144 Then

                                        If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson

                                        L 3 Replies Last reply
                                        0
                                        • S Sascha Lefevre

                                          I missed that you formatted the output as hexadecimal. Change that line to:

                                          If Status = 144 Then

                                          If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson

                                          L Offline
                                          L Offline
                                          Lost User
                                          wrote on last edited by
                                          #41

                                          OOOOOOOOKKKKKKK..seems good..A LOT OF THANKS!

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups