24 May '13 - 15:46 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: 1 ... 3 4 [5] 6 7 ... 18
  Reply  |  Print  
Author Topic: BASS for Android  (Read 48255 times)
Ian @ un4seen
Administrator
Posts: 15275


« Reply #80 on: 13 Feb '12 - 16:11 »
Reply with quoteQuote

BASS_AAC would be great.

An Android build is now up in the 1st post.

Taking a hint from the .NET version of BASS, I was able to get StreamCreateFile to work in Mono for Android by adding a first parameter that is a bool. I don't know why this is necessary or how the Java interop engine is able to deal with it. This seems to work with passing false for the first parameter:

[DllImport("libbass")]
public static extern int BASS_StreamCreateFile(bool a, string file, long offset, long length, int flags);

I also changed some methods that were using ByteBuffer parameters to just use byte[] or int[]. That also seems to work fine, but ByteBuffer definitely does not work with the interop even though Mono for Android apparently supports the ByteBuffer class. (Good riddance, I say...)

Yep. The Android BASS version includes the standard BASS functions (as in the documentation) and wrapper functions to support the Java class. You're accessing the standard functions rather than the Java stuff, so you should look to the standard API (eg. BASS.H) for the definitions rather than the Java class (BASS.JAVA). The Java class has unneeded parameters removed from a few functions, eg. BASS_Init and BASS_StreamCreateFile.

By the way, did you try using BASS.Net? It can generally be used on any platform that is supported by BASS and Mono, so it could save you the effort of creating your own .Net wrapper.
Logged
Brannon
Posts: 16


« Reply #81 on: 14 Feb '12 - 05:20 »
Reply with quoteQuote

By the way, did you try using BASS.Net? It can generally be used on any platform that is supported by BASS and Mono, so it could save you the effort of creating your own .Net wrapper.

I did not try the BASS.Net wrapper. I was hesitant because I figured it had quite a few methods that were not yet implemented in the Android libs. Is that not true? Do your ARM libs support all the Unicode stuff?
Logged
ken
Posts: 630


« Reply #82 on: 14 Feb '12 - 08:16 »
Reply with quoteQuote


An Android build is now up in the 1st post.

Thanks, that was fast!


Logged
Ian @ un4seen
Administrator
Posts: 15275


« Reply #83 on: 14 Feb '12 - 14:09 »
Reply with quoteQuote

I did not try the BASS.Net wrapper. I was hesitant because I figured it had quite a few methods that were not yet implemented in the Android libs. Is that not true? Do your ARM libs support all the Unicode stuff?

There will be stuff in BASS.Net that isn't currently supported (eg. the encoding stuff), but if you don't use that stuff, I think it should be OK. I'm not a .Net user, so I haven't tried it myself, but BASS.Net has been used with Mono on other platforms, so I imagine it can be used on Android too.

The BASS_UNICODE flag is supported on all platforms.
Logged
Rajesh
Guest
« Reply #84 on: 27 Feb '12 - 14:41 »
Reply with quoteQuote

hello guys i have a problem with bass and bass-mix initialization. the following methods are always return false.
 i have a little-bit confusion whether im going on correct way or Huh?

 if (!BASS.BASS_Init(-1, DEFAULT_SAMPLE_RATE, BASS.BASS_DEVICE_DEFAULT | BASS.BASS_DEVICE_MONO))//Set Sample Rate / MONO
             {
          System.out.println("Pllugin load failed 1");
             }
       if (!BASS.BASS_SetConfig(BASSmix.BASS_CONFIG_MIXER_FILTER, 50))
          /*Set filter for anti aliasing*/
       {
          System.out.println("Pllugin load failed 2 ");
       }
       if (!BASS.BASS_SetConfig(BASS.BASS_CONFIG_FLOATDSP, 50))    // Set floating parameters to be passed
       {
          System.out.println("Pllugin load failed 3");
       }

Thanks Rajesh
Logged
Ian @ un4seen
Administrator
Posts: 15275


