Android MIDI - juce::MidiOutput::getAvailableDevices - nothing found?

Hi folks!

Calling this on Android, only ever reports zero devices!

auto deviceInfos = juce::MidiOutput::getAvailableDevices();

My Samsung Galaxy device is connected via a USB port to external hardware; I know that the USB connection side is good, as I’ve verified that directly from my Mac.

I guess this is down to some sort of Android configuration magic that I’ve missed?

Thanks in advance for any suggestions!

Pete

Hi Pete,

you need to configure the usb connection for use as MIDI. Do this by swiping from the top to see all your notifications. There should be a small notification with a tiny USB icon and text indicating the current device mode. Tap on that and you should be able to select the device as a MIDI device. Only then will JUCE be able to find the device.

1 Like

@fr810 thank you very much indeed - I’ll give that a go :slight_smile:

Best wishes,

Pete

Hi folks,

Here is what I found.

Step 1 - of course - make sure that you’ve configured your Android device to debug over Wi-Fi.

Step 2 - connecting my Android device to a MIDI adaptor

I tried four different MIDI connecting cables - each one a different make! - and all four failed to connect.

I stumbled upon connecting my Android device to my mac directly via USB-C cable; and that magically worked! I can then use (say) MIDI Loupe on the Mac to verify I’m getting MIDI from Wotja on the Android device.

EDIT: I found that a Roland Um-One Mk2 USB Midi Interface works; but you MUST flip the tiny embedded switch… or it doesn’t work :slight_smile: Not a cheap device, but the other 4 devices have just gone in the bin…

Step 3 - on the software side - I found that I had to call this twice…

auto deviceInfos = juce::MidiOutput::getAvailableDevices();

… and the second call had to be delayed by a second or so. Clearly, that is a bit of a mess, but without the call, the query of devices returns an empty list.

Clearly, there is something in JUCE/Android where when the device connection is activated, the devices aren’t connected up until after some variable delay - which is perfectly understandable.

It’d be nice/cleaner if the JUCE Android system could be configured such that code in the JUCE app/client could be called, to let it know that the (internal to JUCE) MIDI output device list had been updated.

Best wishes to all,

Pete

Yes - I tend to loop on a timer until I am able to connect. This also gives one the luxury (at least on Mac and Android - not sure about Windows) to connect the device after starting the program

1 Like

@peteatjuce would you say the same would go for midi input devices?
I am seeing something similar on android where the midi inputs are not picked up right away and take some variable time like you said.
I have a timer callback in one of my classes that waits till this is done and midi inputs start working.
However I am thinking there is something else also going on related to this timing issue.
When I try to make a synthesiser say using the FourOSC Plugin or similar, the midi keys pressed do no emit any sound at all. I was able to make this “work” when I was debugging the engine code and had a bunch of breakpoints, clearly introducing artificial hardware delays, but still don’t know what prevents this from working.
What I was seeing was the noteOn/noteAdded methods in juce MPESynth don’t get hit when this is broken.
Any advice would be greatly appreciated.

Hi @coderoid

Sounds like we’re all in this together :slight_smile:

Yes, that sounds about right.

Per my suggestion last year, I’d presume that the definitive solution would be for JUCE to provide a callback mechanism, whereby the client code could be called when the MIDI device status changed.

Until such time as that arrives, it remains a bit tricky for JUCE developers targeting Android devices to offer reliable MIDI device support.

Best wishes, Pete