midi-relay icon indicating copy to clipboard operation
midi-relay copied to clipboard

Feature request: rescan for MIDI devices

Open mark-epstein opened this issue 3 years ago • 1 comments

My request is that midi-relay would be more aware of the presence of compatible hardware, and self-recover as much as possible if that hardware changes.

In https://github.com/josephdadams/midi-relay/issues/18 I outline some issues I had with midi-relay losing communication with a midi port because the USB host had lost the MIDI device. Restarting midi-relay rectified the issue.

Note: for troubleshooting this I only had a remote desktop connection. I could not physically unplug devices but I could power off the corresponding USB ports. I don't much understand the relationship between the MIDI hardware, the USB port, the USB host, the RPi OS, and midi-relay, but:

  • The /settings page would "advertise" my MIDI hardware even when I have the associated USB port powered off
  • The "Refresh MIDI ports," "Refresh Hosts," and "Get MIDI Ports" functions in the /settings page all seemed blissfully unaware when the hardware was not available
  • The Activity Log would give me messages like noteon-sent-successfully and MIDI Input/Output ports were refreshed and updated successfully. when they were anything but successful.
  • Even with the USB port in the off-state, pm2 logs shows this (UM-1 is my USB-MIDI device):
0|midi-rel | Version: 2.2.0
0|midi-rel | MIDI Relay server started on: 4000
0|midi-rel | Beginning MIDI Setup.
0|midi-rel | MIDI Output Ports
0|midi-rel | Midi Through Port-0
0|midi-rel | UM-1 MIDI 1
0|midi-rel | MIDI Input Ports
0|midi-rel | Midi Through Port-0
0|midi-rel | UM-1 MIDI 1
0|midi-rel | Loading stored Triggers from file...
0|midi-rel | Triggers loaded.

Knowing next to nothing about the inner workings of RPi I suspect that it has simply cached the name of the last device that it saw on the USB port and doesn't tell the software that anything has changed. And for its part, midi-relay can only know that it told the USB port to send to the attached device and didn't get an error in response.

But maybe there is a more comprehensive status somewhere in there that midi-relay could know that the MIDI port was actually offline, and it could react accordingly?

mark-epstein avatar Apr 19 '21 16:04 mark-epstein

We could try a timer/interval, I suppose, to periodically check for MIDI port changes and update the ins/outs list.

josephdadams avatar Aug 11 '21 11:08 josephdadams

I've added an auto rescan in v3.0.6

josephdadams avatar Jun 13 '23 13:06 josephdadams