Author Topic: BASS for Android  (Read 249533 times)

Ian @ un4seen

  • Administrator
  • Posts: 18804
BASS for Android
« on: 21 Nov '11 - 16:23 »
Android versions of BASS and the BASSALAC/DSD/FLAC/MIDI/OPUS/WV/enc/mix add-ons are available here:

   www.un4seen.com/stuff/bass24-android.zip (updated: 3 Feb '16)

These add-ons are also available:

   www.un4seen.com/stuff/bass_aac-android.zip
   www.un4seen.com/stuff/bass_ape-android.zip
   www.un4seen.com/stuff/bass_mpc-android.zip
   www.un4seen.com/stuff/bass_tta-android.zip
   www.un4seen.com/stuff/tags-android.zip
   www.un4seen.com/files/z/0/bass_fx24-android.zip

The armeabi/armeabi-v7a/x86 architectures are supported. For performance reasons, the armeabi version uses fixed-point rather than floating-point (like the Windows CE version), which means the BASS_SAMPLE_FLOAT flag isn't supported. The BASS_CONFIG_FLOATDSP option is still available then, but it will result in DSPPROC functions receiving 8.24 fixed-point data instead of floating-point. The BASS_CONFIG_FLOAT config option can be used (with BASS_GetConfig) to check whether floating-point is supported (1=yes, 0=no); the DSPTEST example includes a demonstration of using that. In the case of the BASSMIDI add-on, MIDI input isn't supported and BASS_MIDI_FontPack isn't included because there are no command-line encoders to use. BASS_MIDI_StreamGetChannel also isn't available on the armeabi architecture due to the lack of floating-point streams.

The libraries include support for Java code (via BASS classes), as well as native code (via the usual BASS headers). The Java API follows the C/C++ API as much as possible, but there are some unavoidable differences, mainly in parameter/return types. The BASS classes are included in source form (eg. BASS.JAVA file), so you can see exactly what's what in there. Java versions of the DSPTEST/FXTEST/LIVESPEC/NETRADIO/PLUGINS/RECTEST and MIDITEST examples are included to demonstrate things. To play with the examples, you can use the "New > Android Project > Create project from existing source" option to create projects for them in Eclipse. You will also need to import the root SRC folder (containing the BASS class) via the "Build Path > Link Source" option and copy the root LIBS folder (containing the BASS library) into the example's folder. When using an add-on (eg. with the PLUGINS or MIDITEST example), you should do the same with the add-on's SRC and LIBS folders. Note the SRC folder (containing the add-on's class) is only needed when calling the add-on's functions (as in MIDITEST), not when using the plugin system (as in PLUGINS).

Android's native audio API (OpenSL ES-based) is used for audio output/input, which requires Android 2.3, but the "no sound" device is still available with older versions (decoding channels could be fed into the AudioTrack stuff then). The BASS_CONFIG_DEV_BUFFER config option determines the device/output buffer size used by BASS. That currently defaults to 30ms, which might be a bit too low for some devices; try increasing that if you get stuttering output. BASS_Init will default to using the device's native sample rate (as reported by AudioTrack.getNativeOutputSampleRate) rather than the rate provided in the "freq" parameter, but that can be overridden via the BASS_DEVICE_FREQ flag. High resolution output is supported on Android 5, while older Android versions are limited to 16-bit output.

An "mp3-free" BASS version (using the OS's MP3 decoder) is included, which requires Android 4.1 or above; it will run on earlier versions but MP3 support won't be available.

For convenience, the stream/sample/music creation functions include support for assets, via an "Asset" class. For example, a stream could be created from a "music.ogg" asset like this...

Code: [Select]
stream = BASS.BASS_StreamCreateFile(new BASS.Asset(getAssets(), "music.ogg"), 0, 0, 0);

When using ProGuard to obfuscate your Java code, the BASS classes should be left alone, like this:

Code: [Select]
-keep class com.un4seen.bass.** {*;}
« Last Edit: 3 Feb '16 - 13:20 by Ian @ un4seen »

zenon

  • Posts: 95
Re: BASS for Android
« Reply #1 on: 21 Nov '11 - 20:14 »
Congratulations !!!

BASS library rocks !!!  8)

Ionut Cristea

  • Posts: 1533
Re: BASS for Android
« Reply #2 on: 21 Nov '11 - 23:45 »
  I've tried to make an application with Eclipse. I've build with both ARMv5 and ARMv7. Every bass call i make make application to crash.

Ian @ un4seen

  • Administrator
  • Posts: 18804
Re: BASS for Android
« Reply #3 on: 22 Nov '11 - 14:04 »
What does Eclipse say about the crash, eg. is there an exception and/or is there anything in the log? If it's happening with every BASS call, perhaps the problem is that the BASS library can't be found. Did you copy the LIBS folder into your project's folder? After doing that, you may also need to refresh the Eclipse project (the LIBS folder should be shown in the project's contents).

If you're still having any trouble with it, please check whether the same thing happens when you try to run the examples.