« Reply #85 on: 27 Feb '12 - 17:23 »
Reply with quoteQuote

To find out what went wrong, please check the error code by calling BASS_ErrorGetCode straight after a failed call. Also, what Android version are you using?
Logged
toob
Posts: 112


« Reply #86 on: 7 Mar '12 - 11:20 »
Reply with quoteQuote

I'm having problems getting the examples to work, specifically rectest.

I think I've done everything correctly eg "Create project from existing source", import the bass class, linked and copied the lib folder.

In elipse project I can see bass.java & rectest.java files in src. armeabi & armeabi-v7a folders and library files are shown in libs folder.

When I run the project on my phone it crashes.

I've set an early breakpoint and it fails at "BASS.BASS_RecordInit(-1)" in the rectest example code.

Logcat displays:
03-07 10:57:08.447: D/dalvikvm(1517): GC_EXPLICIT freed 85K, 50% free 4367K/8583K, external 7092K/8856K, paused 76ms
03-07 10:57:12.881: D/PowerManagerService(1371): New lightsensor value:320, lcdValue:101
03-07 10:57:12.881: D/PowerManagerService(1371): lightSensorChangedLocked, buttonValue >= 0, mPowerState = 3
03-07 10:57:16.885: D/dalvikvm(3504): Trying to load lib /data/data/com.example.rectest/lib/libbass.so 0x4051d598
03-07 10:57:16.955: D/dalvikvm(3504): Added shared lib /data/data/com.example.rectest/lib/libbass.so 0x4051d598
03-07 10:57:16.955: W/dalvikvm(3504): No implementation found for native Lcom/example/rectest/BASS;.BASS_RecordInit (I)Z
03-07 10:57:36.875: D/dalvikvm(3504): Calling exit(1)
03-07 10:57:36.895: I/ActivityManager(1371): Process com.example.rectest (pid 3504) has died.

I've checked the .apk file and that contains bass libraries.

Any clues as to what I've missed?

thanks
Mark


« Last Edit: 7 Mar '12 - 11:25 by toob » Logged
Ian @ un4seen
Administrator
Posts: 15275


« Reply #87 on: 7 Mar '12 - 15:15 »
Reply with quoteQuote

That looks like the problem is the path of the BASS.JAVA file, which needs to match the BASS package name ("com.un4seen.bass"). The simplest way (without any file copying) to add the BASS class to your project is to use Eclipse's "Build Path > Link Source" option to import the root "src" folder. If you name the folder "bass", then the project should look something like the attachment in this post...

   www.un4seen.com/forum/?topic=13225.msg92103#msg92103
Logged
toob
Posts: 112


« Reply #88 on: 8 Mar '12 - 11:19 »
Reply with quoteQuote

Thank you Ian, you correctly identified the problem.

That looks like the problem is the path of the BASS.JAVA file, which needs to match the BASS package name ("com.un4seen.bass"). The simplest way (without any file copying) to add the BASS class to your project is to use Eclipse's "Build Path > Link Source" option to import the root "src" folder. If you name the folder "bass", then the project should look something like the attachment in this post...

   www.un4seen.com/forum/?topic=13225.msg92103#msg92103
Logged
toob
Posts: 112


« Reply #89 on: 9 Mar '12 - 09:01 »
Reply with quoteQuote

Is it still the case that the only DX8 effect that currently supported in android bass is PARAMEQ?
Will the other effects be added, ie echo, distortion etc?

Also I have a requirement to play a stream in reverse, is this something that can be done in bass android now or will I need to wait for BASS_FX for android?

thanks
Logged
Ian @ un4seen
Administrator
Posts: 15275


« Reply #90 on: 9 Mar '12 - 15:24 »
Reply with quoteQuote

Is it still the case that the only DX8 effect that currently supported in android bass is PARAMEQ?
Will the other effects be added, ie echo, distortion etc?

Yes, PARAMEQ is currently the only DX8 effect supported on Android, but the others may well be added in future. I'll have a look at that next week.

