Author Topic: BASS for Android  (Read 422636 times)

gicci

  • Posts: 48
Re: BASS for Android
« Reply #1350 on: 6 Feb '18 - 19:36 »
Hi Ian,

with this release I am no longer getting crashes on SoundFont close.

Thank you.

astrohoff

  • Posts: 4
Re: BASS for Android
« Reply #1351 on: 7 Feb '18 - 00:49 »
Test file is uploaded. I get the same behavior with the 2.4.13.8 version. To check if the problem was with the communication between C# and Java, I did the same series of events as the MIDI file, but entirely in a Java-side function, and that has the same behavior. The only other explanations I can think of is that either Unity is somehow mucking up the plugin, or I'm doing something so dumb that you haven't thought to check it...
I'll make a test app to test the Java code independent of Unity.

Ian @ un4seen

  • Administrator
  • Posts: 21017
Re: BASS for Android
« Reply #1352 on: 7 Feb '18 - 17:22 »
That's very strange. I can't reproduce the problem with the uploaded MIDI file either; the 6 notes are played fine. I'm testing with the MIDITEST example that's included in the package in the 1st post. Can you try that there? Here's a prebuilt version that you can quickly try:

   www.un4seen.com/stuff/miditest.apk

astrohoff

  • Posts: 4
Re: BASS for Android
« Reply #1353 on: 8 Feb '18 - 01:05 »
I am unable to set the soundfont in the app; it doesn't show anything in the sdcard folder where I have the soundfont. It also seems to be having problems showing the contents of subfolders, as any folder opened by going down a level appears as empty. Going up a level does show the proper folders though. See attached screenshot.

Edit: Actually I might just be confused. But regardless I haven't been able to locate my soundfont or midi files with the app.
« Last Edit: 8 Feb '18 - 14:58 by astrohoff »

Ian @ un4seen

  • Administrator
  • Posts: 21017
Re: BASS for Android
« Reply #1354 on: 8 Feb '18 - 15:30 »
The MIDITEST example defaults to the path given by Environment.getExternalStorageDirectory, but it's possible that your files are elsewhere. In that case, you can go to the root directory (using the ".." option) and then navigate to the correct location.

Ian @ un4seen

  • Administrator
  • Posts: 21017
Re: BASS for Android
« Reply #1355 on: 28 Feb '18 - 17:17 »
An updated version (2.4.9.2) of the BASSmix add-on to fix a resampling bug is up now in the 1st post.

bracken

  • Posts: 12
Re: BASS for Android
« Reply #1356 on: 8 Mar '18 - 18:33 »
I'm trying to encode audio into aac format using MediaCodec.  The trouble I'm having seems to be that the MediaCodec expects PCM data as S16LE and what I'm getting decoded from BASS is 32 bit Float LE.  How can I get the data to the S16LE format?  Is there a parameter I can set to get it it in this format, or is there a transform I can apply to the bytes in the BASSenc.ENCODERPROC callback before sending them on to the encoder?

bracken

  • Posts: 12
Re: BASS for Android
« Reply #1357 on: 8 Mar '18 - 20:14 »
Well, I found a way to do the float to short byte array conversion which works for my needs.  But still would be nice if there is some way to request that the bytes are 16bit short instead of 32bit float in the first place to save on the conversion process.

Ian @ un4seen

  • Administrator
  • Posts: 21017
Re: BASS for Android
« Reply #1358 on: 9 Mar '18 - 14:42 »
You can use the BASS_ENCODE_FP_16BIT flag in the BASS_Encode_StartUser call to have BASSenc convert floating-point sample data to 16-bit before passing it to your ENCODERPROC function.

bracken

  • Posts: 12
Re: BASS for Android
« Reply #1359 on: 9 Mar '18 - 15:27 »
Great, thank you!

norbert

  • Posts: 132
Re: BASS for Android
« Reply #1360 on: 25 Mar '18 - 13:15 »
BASSMIDI.BASS_MIDI_FontGetPresets returns one preset "0" from a sfz soundfont.
However BASSMIDI.BASS_MIDI_FontGetPreset returns "null" if I pass "0" for preset and "0" for bank.
Shouldn't it better return at least "empty string" or the name of the soundfont, if no preset name is available  (i think the iOS Version does)
« Last Edit: 25 Mar '18 - 14:13 by norbert »

Ian @ un4seen

  • Administrator
  • Posts: 21017
Re: BASS for Android
« Reply #1361 on: 26 Mar '18 - 17:11 »
That sounds like you may be using an old BASSMIDI version on Android. BASS_MIDI_FontGetPreset would previously return NULL for SFZ files, but in the current version (2.4.11), it should return the SFZ filename, or an empty string if that is not available (eg. when BASS_MIDI_FontInitUser is used to load the file).

gicci

  • Posts: 48
Re: BASS for Android
« Reply #1362 on: 27 Mar '18 - 20:00 »
Hi Ian,

I am receiving crash reports from your library but only on Android 6.0 devices. I have a 6.0.1 tablet but on it the problem seems to be not present, and also in the (x86) emulator I was not able to reproduce. I think that you shall be triggering some fault of early 6.0 ROMs. I have only the following info (always the same location):

