android / ndk-samples

Android NDK samples with Android Studio
http://developer.android.com/ndk
Apache License 2.0
9.97k stars 4.15k forks source link

Native-MIDI seems to be missing some MIDI commands sent #941

Open batata004 opened 1 year ago

batata004 commented 1 year ago

Hi,

I am using Native-MIDI to read MIDI commands. It seems to work fine, when I connect my smartphone to a midi controller, I can see that the smartphone is receiving all the keys I press in my midi controller.

However, when I send keys too fast, the android app (using the sample code provided in the github) is missing many commands. The strange thing is that when I tested most apps of the PlayStore that allows receiving MIDI, all of them work flawlesly, they dont miss any MIDI command.

Maybe they are using other library? I dont know, that's why I ask you: is there any other library the allows me to received MIDI events in a very low latency mode and that misses the least number of commands when they are sent too fast? Or this NDK library is the best one? If so, why is the example code provided in the ndk/native-midi missing MIDI commands?

as-4096 commented 8 months ago

I found that in the code for reading MIDI signals, there was no handling of the length of the received data. When very fast note signals are received, there is a phenomenon of sticking together, where multiple notes are included in one output. However, the current code only takes the first note. It should loop through and process all the note messages received. I have already fixed this issue locally and applied it to my app.

DanAlbert commented 2 months ago

If someone could upload a PR, I'd be grateful. I don't have a midi controller so there isn't a whole lot I can do here.