Also I have a requirement to play a stream in reverse, is this something that can be done in bass android now or will I need to wait for BASS_FX for android?

It is possible to implement the reverse processing yourself, using a decoding channel (BASS_STREAM_DECODE) to decode the file and a custom stream (BASS_StreamCreate) to play it. Your STREAMPROC function would decode a block of data from the end of the file and reverse the order of the samples in it. It would then deliver the data to BASS as it is requested, and when it's finished that, it would set (using BASS_ChannelSetPosition) the decoder back to the next block and repeat. If you will be playing MP3 files, then you should use the BASS_STREAM_PRESCAN flag when doing this, to enable accurate seeking.
Logged
AndroidMediaPlayer
Guest
« Reply #91 on: 14 Mar '12 - 15:47 »
Reply with quoteQuote

Hi!

I have some problems to include the libbass.so to my native project. My android project compiles well, but when i start my app on my phone it crashes with the following error:

Quote
03-14 16:35:13.522: D/dalvikvm(14876): Trying to load lib /data/data/com.android.mediaplayer/lib/libAndroidMediaPlayer.so 0x4051cd30
03-14 16:35:13.522: W/dalvikvm(14876): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lcom/android/mediaplayer/AndroidMediaPlayerActivity;
03-14 16:35:13.522: W/dalvikvm(14876): Class init failed in newInstance call (Lcom/android/mediaplayer/AndroidMediaPlayerActivity;)
03-14 16:35:13.522: D/AndroidRuntime(14876): Shutting down VM
03-14 16:35:13.522: W/dalvikvm(14876): threadid=1: thread exiting with uncaught exception (group=0x4001d648)
03-14 16:35:13.532: E/AndroidRuntime(14876): FATAL EXCEPTION: main
03-14 16:35:13.532: E/AndroidRuntime(14876): java.lang.ExceptionInInitializerError
03-14 16:35:13.532: E/AndroidRuntime(14876):    at java.lang.Class.newInstanceImpl(Native Method)
03-14 16:35:13.532: E/AndroidRuntime(14876):    at java.lang.Class.newInstance(Class.java:1409)
03-14 16:35:13.532: E/AndroidRuntime(14876):    at android.app.Instrumentation.newActivity(Instrumentation.java:1040)
03-14 16:35:13.532: E/AndroidRuntime(14876):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1735)
03-14 16:35:13.532: E/AndroidRuntime(14876):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1851)
03-14 16:35:13.532: E/AndroidRuntime(14876):    at android.app.ActivityThread.access$1500(ActivityThread.java:132)
03-14 16:35:13.532: E/AndroidRuntime(14876):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1038)
03-14 16:35:13.532: E/AndroidRuntime(14876):    at android.os.Handler.dispatchMessage(Handler.java:99)
03-14 16:35:13.532: E/AndroidRuntime(14876):    at android.os.Looper.loop(Looper.java:150)
03-14 16:35:13.532: E/AndroidRuntime(14876):    at android.app.ActivityThread.main(ActivityThread.java:4293)
03-14 16:35:13.532: E/AndroidRuntime(14876):    at java.lang.reflect.Method.invokeNative(Native Method)
03-14 16:35:13.532: E/AndroidRuntime(14876):    at java.lang.reflect.Method.invoke(Method.java:507)
03-14 16:35:13.532: E/AndroidRuntime(14876):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
03-14 16:35:13.532: E/AndroidRuntime(14876):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
03-14 16:35:13.532: E/AndroidRuntime(14876):    at dalvik.system.NativeStart.main(Native Method)
03-14 16:35:13.532: E/AndroidRuntime(14876): Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: link_image[1963]:   140 could not load needed library 'libbass.so' for 'libAndroidMediaPlayer.so' (load_library[1105]: Library 'libbass.so' not found)
03-14 16:35:13.532: E/AndroidRuntime(14876):    at java.lang.Runtime.loadLibrary(Runtime.java:434)
03-14 16:35:13.532: E/AndroidRuntime(14876):    at java.lang.System.loadLibrary(System.java:554)
03-14 16:35:13.532: E/AndroidRuntime(14876):    at com.android.mediaplayer.AndroidMediaPlayerActivity.<clinit>(AndroidMediaPlayerActivity.java:15)
03-14 16:35:13.532: E/AndroidRuntime(14876):    ... 15 more