Ionut Cristea

  • Posts: 1533
Re: BASS for Android
« Reply #4 on: 22 Nov '11 - 14:11 »
"The application .... has stopped unexpectedly. PLease try again"


this happens with my application, and bass samples also. I've included libbass

Ian @ un4seen

  • Administrator
  • Posts: 18804
Re: BASS for Android
« Reply #5 on: 22 Nov '11 - 15:02 »
That looks like a message displayed on the device rather than in Eclipse? Please also check what Eclipse has to say about it in its debug perspective, eg. there should be some details in the "LogCat" view.

To confirm that the problem is happening on the first BASS call, have you placed a breakpoint on the call and then tried stepping over (F6) it? If it reaches the breakpoint and then crashes when you step over the call, does it make any difference what the call is, eg. does it happen even with a BASS_GetVersion call? Note the app should be started in "Debug" mode (rather than "Run") when doing this.

Ionut Cristea

  • Posts: 1533
Re: BASS for Android
« Reply #6 on: 22 Nov '11 - 15:20 »
Thread [<1> main] (Suspended (exception UnsatisfiedLinkError))   
   Runtime.loadLibrary(String, ClassLoader) line: 429   
   System.loadLibrary(String) line: 554   
   BASS.<clinit>() line: 612   
   NetRadio.onCreate(Bundle) line: 183   
   Instrumentation.callActivityOnCreate(Activity, Bundle) line: 1047   
   ActivityThread.performLaunchActivity(ActivityThread$ActivityClientRecord, Intent) line: 1611   
   ActivityThread.handleLaunchActivity(ActivityThread$ActivityClientRecord, Intent) line: 1663   
   ActivityThread.access$1500(ActivityThread, ActivityThread$ActivityClientRecord, Intent) line: 117   
   ActivityThread$H.handleMessage(Message) line: 931   
   ActivityThread$H(Handler).dispatchMessage(Message) line: 99   
   Looper.loop() line: 123   
   ActivityThread.main(String[]) line: 3683   
   Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]   
   Method.invoke(Object, Object...) line: 507   
   ZygoteInit$MethodAndArgsCaller.run() line: 839   
   ZygoteInit.main(String[]) line: 597   
   NativeStart.main(String[]) line: not available [native method]   

Ian @ un4seen

  • Administrator
  • Posts: 18804
Re: BASS for Android
« Reply #7 on: 22 Nov '11 - 15:45 »
Thread [<1> main] (Suspended (exception UnsatisfiedLinkError))   
   Runtime.loadLibrary(String, ClassLoader) line: 429   
   System.loadLibrary(String) line: 554   
   BASS.<clinit>() line: 612   

That does look very much like the BASS library can't be found :)

Is the LIBS folder shown in Eclipse, and if you open it, do you see the ARMEABI(-V7A) subfolders and LIBBASS.SO files in there? If not, try refreshing the project (right-click and choose "Refresh").

Ionut Cristea

  • Posts: 1533
Re: BASS for Android
« Reply #8 on: 22 Nov '11 - 22:56 »
Quote
Is the LIBS folder shown in Eclipse, and if you open it, do you see the ARMEABI(-V7A) subfolders and LIBBASS.SO files in there? If not, try refreshing the project (right-click and choose "Refresh").

Yes is there :(

Ian @ un4seen

  • Administrator
  • Posts: 18804
Re: BASS for Android
« Reply #9 on: 23 Nov '11 - 14:14 »
Does your "Package Explorer" view in Eclipse look like the attached image? To confirm whether the BASS library is being included in the app's package, you can go to the project's BIN directory and open the APK file with a ZIP archiver; you should find a LIB folder in there (with the same contents as the project's LIBS folder).

Ionut Cristea

  • Posts: 1533
Re: BASS for Android
« Reply #10 on: 23 Nov '11 - 15:06 »
Yes the tree folder is similar and i can find libbass.so in the .apk file :)
Here is my compiled netradio example

Ian @ un4seen

  • Administrator
  • Posts: 18804
Re: BASS for Android
« Reply #11 on: 23 Nov '11 - 16:07 »
The LIBBASS.SO file is in the root of your package instead of in a LIB folder, so that explains why it isn't being found. When you say your project looks similar, how similar is that? :) ... The LIBS branch should look identical. If it is identical and still not working, please upload the entire project folder to have a look at, to hopefully find out what is going wrong with it.

Ian @ un4seen

  • Administrator
  • Posts: 18804
Re: BASS for Android
« Reply #12 on: 24 Nov '11 - 16:47 »
There were problems with the MO3 and IT file loaders, so an updated library is up (in the 1st post) to fix that. An FXTEST example has also been added.

bjadams

  • Posts: 9
Re: BASS for Android
« Reply #13 on: 28 Nov '11 - 20:45 »
Does it support the Android NDK or is it Java only, as I could not find and NDK examples in the zip archive?
« Last Edit: 28 Nov '11 - 21:57 by bjadams »

Ian @ un4seen

  • Administrator
  • Posts: 18804
Re: BASS for Android
« Reply #14 on: 29 Nov '11 - 15:25 »
Yes, it should be possible to use the BASS library in native code too, with the standard BASS.H header. The header isn't included in the package above, but it can be taken from one of the other BASS platform packages (it's the same header for all platforms).

