Ejemplo n.º 1
0
        private void _inputDevice_Input(object sender, MidiInputEventArgs args)
        {
            if (IsHandleCreated)
            {
                BeginInvoke(new Action(() =>
                {
                    if (null != _outputDevice && _outputDevice.IsOpen)
                    {
                        _outputDevice.Send(args.Message);
                    }
                    // when we hit a note on, or note off below
                    // we set or release the corresponding piano
                    // key. We must suppress raising events or
                    // this would cause a circular codepath
                    switch (args.Message.Status & 0xF0)
                    {
                    case 0x80:                             // key up
                        var msw = args.Message as MidiMessageWord;
                        Piano.SetKey(msw.Data1, false, true);
                        break;

                    case 0x90:                             // key down
                        msw = args.Message as MidiMessageWord;
                        Piano.SetKey(msw.Data1, true, true);
                        break;
                    }
                }));
            }
        }
Ejemplo n.º 2
0
 private void device_Input(object sender, MidiInputEventArgs args)
 {
     try
     {
         Invoke(new Action(delegate()
         {
             MessagesTextBox.AppendText(
                 args.Message.ToString() +
                 Environment.NewLine);
         }));
     }
     catch
     {
     }
 }