backtrace:
  #00  pc 000000000000bcf8  /data/app/<package>-2/lib/arm/libbasswv.so

Users report that the app crashes as soon as they try to open a MIDI file.

Ian @ un4seen

  • Administrator
  • Posts: 21017
Re: BASS for Android
« Reply #1363 on: 28 Mar '18 - 14:45 »
That looks like it crashed in the BASSWV add-on. Are you sure the crash is happening when just opening a MIDI file (eg. in a BASS_MIDI_StreamCreateFile call), or could it be when starting playback (and loading samples) of the MIDI stream? Is the user using a Wavpack-encoded soundfont/samples? If so, please upload that to have a look at here:

   ftp.un4seen.com/incoming/

Please also confirm what version of BASSWV you are using in your app.

gicci

  • Posts: 48
Re: BASS for Android
« Reply #1364 on: 28 Mar '18 - 15:10 »
This happens with the latest version currently linked in the first post.
The default SoundFont embedded with the app is compressed, so I guess that this happens at playback start with it used.
Unfortunately no other trace is available as this crash happens in native, I am trying to understand if I am able to instrument the app more to collect other info, but as I do not have the library symbols probably nothing more than the PC within it (already available) will be reported.
I forgot to say that the signal generating the crash is signal 11 (SIGSEGV), code 1 (SEGV_MAPERR).

I uploaded the soundfont "SOUNDFONT-e3.sf2". As the name says it has been compressed with option -e3.
« Last Edit: 28 Mar '18 - 15:15 by gicci »

Ian @ un4seen

  • Administrator
  • Posts: 21017
Re: BASS for Android
« Reply #1365 on: 28 Mar '18 - 17:40 »
I wasn't able to reproduce the crash with that soundfont on an Android 6.0 device here (using the MIDITEST example). Perhaps it's happening when playing a particular MIDI file?

Anyway, from the address you posted, it appears to have crashed in the Wavpack decoder's armv7-optimized unpack_decorr_mono_pass_cont_armv7 function. So here's an update with the decoder's armv7 optimizations disabled for your user(s) to try:

   www.un4seen.com/stuff/basswv-android-test.zip

Let me know if the crash still happens with that (and the new address if so).

gicci

  • Posts: 48