I have checked the apk file, libbass.so is included in /libs/armeabi/. Heres my Android.mk

Quote
LOCAL_PATH := $(call my-dir)

# Bass
# ========================================================
include $(CLEAR_VARS)
LOCAL_MODULE := bass
LOCAL_SRC_FILES := $(TARGET_ARCH_ABI)/libbass.so
LOCAL_EXPORT_C_INCLUDES := /cygdrive/D/Coding/Android/AndroidMediaPlayer/jni/includes // << is this ok? or should it be only "includes"?
include $(PREBUILT_SHARED_LIBRARY)

# Default
# ========================================================
include $(CLEAR_VARS)
LOCAL_MODULE := AndroidMediaPlayer
#LOCAL_STATIC_LIBRARIES := temp
LOCAL_SHARED_LIBRARIES := bass
LOCAL_SRC_FILES := mp_lib.c mp_log.c mp_resource.c mp_library.c mp_local_player.c AndroidMediaPlayer.c
LOCAL_C_INCLUDES := mp_lib.h mp_log.h mp_library.h mp_resource.h mp_local_player.h includes/bass.h
LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog
include $(BUILD_SHARED_LIBRARY)

My app crashes without any BASS code. So what's wrong there?

Thank you! Smiley
Logged
Medvedev S
Posts: 1


« Reply #92 on: 14 Mar '12 - 17:39 »
Reply with quoteQuote

Good time of the day! I have the following question. We want to use your library in our application, this appliction will be distributed free of charge, however donations are welcome if the application is liked. Shall such application distribution be considered as commercial or is it non-commercial use still?
Logged
Ian @ un4seen
Administrator
Posts: 15275


« Reply #93 on: 14 Mar '12 - 18:01 »
Reply with quoteQuote

I have some problems to include the libbass.so to my native project. My android project compiles well, but when i start my app on my phone it crashes with the following error:

