private void InitializeDevice()
        {
            foreach (var item in InputDevice.GetAll())
            {
                item.EventReceived += (sender, ee) =>
                {
                    switch (ee.Event)
                    {
                    case NoteOnEvent @event:
                    {
                        Logger.Trace($"keyboard: {@event.NoteNumber} pressed");
                        KeyController.KeyboardPress(@event.NoteNumber);
                        break;
                    }

                    case NoteOffEvent @event:
                    {
                        Logger.Trace($"keyboard: {@event.NoteNumber} release");
                        KeyController.KeyboardRelease(@event.NoteNumber);
                        break;
                    }
                    }
                };
                MidiDeviceList.Add(item);
            }
        }
Example #2
0
 public static void NoteOn(NoteOnEvent msg)
 {
     lock (NoteOnlock)
     {
         Log.Debug($"msg  {msg.NoteNumber} on at time {DateTime.Now:O}");
         if (Convert.ToInt32(msg.NoteNumber) <= 84 && Convert.ToInt32(msg.NoteNumber) >= 48)
         {
             if (msg.Velocity == 0) //note off
             {
                 kc.KeyboardRelease(Convert.ToInt32(msg.NoteNumber));
             }
             else
             {
                 kc.KeyboardPress(Convert.ToInt32(msg.NoteNumber));
             }
         }
     }
 }
Example #3
0
 public static void NoteOff(NoteOffMessage msg)
 {
     lock (NoteOfflock)
     {
         if (Convert.ToInt32(msg.Pitch) <= 84 && Convert.ToInt32(msg.Pitch) >= 48)
         {
             KeyController.KeyboardRelease(Convert.ToInt32(msg.Pitch));
         }
     }
 }
Example #4
0
 public static void NoteOn(NoteOnMessage msg)
 {
     lock (NoteOnlock)
     {
         if (Convert.ToInt32(msg.Pitch) <= 84 && Convert.ToInt32(msg.Pitch) >= 48)
         {
             if (msg.Velocity == 0)//note off
             {
                 KeyController.KeyboardRelease(Convert.ToInt32(msg.Pitch));
             }
             else
             {
                 KeyController.KeyboardPress(Convert.ToInt32(msg.Pitch));
             }
         }
     }
 }