MidiInput/MidiOutput getAvailableDevices continues to return devices that are turned off

I have been following the MidiDemo example to build a midi app to interface with a 90s synth. The synth plugs into my setup via an older midi interface called Motu midi Timepiece MTP AV. The getAvailableDevices function works great for all my USB midi stuff and I use the same 500ms timer approach as given in MidiDemo. Only for this midi interface, even after I turn power off to the interface, the function continues to return all the ports of the interface. So far, the only way to get the right list of devices after turning off power, is to close the app and open it again. Same issue exists when I use MidiDemo in DemoRunner app as well. Has anyone encountered this issue before?

If not, I will be happy to help debug this to figure out what’s happening, if someone could help me with the right next steps. Thanks!

These seems like an odd behavior, as JUCE just reflects the current list of devices from the OS. One, less than perfect, solution might be to try and open each port before adding it to the list. That is assuming that trying to open one of those ports would fail.

Thank you. Yeah, it does look odd. I am going to attempt stepping into the getAvailableDevices code to see if I get any further. Unfortunately, since that is my only DIN midi interface, I am not able to compare with anything else.

The solution you suggested will definitely work, and as you said it does involve an overhead (I don’t want them all open. So, it will mean I will have to open and close in the logic before populating the list). Documentation indicates that if openDevice returns an empty device, it indicates that the open failed. May fall back to it if I cannot find anything more on this.

oh! is the interface just a standard midi port interface? If so, I think it is highly unlikely that it knows anything is plugged in or not. ie. the midi port is what you see in the list, not any device connected to it.

Yes it is, but the interface itself was turned off.

Basically, the code reads the interface’s ports fine, when it is on, and then I turn the midi interface off (to test how I can react to it in code), but the function continues to return the interface’s ports as available, even though it is turned off.

Having this isse as well. I’ve been able to replicate it on Windows 10.

Glad to see I am not alone. For the time being, I am ‘ignoring’ the problem as I move forward with development. Eventually, I need to come back to this at some point.

Hey guys, one of the great things about JUCE is that you have the source code. You can step into the JUCE code and debug it. Is the device showing up in the OS level API call? if so, JUCE can’t do anything about it. otherwise you can find the bug in JUCE, and a) be able to fix it locally, and b) possibly get it fixed more quickly, as the team won’t have to debug it.

This is a very good point. Thanks for the note! I think I should def check OS level API output on this.

Of course, I am absolutely for helping debug as deep as possible to make it easier to figure out/fix.

1 Like

Yeah thanks, I’ll add the task to the other 5 products I’m currently working on :slight_smile:
I’ll investigate when I get the chance.