That looks similar to the problem bjadams had earlier in this thread. Using libraries in native code seems to be tricky because the app's "lib" folder is not in the system's library search path (so it can't find the libraries in there). I think there may be 2 possible solutions: have Java load the BASS library before your library that depends on it is loaded, or load the BASS library dynamically as suggested in this post...

   www.un4seen.com/forum/?topic=13225.msg92467#msg92467

Let me know how you get on.

Good time of the day! I have the following question. We want to use your library in our application, this appliction will be distributed free of charge, however donations are welcome if the application is liked. Shall such application distribution be considered as commercial or is it non-commercial use still?

Are you creating the app yourself as an individual, or are you working for a company? If you are an individual, and the donations don't buy the user any privileges (extra features/support/etc) and the donations aren't requested within the app itself (eg. they could be on your website), then that will be OK without a licence. If donations are requested within the app and/or do buy privileges, then a Shareware licence would generally cover it. If you are a company, then a Commercial licence would usually be required to use BASS in an app, even if you are not charging for it.
Logged
AndroidMediaPlayer
Guest
« Reply #94 on: 14 Mar '12 - 22:30 »
Reply with quoteQuote

Ok, the dlopen method works fine, but only for libbass.so, not for the extensions?

void *mp_libbass = NULL;
#define LOADBASSFUNCTION(f) *((void**)&f)=dlsym(mp_libbass, #f)

void *mp_libbassflac = NULL;
#define LOADBASSFLACFUNCTION(f) *((void**)&f)=dlsym(mp_libbassflac, #f)

#include "includes/bass.h"
#include "includes/bassflac.h"

...

mp_libbass = dlopen("/data/data/com.android.mediaplayer/lib/libbass.so", RTLD_LAZY);
if(mp_libbass == NULL) {
mp_log_error("Error loading libbass.so");
exit(1);
} else {
mp_log_info("libbass.so loaded...");
}

mp_libbassflac = dlopen("/data/data/com.android.mediaplayer/lib/libbassflac.so", RTLD_LAZY);
if(mp_libbassflac == NULL) {
mp_log_error("Error loading libbassflac.so");
exit(1);
} else {
mp_log_info("libbassflac.so loaded...");
}

Both libs get loaded. But when i call:

LOADBASSFLACFUNCTION(BASS_FLAC_StreamCreateFile);

i got a compile error:

SharedLibrary  : libAndroidMediaPlayer.so
./obj/local/armeabi/objs/AndroidMediaPlayer/mp_local_player.o: In function `mp_local_player_init':
D:\Coding\Android\AndroidMediaPlayer/jni/mp_local_player.c:80: undefined reference to `BASS_FLAC_StreamCreateFile'
collect2: ld returned 1 exit status
/cygdrive/D/Coding/Tools/android-ndk-r7b/build/core/build-binary.mk:314: recipe for target `obj/local/armeabi/libAndroidMediaPlayer.so' failed
make: *** [obj/local/armeabi/libAndroidMediaPlayer.so] Error 1

So what's wrong here?
Logged
AndroidMediaPlayer
Guest
« Reply #95 on: 15 Mar '12 - 02:10 »
Reply with quoteQuote

Ach, works fine now. Have forgot to define BASSFLACDEV. Smiley
Logged
Ian @ un4seen
Administrator
Posts: 15275


« Reply #96 on: 15 Mar '12 - 13:49 »
Reply with quoteQuote

Good to hear you have got things working. Regarding using add-ons like BASSFLAC, a simpler way to use them is via the plugin system. For example, you could do this...

BASS_PluginLoad("/data/data/com.android.mediaplayer/lib/libbassflac.so", 0);

When an add-on is loaded that way, support for its file formats is added to the standard BASS functions, eg. BASS_StreamCreateFile.
Logged
AndroidMediaPlayer
Guest
« Reply #97 on: 15 Mar '12 - 18:10 »
Reply with quoteQuote

Good to hear you have got things working. Regarding using add-ons like BASSFLAC, a simpler way to use them is via the plugin system. For example, you could do this...

BASS_PluginLoad("/data/data/com.android.mediaplayer/lib/libbassflac.so", 0);

When an add-on is loaded that way, support for its file formats is added to the standard BASS functions, eg. BASS_StreamCreateFile.
Och, works great! Thanx, my player works fine now. Smiley

But now i have a last little question. You have written on the first page that we shall increase the BASS_CONFIG_DEV_BUFFER if we get stuttering output. My player stutters a wee bit, especially if i go back to the home screen, switch the homescreens, call an other application, the screen shuts off ....

I have tried to increease it, but it had no effect to this behavior?

BASS_SetConfig(BASS_CONFIG_DEV_BUFFER, 250); << This ok so?

I also have a great device, a 1,2GHz Dualcore and 1GB Ram. Are there more configs i can try?

Thank you! Smiley
Logged
Ian @ un4seen
Administrator
Posts: 15275


« Reply #98 on: 16 Mar '12 - 15:18 »
Reply with quoteQuote

Are you adjusting the BASS_CONFIG_DEV_BUFFER setting before you call BASS_Init? Doing that should help avoid stuttering, if the stuttering is a result of BASS getting starved of CPU. Another possibility is that the audio system/driver is getting starved of CPU and/or interrupted. To check whether that may be the case, are other audio players affected too?
Logged
AndroidMediaPlayer
Guest
« Reply #99 on: 16 Mar '12 - 21:14 »
Reply with quoteQuote

Hm, i had some problems using JNI Callbacks. After solving them my player works fine now without any stuttering. Seems that this was the problem... Smiley
Logged
Pages: 1 ... 3 4 [5] 6 7 ... 18
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines