private void P_EventPlayed(object sender, MidiEventPlayedEventArgs e) { switch (e.Event) { case NoteOnEvent keyon: KeyboardUtilities.NoteOn(keyon); break; case NoteOffEvent keyoff: KeyboardUtilities.NoteOff(keyoff); break; } }
/// <summary> /// 控制游戏按键的函数 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void EventPlayed(object sender, MidiEventPlayedEventArgs e) { switch (e.Event) { case NoteOnEvent @event: { KeyController.PostPress(@event.NoteNumber); //KeyController.KeyboardPress(@event.NoteNumber); break; } case NoteOffEvent @event: { KeyController.PostRelease(@event.NoteNumber); //KeyController.KeyboardRelease(@event.NoteNumber); break; } } }