Re: BASS for Android
« Reply #1366 on: 28 Mar '18 - 22:35 »
For sure it is not due to the MIDI file, one user reported that it is not able to open no file at all on one of his devices, while in the past it worked on all of them. Unfortunately most of the users do not report the error and just uninstall  :(

I have 1030 of this crash report from 116 unique users, this is a list of devices on which it is present, if you have any one of them to try:

Code: [Select]
TCT (Alcatel) 5080A (shine_lite), 2048MB RAM, Android 6.0
Samsung Galaxy S5 Neo (s5neolte), 2048MB RAM, Android 6.0
Samsung Grand Prime Plus (grandpplte), 1536MB RAM, Android 6.0
Samsung Galaxy S5 Neo (s5neolte), 2048MB RAM, Android 6.0
Advan digital i7A (ADVAN_i7A), 1024MB RAM, Android 6.0
Samsung Galaxy Note4 (trelte), 3072MB RAM, Android 6.0
Samsung Galaxy J7 Prime (on7xelte), 3072MB RAM, Android 6.0
LGE LG G4 (p1), 3072MB RAM, Android 6.0
NGM Italia SRL Smart5Plus (Smart5Plus), 3072MB RAM, Android 6.0
ZTE NX531J (NX531J), 3072MB RAM, Android 6.0
Wiko JERRY (v2806), 1024MB RAM, Android 6.0
Freetel SAMURAI REI (FTJ161B), 2048MB RAM, Android 6.0
Sony Xperia XZ (SO-01J), 3072MB RAM, Android 6.0
Acer B3-A30 (acer_jetfirehd), 1024MB RAM, Android 6.0
Huawei Mate 8 (HWNXT), 4096MB RAM, Android 6.0
Vivo Y55s (1610), 3072MB RAM, Android 6.0
Acer B3-A30 (acer_jetfirehd), 1024MB RAM, Android 6.0
Samsung Galaxy Note4 (tre3calteskt), 3072MB RAM, Android 6.0
Samsung Grand Prime Plus (grandppltedtv), 1536MB RAM, Android 6.0
Wiko ROBBY (V3750AN), 1024MB RAM, Android 6.0
ZTE BLADE L7 (P731F10), 1024MB RAM, Android 6.0
Samsung Galaxy J1 (j1xlteatt), 1024MB RAM, Android 6.0
Lenovo TAB 2 A10 (A10-70F), 2048MB RAM, Android 6.0
Acer B3-A30 (acer_jetfirehd), 1024MB RAM, Android 6.0
Fujitsu F-04G (F04G), 3072MB RAM, Android 6.0
Altice S31 (S31), 1024MB RAM, Android 6.0
BlackBerry PRIV by BlackBerry (venice), 3072MB RAM, Android 6.0
Wiko JERRY (v2806), 1024MB RAM, Android 6.0
Vivo 1601 (1601), 3072MB RAM, Android 6.0
Lenovo TAB 3 850M (TB3-850M), 1024MB RAM, Android 6.0
Oppo CPH1609 (CPH1609), 4096MB RAM, Android 6.0

Other interesting clues:
  • As said, I had a previous version of the app released on January 2017 where the fault was not present, I only recently restarted publishing updates and on all of them the fault is reported. So it seems that it could be due to something changed in between. I imported in my source system a new version of libbasswv.so on 27/3/2017, without releasing it until now.
  • I load the SoundFont in memory and I use it from there.

What was changed in that release? Could I rollback to the previous version on the main track, while letting friendly users test the not optimized version on the beta channel?

Thank you for your support.

Ian @ un4seen

  • Administrator
  • Posts: 21017
Re: BASS for Android
« Reply #1367 on: 29 Mar '18 - 15:48 »
What BASSWV version was the "backtrace" that you posted from? If it wasn't 2.4.6 (the version currently in the 1st post), then the address may not have been in the function that I stated. The main change from BASSWV 2.4.5 to 2.4.6 was updating the Wavpack decoder from 4.70 to 5.0 (which added the armv7 optimizations).

gicci

  • Posts: 48
Re: BASS for Android
« Reply #1368 on: 29 Mar '18 - 15:55 »
The crash was from the version currently in the first post. The previous one (if it was released before 27/3/2017, I am not sure how to check the version number) was working properly.
What puzzles me is how these optimizations are linked to Android 6.0. Do they use any system call?

gicci

  • Posts: 48
Re: BASS for Android
« Reply #1369 on: 29 Mar '18 - 16:19 »
I looked a bit into the source code of Wavpack, and it seems that there is a later release of the ARM decoder which removes the usage of the SSAT instruction. My best guess is that on the ARM used by those devices the instruction is missing, and/or its emulation is broken.
Could you try to build a library using the latest unpack_armv7.S ?

https://github.com/dbry/WavPack/commit/2fd94796d688b8b075fb8af7501256d2da23d634

Ian @ un4seen

  • Administrator
  • Posts: 21017
Re: BASS for Android
« Reply #1370 on: 29 Mar '18 - 17:39 »
I don't think it's related to the SSAT instruction (armv7 includes that). The crash is happening on this line:

   https://github.com/dbry/WavPack/blob/ececd958b0929a6b9603da8997231999961b037c/src/unpack_armv7.S#L663

That instruction is reading from a buffer, so my guess is it's going beyond the end of the buffer when the crash happens. The unpack_armv7.S file isn't used in the update I posted above, so hopefully that will prevent the problem happening.

Regarding BASSWV release dates, 2.4.6 was released for Android on 25/1/2017. 2.4.5 was released in 2014.

gicci

  • Posts: 48
Re: BASS for Android
« Reply #1371 on: 30 Mar '18 - 22:42 »
I have released the app with the un-optimized version and I have got no crash report up to now.
Is that the 2.4.5 version? Will you revert your main version to the un-optimized one?
I would like to avoid picking that version by mistake...

denis_shakinov

  • Posts: 3
Re: BASS for Android
« Reply #1372 on: 3 Apr '18 - 17:39 »
Could you please provide code snippet how to use AudioTrack output with Bass. I've found BASS.BASS_DEVICE_AUDIOTRACK constant but when I used it as:
Code: [Select]
BASS.BASS_Init(BASS.BASS_DEVICE_AUDIOTRACK, SAMPLE_RATE, 0)I hear no sound then

Ian @ un4seen

  • Administrator
  • Posts: 21017
Re: BASS for Android
« Reply #1373 on: 3 Apr '18 - 18:02 »
I have released the app with the un-optimized version and I have got no crash report up to now.
Is that the 2.4.5 version? Will you revert your main version to the un-optimized one?
I would like to avoid picking that version by mistake...

The BASSWV update posted above is the 2.4.6 release version minus the armv7 optimizations. If it turns out that the armv7 optimizations are indeed causing the crashes, I will replace the current release version (in the 1st post) with the update. Let me know what you find with your app.

Could you please provide code snippet how to use AudioTrack output with Bass. I've found BASS.BASS_DEVICE_AUDIOTRACK constant but when I used it as:
Code: [Select]
BASS.BASS_Init(BASS.BASS_DEVICE_AUDIOTRACK, SAMPLE_RATE, 0)I hear no sound then

Those parameters appear to be in the wrong order. Try this:

Code: [Select]
BASS.BASS_Init(-1, SAMPLE_RATE, BASS.BASS_DEVICE_AUDIOTRACK)

denis_shakinov

  • Posts: 3
Re: BASS for Android
« Reply #1374 on: 3 Apr '18 - 19:14 »
Thanks Ian, I hear sound now.
However, do I need to create a AudioTrack object directly and write a buffer to it and invoke audioTrack.play()?
(I use BASS_MIDI_FontInit for soundfont loading and then apply different effects on channel and just invoke BASS_MIDI_StreamEvent when I need to hear a midi note)