コード例 #1
0
        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);
            }
        }
コード例 #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));
             }
         }
     }
 }
コード例 #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));
         }
     }
 }
コード例 #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));
             }
         }
     }
 }