Author Topic: BASS for Android  (Read 652058 times)

ken1

  • Guest
Re: BASS for Android
« Reply #1650 on: 25 Nov '19 - 17:09 »
I tried use this library but the game crashes after touch on it.
Scheme how it works. GTA SA Mobile + SAMP Mobile + BASS lib.
GTA SA Mobile runs (libGTASA.so (JNI_OnLoad) -> runs samp.so (i include bass into so library, see Android.mk file)

APK file:
https://yadi.sk/d/hAiFuNFEDpn0vA

Here is a log:
https://pastebin.com/yECu4uHf

Android.mk file
https://pastebin.com/4wTHzrLb

Application.mk file
https://pastebin.com/Xd25rdsW

Files structure:
https://pastebin.com/G7bTAg2b


Ian @ un4seen

  • Administrator
  • Posts: 22241
Re: BASS for Android
« Reply #1651 on: 26 Nov '19 - 15:05 »
That looks like there was a failed System.loadLibrary call in the com.rockstargames.gtasa.GTASA class static block. What Android version are you running the app on? If you run the app under the Android Studio debugger, it should tell you what library couldn't be loaded and possibly where was searched.

ken1

  • Guest
Re: BASS for Android
« Reply #1652 on: 28 Nov '19 - 08:33 »
I running it from
Redmi Note 7
Android ver: 9 PKQ1. 180904.001
MIUI ver: MIUI Global 10.21 stable
Core ver: 4.4.153-perf+

elan

  • Posts: 33
Re: BASS for Android
« Reply #1653 on: 3 Dec '19 - 22:10 »
I might be missing something, but I can't find a bass.h which defines BASS_CONFIG_ANDROID_AAUDIO  :)

(Used to grabbing latest headers from the Mac/Windows/Linux main downloads, but they don't seem to have them.)

Ian @ un4seen

  • Administrator
  • Posts: 22241
Re: BASS for Android
« Reply #1654 on: 4 Dec '19 - 14:11 »
The BASS_CONFIG_ANDROID_AAUDIO option will be included in the BASS.H file with the next BASS release (it was introduced after the current Win32/Linux/OSX releases). In the meantime, you can define it yourself like this:

Code: [Select]
#define BASS_CONFIG_ANDROID_AAUDIO 67

ken1

  • Guest
Re: BASS for Android
« Reply #1655 on: 7 Dec '19 - 09:43 »
I can't found any info about bass lib (NDK version compiled on, should it work on ndk 14 version?).
And what bass lib includes inside (.so files).

ken1

  • Guest
Re: BASS for Android
« Reply #1656 on: 8 Dec '19 - 21:31 »
Now it's works. I using dlopen function but now another problem with error "undefined reference to ''".
https://pastebin.com/bWKMrbGs

If using precomiled shared libraries in Android.mk then compiles correctly but if you just include bass.h and bass.lib then i got this (errors above).

Ian @ un4seen

  • Administrator
  • Posts: 22241
Re: BASS for Android
« Reply #1657 on: 9 Dec '19 - 17:52 »
I think using "include $(BUILD_SHARED_LIBRARY)" in the Android.mk file (like you did originally) is the correct way to use the BASS libraries in native code. Did you try running under the debugger to find out which library couldn't be loaded?

If you would prefer to use dlopen then you will need to define the BASS functions as pointers and use dlsym to set them. You can define the functions as pointers by simply doing this:

Code: [Select]
#define BASSDEF(f) (*f) // define the BASS functions as pointers
#include "bass.h"

Note you should only do that in one source file, otherwise you will have multiple pointers to each BASS function that need setting.

otherside

  • Posts: 53
Re: BASS for Android
« Reply #1658 on: 16 Dec '19 - 13:38 »
Hello. I have a problem with new version of bass that is related to AAudio.

If I press 1) play 2) pause 3) after 1-2 seconds play - AAudioStream_requestStop is getting called without AAudioStream_requestStart and audio is not being played.

