melanchall / drywetmidi

.NET library to read, write, process MIDI files and to work with MIDI devices

Home Page:https://melanchall.github.io/drywetmidi

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Simply not working?

minisbett opened this issue · comments

commented
  private static async Task Main()
  {
    using (InputDevice inputDevice = InputDevice.GetByIndex(1))
    {
      inputDevice.ErrorOccurred += OnErrorOccured;
      inputDevice.EventReceived += OnEventReceived;
      inputDevice.StartEventsListening();
    }

    await Task.Delay(-1);
  }

  private static void OnErrorOccured(object? sender, ErrorOccurredEventArgs e)
  {
    Console.WriteLine(e.Exception.Message);
    ;
  }

  private static void OnEventReceived(object? sender, MidiEventReceivedEventArgs e)
  {
    MidiDevice midiDevice = (MidiDevice) sender!;
    Console.WriteLine($"Event received from '{midiDevice.Name}' at {DateTime.Now}: {e.Event}");
  }

This is my test code, tried just receiving events. On InputDevice.GetAll I got two devices, both my keyboard. Tried both of them, nothing received on any.