drywetmidi: Intermittent "Undefined external error" takes down app when debugging

I’ve just started using the library, and love it… but I’ve got a problem that I don’t yet understand.

I’ve only seen it when using a “Fore” MIDI to USB cable (the actual MIDI device it’s talking to doesn’t seem to matter) but it seems that if it’s going to happen, it happens the first time I try to play a file on any device. If it works once, it keeps working until the process is finished. When it does fail, which has always been while debugging, so far, it takes down the process.

This is the exception:

Melanchall.DryWetMidi.Devices.MidiDeviceException
  HResult=0x80131500
  Message=Undefined external error.
  Source=Melanchall.DryWetMidi
  StackTrace:
   at Melanchall.DryWetMidi.Devices.MidiDevice.ProcessMmResult(UInt32 mmResult)
   at Melanchall.DryWetMidi.Devices.OutputDevice.SendShortEvent(MidiEvent midiEvent)
   at Melanchall.DryWetMidi.Devices.OutputDevice.SendEvent(MidiEvent midiEvent)
   at Melanchall.DryWetMidi.Devices.Playback.OnClockTicked(Object sender, EventArgs e)
   at Melanchall.DryWetMidi.Devices.MidiClock.OnTicked()
   at Melanchall.DryWetMidi.Devices.MidiClock.Tick()
   at Melanchall.DryWetMidi.Devices.MidiClock.OnTickGenerated(Object sender, EventArgs e)
   at Melanchall.DryWetMidi.Devices.TickGenerator.GenerateTick()
   at Melanchall.DryWetMidi.Devices.HighPrecisionTickGenerator.OnTick(UInt32 uID, UInt32 uMsg, UInt32 dwUser, UInt32 dw1, UInt32 dw2)

The code is reasonably simple - it’s in a WPF app:

var devices = OutputDevice.GetAll().ToList();
var outputDevice = devices.First(d => d.Name == "USB Midi ");
MidiFile file = MidiFile.Read(midiFileName);
var playback = file.GetPlayback(outputDevice);
var duration = playback.GetDuration<MetricTimeSpan>();
playback.InterruptNotesOnStop = true;
playback.Start();

The exception looks like it’s in a library-specific thread. Any thoughts around how I can diagnose this any further? Should I be looking for updated drivers?

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 22 (8 by maintainers)

Commits related to this issue

Most upvoted comments

Well, I’ll add discussed API, build prerelease package and let you know.

Thanks for the issue!