MIDI device onDisconnect?

Is there a way to register a callback for MIDI device disconnection events in the API?

My module (VCV Library - PitchGrid Microtonal Exquis Interface) is built for one specific MIDI controller to which it directly and automatically connects by looping over drivers and devices, identifying the right one by name. Every 2.5 seconds I am doing that loop to see if the device is still available, to detect a disconnect. However, I noticed that the loop is prohibitively expensive, in particular when using VCV Rack as a VST plugin. I could avoid the loop if I could listen to an onDisconnect event, but I could not find any info in the docs how I could achieve this. Can someone help out?

Rack (and the underlying support libraries rtmidi/rtaudio) do not expose any such event for device changes (adds are as important as removals). This results in poor behavior when devices are plugged and unplugged.

This problem has certainly created a lot of headaches for my MIDI-centered plugin.

All of the Rack OS platforms have a way to watch and be notified of device changes, so this is certainly technically possible, but Rack has not implemented such a thing. It generally relies on 3rd party cross-platform library support for graphics, input, and devices.

Worth opening a support ticket for.

1 Like

Not the answer I hoped for but very helpful. Thank you! Will contact support.