Also I tried to disable AAudio mode without success. Nothing changed in terms of sound and I still saw messages:
AAudioStream_requestStart - (when play)
AAudioStream_requestStop - (2-3 seconds after pause)

I don't seem to be able to reproduce that problem here. Please confirm what Android and BASS versions you're using (what BASS_GetVersion reports). Also confirm whether you're using BASS_ChannelPause/Play or BASS_Pause/Start, and are the calls reporting success in their return values?

This is how I tried to disable it:
Code: [Select]
BASS.BASS_Init(-1, strToIntDef, 0)
BASS.BASS_SetConfig(BASS.BASS_CONFIG_ANDROID_AAUDIO, 0)

BASS_CONFIG_ANDROID_AAUDIO needs to be set before calling BASS_Init for the new setting to take effect.

Hello again. I applied your suggestion. There's no trouble now when I disable AAudio output. But the problem described above persists with AAudio.
Bass version - 33820181
I use - BASS_ChannelPause/Play and they always return true. Also I tried method isChannelActive it returns that channel is being played, even thou it is not true.

UPD: found what triggers the trouble - I have a preference, that sound go down before pause and up after start for smoothness. This is what creates bug. And it is weird that the bug exists only on this audio output.

This is how it is done:

Code: [Select]
BASS.BASS_ChannelSetSync(chan, BASS.BASS_SYNC_SLIDE, 1, { handle, channel, data, user: Any? ->
            BASS.BASS_ChannelRemoveSync(channel, handle)
            BASS.BASS_ChannelPause(chan)
        }, null)
        BASS.BASS_ChannelSlideAttribute(chan, BASS.BASS_ATTRIB_VOL, 0f, 2000L)
« Last Edit: 16 Dec '19 - 13:58 by otherside »

Ian @ un4seen

  • Administrator
  • Posts: 22241
Re: BASS for Android
« Reply #1659 on: 16 Dec '19 - 13:53 »
Please see if you can still reproduce the problem with this latest build:

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

If it does still happen then I will probably need to send you a debug version to get more info.

otherside

  • Posts: 53
Re: BASS for Android
« Reply #1660 on: 17 Dec '19 - 14:14 »
Please see if you can still reproduce the problem with this latest build:

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

If it does still happen then I will probably need to send you a debug version to get more info.

I tested it. Thanks! The bug has disappeared.

Ian @ un4seen

  • Administrator
  • Posts: 22241
Re: BASS for Android
« Reply #1661 on: 17 Dec '19 - 17:11 »
The Android version of the BASS 2.4.15 release is up now in the 1st post.

ken1

  • Guest
Re: BASS for Android
« Reply #1662 on: 18 Dec '19 - 20:32 »
It's possible to remove "looped echo"?

When i say something on Windows and hear it on Android i heard some high frequency waves (from normal to high frequency) and my voice is repeated many times and infinite. This happend when i say something on Android too but on Windows i hear better quality (and few "looped echo" on last phrase).

Specs of sound:
bitrate = 6000
frequency = 48000
frame_dur = 100

ken1

  • Guest
Re: BASS for Android
« Reply #1663 on: 19 Dec '19 - 08:13 »
tried to set BASS_CONFIG_ANDROID_AAUDIO 0
and BASS_CONFIG_UPDATEPERIOD from 1 to 100
all this parameters set before i called BASS_Init

nothing changes. I hear "looped echo"


ken1

  • Posts: 4
