Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MidiManager class can't find any MIDI device with an input port #979

Closed
spencerparkin opened this issue Jan 13, 2024 · 2 comments
Closed

Comments

@spencerparkin
Copy link

Hi. I can successfully find and open a MIDI device using the MidiManager API, but the only such device I can find is one with a single output port. Now, I can download and install apps on my phone that play synthesized MIDI data. If that's the case, then a MIDI device must exist that has an input port. Am I using the API wrong?

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        val midiManager = this.getSystemService(Context.MIDI_SERVICE) as MidiManager
        val deviceInfoArray = midiManager.getDevices()
        for(deviceInfo in deviceInfoArray) {
            // TODO: This won't work.  We need an input port.
            if(deviceInfo.getOutputPortCount() > 0) {
                midiManager.openDevice(deviceInfo, this.listener, Handler(Looper.getMainLooper()))
                break
            }
        }

Note that my Android phone is a bit old and I must use "minSdk=29" in my gradle file. Is the problem that my phone is too old while the API is too new?

Is your API broken in this case?

Thanks,
--Spencer

@spencerparkin
Copy link
Author

New development (at 1:16 a.m.!)

I opened the MIDI device anyway and was able to open an input port on the device, but your API indicates that it has no input ports and only one output port.

So this really is a problem with your API. I'm not sure if you really care, but I'm convinced you guys have a bug.

Of course, it remains to be seen if I'll actually be able to write on the port, but I believe I will, because a logging app I downloaded shows activity on this MIDI device when I use a different MIDI app. The MIDI logging app also shows that this device has no input port, yet it is being used by the other app to synthesize music.

Am I going crazy? Is this a semantic mixup of the words "input" and "output"?

In any case, I'm going to bed. I hope I don't wake up tomorrow and live another day.

@spencerparkin
Copy link
Author

Sorry for all the fuss. I'm finally understanding all this better. I don't think there is anything wrong with the Android API in this case. I was under the false impression that because some app could play MIDI files that there must be a built-in MIDI synth on my phone, but there probably isn't. To get music to actually play in my app, I just needed to be running another app first that could synthesize the music. My app connected to the exposed MIDI device and sent the MIDI commands, while the other app synthesized the music. Okay, now I get it. I'm an idiot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant