billthefarmer / mididriver

Android midi driver using Sonivox EAS library
176 stars 52 forks source link

Noise on android lollipop 5.1+ #11

Closed DBS12 closed 9 years ago

DBS12 commented 9 years ago

I have been using this library on previous versions of android and it worked flawlessly. I recently upgraded to lollipop 5.1, and now a heavy wind noise is accompanying the synthesized note. Please take a look at the following video here: https://www.dropbox.com/s/kcu245q8yalt2oh/20150825_094212.mp4?dl=0

I have tried it on an LG G4 (5.1) and on a Galaxy S6 Edge (5.1) and they both resulted in the above output. I also tried it on a LG G3 (5.0) and the noise wasn't heard.

What could be causing this? and what can be done to fix it?

jhindin commented 9 years ago

I will test the application.

billthefarmer commented 9 years ago

That sounds exactly like the effect I got when I built a 64 bit version of the library on Linux. A workaround was to reduce the EAS_PARAM_REVERB_CHAMBER reverb value to EAS_PARAM_REVERB_ROOM. It appears to be due to bugs in the Sonivox library source code that wasn't written for 64 bit compilation. The definitions of EAS_U32 and EAS_I32 in particular:

typedef unsigned long EAS_U32; typedef long EAS_I32;

Those are 64 bit values when compiled for 64 bit. I just checked the latest version of the Sonivox library on here and it's still the same. https://github.com/android/platform_external_sonivox. I tried to fix it and then discovered there is confusion between large integers and pointers in the code.

If it is found to be due to using the 64 bit version of libsonivox.so, check if there is a 32 bit version on the device and if so remove or don't build the 64 bit versions of the libmidi.so library so the device is forced to use the 32 bit version. That may be what Google have done.

See https://github.com/billthefarmer/raspi-sonivox.

billthefarmer commented 9 years ago

Both the LG G4 and the Galaxy S6 Edge have 64 bit ARM processors. I can't test this as a 64 bit ARM emulator is not currently available for the Android SDK. It looks like Google or the manufacturers have included a broken 64 bit version of libsonivox.so in these devices. I assume the built in MediaPlayer interface plays midi files correctly, so there should be a 32 bit version as well. If someone can confirm all this on a real 64 bit device it would be very useful. I have made a change to the sources so that only 32 bit code is built.

billthefarmer commented 9 years ago

Removing the 64 bit versions of libmidi.so from the apk fixes this on the x86-64 emulator. Interestingly, I did that the coarse way, using 7z to delete the files from the apk. I didn't realign or resign it, but it still works fine on the emulator and a device. I will close this.