Re: BASS for Android
« Reply #1664 on: 19 Dec '19 - 22:57 »
UPD: forgot to say, im using opus (https://opus-codec.org/) to decode data.

I record via BASS_RecordStart -> use opus_encode -> send to clients (from Windows to Android or vice versa) -> and then I decode (opus_decode) and put it via BASS_StreamPutData into created stream
BASS_StreamCreate(48000, 1, 0, STREAMPROC_PUSH, nullptr);

Now i founded bassopus, but how can i use this function BASS_OPUS_StreamCreateFile if my buffer len is variable, sound doesn't playing idk what i am doing wrong, and maybe this is not a problem with "looped echo".

« Last Edit: 19 Dec '19 - 23:03 by ken1 »

Ian @ un4seen

  • Administrator
  • Posts: 22241
Re: BASS for Android
« Reply #1665 on: 20 Dec '19 - 14:59 »
That sounds like you're getting feedback. Are you recording from a microphone and playing on a speaker at the same time in the same place? If so, does the problem go away if you use headphones instead of a speaker?

ken1

  • Posts: 4
Re: BASS for Android
« Reply #1666 on: 20 Dec '19 - 16:18 »
Case 1. I am recording from laptop (internal mic) and playing it from phone (speakers).
Case 2. I recording it from phone and playing it from laptop (speakers).

In 1 case i have this problem "looped echo". I tested bass examples, rectest. Everything works good.
I am using a default devices (- 1 parameter in BASS_Init and BASS_RecordInit).

I put my phone far from laptop and set volume 40%. Volume increases and high freq too on my phone.
« Last Edit: 20 Dec '19 - 16:22 by ken1 »

ken1

  • Posts: 4
Re: BASS for Android
« Reply #1667 on: 20 Dec '19 - 16:27 »
Ian, i tested it with my headphones plugged to phone. Everything works good. But if i using speakers, i got this "looped echo".

Specs:
- Headphones is audio technica ath m20x
- Phone Redmi Note 7
Android ver: 9 PKQ1. 180904.001
MIUI ver: MIUI Global 10.21 stable
Core ver: 4.4.153-perf+
« Last Edit: 20 Dec '19 - 16:30 by ken1 »

Ian @ un4seen

  • Administrator
  • Posts: 22241
Re: BASS for Android
« Reply #1668 on: 23 Dec '19 - 16:19 »
If headphones prevent the problem then that sounds like it is indeed feedback, ie. previously captured sound is being captured again from the speaker. AEC (Acoustic Echo Cancellation) processing can help with that. BASS doesn't include that feature but if you would like to give it a try, Android has an AcousticEchoCanceler effect (note you will need to use the AudioRecord API instead of BASS_RecordInit/etc for recording then):

   https://developer.android.com/reference/android/media/audiofx/AcousticEchoCanceler.html

If that doesn't work for you, there is also the libspeex library that includes AEC processing (speex_echo_xxx functions), but I'm not sure whether there is a ready-made Android build of that available.

ken1

  • Posts: 4
Re: BASS for Android
« Reply #1669 on: 24 Dec '19 - 13:58 »
I understood correctly, that i need to call speex_echo_cancellation then speex_preprocess_run and after this use BASS_StreamPutData (on Android)?
I done that but this sound i get from packet (from Windows) and i don't know the microphone sound or maybe i don't get it (right now i using only recieved data) and i don't see any effect.

I develop this from JNI and i can't use Android functions (only C++ calls without Java) and i can only use bass API because application on windows using this too.

UPD: Forgot to say, i tested all this with BASS_RecordInit removed (tried to hear sound only without microphone on Android). Echo is exists (from low volume to high volume with high freq). (speex is not used at this moment)

UPD 2: Also i tested this on different volumes on Android. 30% volume (speakers) and lower don't cause this problem.
UPD 3. I changed system volume via hotkeys to 0% on Windows (only recording is available), the same problem.
UPD 4. Removed BASS_Init from Windows too, the same problem.
UPD 5. Maybe it's an another theory, but i using a game (with bass module for VO-IP) and this game makes ambient sounds like wind (maybe it can be affected), i swithed volume to zero in menu (on Android and Windows) nothing changes, the same "looped echo"
UPD 6. Spent some time and founded AEC from WebRTC, should it help? Some people says that speex can't handle big echo from sound.
« Last Edit: 24 Dec '19 - 22:07 by ken1 »

teq

  • Posts: 47
Re: BASS for Android
« Reply #1670 on: 26 Dec '19 - 14:35 »
To perhaps narrow down where the problem is, please try this latest build:

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

If the problem still happens then check whether it also happens after adding the BASS_DEVICE_AUDIOTRACK flag to your BASS_Init call. If it happens then too, you can next try enabling AAudio output like this before calling BASS_Init (and don't use the BASS_DEVICE_AUDIOTRACK flag):

Code: [Select]
BASS.BASS_SetConfig(BASS.BASS_CONFIG_ANDROID_AAUDIO, 1); // enable AAudio
Hi! Should i restart app after this method calls or there is a way to change output on the fly?
I'm using it with bass.net, but it is still not updated, so i can't use BASS_DEVICE_AUDIOTRACK, right?

Ian @ un4seen

  • Administrator
  • Posts: 22241
Re: BASS for Android
« Reply #1671 on: 27 Dec '19 - 14:30 »
I understood correctly, that i need to call speex_echo_cancellation then speex_preprocess_run and after this use BASS_StreamPutData (on Android)?
I done that but this sound i get from packet (from Windows) and i don't know the microphone sound or maybe i don't get it (right now i using only recieved data) and i don't see any effect.

Are you not recording and playing on the Android device? AEC processing needs to see the recorded and played sample data, so they need to be done on the same device. I haven't looked into its internals but I would guess that the AcousticEchoCanceler effect has access to Android's output, so you don't need to provide that to it.

Hi! Should i restart app after this method calls or there is a way to change output on the fly?
I'm using it with bass.net, but it is still not updated, so i can't use BASS_DEVICE_AUDIOTRACK, right?

You don't need to restart the app to change the BASS_DEVICE_AUDIOTRACK setting, but you do need to reinitilize the output device, ie. call BASS_Free and BASS_Init again. BASS_DEVICE_AUDIOTRACK is defined as 0x20000. You can use that value with BASS.Net like this: (BASSInit)0x20000

Ionut Cristea

  • Posts: 1557
Re: BASS for Android
« Reply #1672 on: 10 Jan '20 - 14:06 »
Hello,

Does anyone noticed this ANR too?

Quote

  #00  pc 00000000000168e0  /system/lib/libc.so (syscall+28)
 
  #01  pc 0000000000041ee1  /system/lib/libc.so (_ZL33__pthread_mutex_lock_with_timeoutP24pthread_mutex_internal_tPK8timespeci+328)
 
  #02  pc 0000000000042095  /system/lib/libc.so (pthread_mutex_lock+26)
 
  #03  pc 000000000000fd13  /data/app/com.surodev.suamp-1/split_config.armeabi_v7a.apk (???)
 
  #04  pc 00000000000272f1  /data/app/com.surodev.suamp-1/split_config.armeabi_v7a.apk (???)
 
  #05  pc 0000000000027957  /data/app/com.surodev.suamp-1/split_config.armeabi_v7a.apk (???)
 
  #06  pc 000000000031d0b3  /data/app/com.surodev.suamp-1/oat/arm/base.odex (Java_com_un4seen_bass_BASS_BASS_1Init__III+102)
 
  at com.un4seen.bass.BASS.BASS_Init (BASS.java)

Ian @ un4seen

  • Administrator
  • Posts: 22241
Re: BASS for Android
« Reply #1673 on: 10 Jan '20 - 16:59 »
That seems to suggest that a BASS_Init call took too long. Please confirm where you are calling BASS_Init from. Can you reproduce the problem? If so, to narrow down the cause, does it still happen if you use the BASS_DEVICE_AUDIOTRACK flag? Or if you remove the flag, in case you are currently using it. Also, what Android version is it? If 8.1 or above, you could check if disabling AAudio prevents the problem, like this:

Code: [Select]
BASS.BASS_SetConfig(BASS.BASS_CONFIG_ANDROID_AAUDIO, 0);