Meanwhile... Android versions of the BASSFLAC and BASSWV add-ons have been added to the package, as well as a PLUGINS example. The BASS library has also had a little update to add support for that stuff.

bjadams

  • Posts: 9
Re: BASS for Android
« Reply #15 on: 29 Nov '11 - 23:11 »
I still can't find 1 example or some step-by-step guide how to add all the necessary BASS bits to my current Android project so that I can use it natively.
Is there any chance to put in at least 1 simple example or some quick guide?

materialworlds

  • Posts: 17
Re: BASS for Android
« Reply #16 on: 30 Nov '11 - 10:41 »
Any timescale for an Android version of BASS FX ? :)
« Last Edit: 30 Nov '11 - 10:58 by materialworlds »

Ian @ un4seen

  • Administrator
  • Posts: 18804
Re: BASS for Android
« Reply #17 on: 30 Nov '11 - 17:09 »
I still can't find 1 example or some step-by-step guide how to add all the necessary BASS bits to my current Android project so that I can use it natively.
Is there any chance to put in at least 1 simple example or some quick guide?

I'm afraid there aren't currently any examples for using BASS in native Android projects. Are you looking for help on using BASS (function calls/etc) or on how to include the library in a native Android project? The BASS calls will be the same as on other platforms, so you could have a look at the examples from the other platform BASS packages (be sure to also check the documentation for usage details). Regarding including the library in a native project, I think you would do something like this in your "Android.mk" file...

Code: [Select]
include $(CLEAR_VARS)
LOCAL_MODULE := bass
LOCAL_SRC_FILES := path/to/bass/libs/$(TARGET_ARCH_ABI)/libbass.so
LOCAL_EXPORT_C_INCLUDES := path/to/bass
include $(PREBUILT_SHARED_LIBRARY)

And then add this to your app's build rules...

Code: [Select]
LOCAL_SHARED_LIBRARIES := bass

bjadams

  • Posts: 9
Re: BASS for Android
« Reply #18 on: 30 Nov '11 - 21:11 »
I was mainly just looking for the steps necessary to setup the bass in my android project, not the actual BASS calls which would be the same for Windows (which I already had used once in the past).

Will test the suggested setup and report back!

Thanks for the great support!

bjadams

  • Posts: 9
Re: BASS for Android
« Reply #19 on: 1 Dec '11 - 07:09 »
As soon as I include the BASS lib details in Android.mk, and put all the relevant library files in place, I am getting a process closed error as soon as my app launches. I am not even doing any BASS api calls in my app yet!

I unzipped the apk and LIBbass is being included in the package.

Ian @ un4seen

  • Administrator
  • Posts: 18804
Re: BASS for Android
« Reply #20 on: 1 Dec '11 - 16:02 »
That's strange. Does the problem go away if you simply remove BASS from the project and leave everything else untouched? Do you see any information on what happened in the "LogCat" view? If the problem persists, please upload the APK file to have a look at here...

   ftp.un4seen.com/incoming/

bjadams

  • Posts: 9
Re: BASS for Android
« Reply #21 on: 2 Dec '11 - 06:53 »
The vanilla project, without bass included works perfectly. As soon as I put the bass information in android.mk, the app crashes at launch.

I am using the AGK Opengl api. Can I email you the project in private, or is the ftp private?

Thanks a lot for support.

ken

  • Posts: 713
Re: BASS for Android
« Reply #22 on: 2 Dec '11 - 08:39 »
Hi,

Anyone tried BASS for Android with Titanium? I know Titanium can use 3:rd party "plugins"

http://www.appcelerator.com/products/titanium-mobile-application-development/


bjadams

  • Posts: 9
Re: BASS for Android
« Reply #23 on: 2 Dec '11 - 13:32 »
Uploaded a zip on the ftp with 2 projects. 1 without Bass, and one with the bass libs added to android.mk (this one crashes on app launch)

Ian @ un4seen

  • Administrator
  • Posts: 18804
Re: BASS for Android
« Reply #24 on: 2 Dec '11 - 16:44 »
Uploaded a zip on the ftp with 2 projects. 1 without Bass, and one with the bass libs added to android.mk (this one crashes on app launch)

Java will look in the app's "lib" folder for shared libraries, but I don't think the OS does that, ie. the app's "lib" folder isn't in the library search path, so the LIBBASS.SO file can't be found and the app can't be launched. One way around it that seems to be working is to change the "SONAME" entry in the LIBBASS.SO file to the full installation path (eg. "/data/data/<packagename>/lib/libbass.so"), but that isn't very elegant. I'll see if I can find a better way around it.