Author Topic: BASS for Android  (Read 390248 times)

Mr.Green2

  • Guest
Re: BASS for Android
« Reply #150 on: 9 May '12 - 00:22 »
Where can I read about new features and bug fixes in new release?

Ian @ un4seen

  • Administrator
  • Posts: 20393
Re: BASS for Android
« Reply #151 on: 9 May '12 - 17:12 »
A changelog can be found in the "History" section of the text file (eg. BASS.TXT) included in the packages on the BASS webpage. That is also included in the documentation, which can be viewed online here:

   www.un4seen.com/doc/

rai2270

  • Posts: 5
Re: BASS for Android
« Reply #152 on: 10 May '12 - 21:56 »
Hi. Is there example how to use the ByteBuffer return from BASS.BASS_ChannelGetData to display the spectrum of the sound?
I'm trying to create spectrum analyzer and will post the source code after that.
Thanks.

Ian @ un4seen

  • Administrator
  • Posts: 20393
Re: BASS for Android
« Reply #153 on: 11 May '12 - 16:23 »
The ByteBuffer stuff could look something like this...

Code: [Select]
ByteBuffer bbuf=ByteBuffer.allocateDirect(1024*4); // allocate a buffer for the FFT data
bbuf.order(null); // little-endian byte order
BASS.BASS_ChannelGetData(handle, bbuf, BASS.BASS_DATA_FFT2048); // get the FFT data
int[] fft=new int[1024]; // allocate an "int" array for the FFT data
bbuf.asIntBuffer().get(fft); // get the data from the buffer into the array
// do something with the FFT data...

There isn't currently an Android version of the SPECTRUM example, but you could have a look at that example for the other platforms for some general ideas of what to do with the FFT data. Note that the data is in 8.24 fixed-point form on Android, hence "int" rather than "float", and 0x1000000 (1<<24) is equivalent to 1.0.

rai2270

  • Posts: 5
Re: BASS for Android
« Reply #154 on: 12 May '12 - 05:21 »
Do you have a link to someone that implement the fft data in a graphic way? Thanks.

Slava

  • Guest
Re: BASS for Android
« Reply #155 on: 14 May '12 - 14:11 »
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);


Is there a way to do the same in C++ not making any java calls from the user's code? :)

Ian @ un4seen

  • Administrator
  • Posts: 20393
Re: BASS for Android
« Reply #156 on: 14 May '12 - 15:43 »
Do you have a link to someone that implement the fft data in a graphic way? Thanks.

I don't think there is any such example for Android at the moment, but you could have a look at the SPECTRUM example on the other platforms for some ideas.

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);

Is there a way to do the same in C++ not making any java calls from the user's code? :)

I'm not certain, but I don't think it will be possible to use the "BASS.Asset" Java class in a native app. I'm not sure if it is even possible to use assets in a native app, as an AssetManager instance (which the "getAssets" call above provides) is required, but if it is possible, you could load the asset to memory and then pass it to BASS_StreamCreateFile (with mem=TRUE).

Slava

  • Guest
Re: BASS for Android
« Reply #157 on: 14 May '12 - 22:04 »

I'm not certain, but I don't think it will be possible to use the "BASS.Asset" Java class in a native app. I'm not sure if it is even possible to use assets in a native app, as an AssetManager instance (which the "getAssets" call above provides) is required, but if it is possible, you could load the asset to memory and then pass it to BASS_StreamCreateFile (with mem=TRUE).

Well, actually some examples could be found e.g. in SDL-1.3 source, where there're tricks such as accessing AssetManager or other Java classes through jni.
Also there's a number of tricks for getting the descriptor of the asset file and the position and size of a particular asset in the code which could be useful, provided it is not really compressed in the apk.

I'll try the mem=true way then :)

toob

  • Posts: 133
Re: BASS for Android
« Reply #158 on: 17 May '12 - 14:58 »
Hi,

I've got a problem with the latest version of bass_fx.

I wanted the latest bass cause i wanted to use the new BASS.Asset(getAssets() feature which works fine. However I can no longer use bass_fx without an error even after downloading the lastest bass_fx,

I have opened the new bass_fx.java and can see the new stuff when comparing it to my previous version.
If I revert both bass and bass_fx then the errors go away but of course I cannot use BASS.Asset(getAssets().

The error in logcat is:
05-17 14:41:49.033: E/AndroidRuntime(28930): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load bass_fx: findLibrary returned null

I have not changed my calling code, but here my reverse play:
Code: [Select]
//reverse
if (Style==3){

BASS.BASS_ChannelRemoveFX(stream1, fxHandle);
BASS.BASS_StreamFree(stream1);

        if ((stream1=BASS.BASS_StreamCreateFile(quizstart.Tracks.get(CurrentQ).path, 0, 0, BASS.BASS_STREAM_DECODE|BASS.BASS_STREAM_PRESCAN))==0) {
Error("Can't play the file");
sb.setMax(0);
return;
}

        stream1 = BASS_FX.BASS_FX_ReverseCreate(stream1, 2f, BASS_FX.BASS_FX_FREESOURCE);
        BASS.BASS_ChannelSetAttribute(stream1,  BASS_FX.BASS_ATTRIB_REVERSE_DIR, -1f);

            long len = BASS.BASS_ChannelGetLength(stream1, BASS.BASS_POS_BYTE);
        BASS.BASS_ChannelSetPosition(stream1, (len/3), BASS.BASS_POS_BYTE);
        BASS.BASS_ChannelPlay(stream1, false);

int sometime=10;
sometime=Integer.parseInt(quizmain.ListPreference);

sb.setMax(sometime * 1000);
quiztime =0;
StopQuizTimerThread=false;
questionhandler.postDelayed(r, 100);

return;
} //reverse


Ian @ un4seen

  • Administrator
  • Posts: 20393
Re: BASS for Android
« Reply #159 on: 17 May '12 - 15:42 »
I just checked, and it seemed to be fine, ie. BASS_FX was loaded and the reverse processing applied, so that's strange. After replacing the SO and/or Java files, be sure to "Refresh" the corresponding project branch in Eclipse. If it's still not working after that, please confirm the date and size of the SO files in your app's APK file (it's a ZIP file). Also confirm which line the error message is appearing at; I guess it's the BASS_FX_ReverseCreate call?

toob

  • Posts: 133
Re: BASS for Android
« Reply #160 on: 17 May '12 - 18:37 »
I just checked, and it seemed to be fine, ie. BASS_FX was loaded and the reverse processing applied, so that's strange. After replacing the SO and/or Java files, be sure to "Refresh" the corresponding project branch in Eclipse. If it's still not working after that, please confirm the date and size of the SO files in your app's APK file (it's a ZIP file). Also confirm which line the error message is appearing at; I guess it's the BASS_FX_ReverseCreate call?

Thanks Ian for confirming it works ok your end.

Allthough "libbass_fx.so" in  my eclipse libs tree "armeabi" and "armeabi-v7a" were showing fine with no errors when I clicked on properties they showed as missing. Copied them from bass_fx zip folder and it's now sorted.
Was sure I checked everything!  ???

thanks for the quick response and the updates.

rai2270

  • Posts: 5
Re: BASS for Android
« Reply #161 on: 17 May '12 - 22:14 »
Hi,
I'm reading from the Music folder and making sure each file can be play by BASS. So I'm checking extensions like : ".mp3", ".mid", ".wav", ".ogg", ".mp4" .
Does anyone already prepared a list  of all the types BASS can play?
Thanks.

Ian @ un4seen

  • Administrator
  • Posts: 20393
Re: BASS for Android
« Reply #162 on: 18 May '12 - 14:56 »
BASS and the add-ons check the file content rather than the extension to determine whether a file is playable, so there is no real need to pre-check a file's extension. But if you would like to do that (eg. for a file selector), BASS itself supports OGG/MP3/MP2/MP1/WAV/AIFF files, and the add-on supported formats are available from BASS_PluginGetInfo. The Android version of the PLUGINS example doesn't filter its file lists (it uses a very basic file selector), but you could have a look at the Win32 or Linux versions for a demonstration of doing that.

Ian @ un4seen

  • Administrator
  • Posts: 20393
Re: BASS for Android
« Reply #163 on: 7 Jun '12 - 16:21 »
Updated BASS and BASSmix builds are up in the first post, including NEON-optimized sinc interpolation for a nice performance boost on NEON-supporting devices, which is most ARMv7 devices. The non-NEON code is also still included for devices that don't support NEON.

xStSx

  • Posts: 11
Re: BASS for Android
« Reply #164 on: 8 Jun '12 - 13:10 »
Hi.
I'm trying to write simple HelloWorld with Bass on Android (playing internet radio)

but I always receiving 0 from BASS_StreamCreateURL , and Error code 2 (ERROR_FILEOPEN) ,is there some trick ?

Code: [Select]
static final String url = "http://webcast.emg.fm:55655/europaplus128.mp3";
...
BASS.BASS_Init(-1, 44100, 0);
BASS.BASS_SetConfigPtr(BASS.BASS_CONFIG_NET_AGENT, "Mozilla/5.0 (Windows NT 6.0; WOW64) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.45 Safari/535.19"); //needed for this specific stream

chan = BASS.BASS_StreamCreateURL(url, 0, BASS.BASS_STREAM_BLOCK|BASS.BASS_STREAM_AUTOFREE, null, null);
...
BASS.BASS_ChannelPlay(chan, false);

same code in C/Linux working fine.
Thanks. Stas.

Android 2.3.3
debuging on phone.
« Last Edit: 8 Jun '12 - 13:14 by xStSx »

Ian @ un4seen

  • Administrator
  • Posts: 20393
Re: BASS for Android
« Reply #165 on: 8 Jun '12 - 16:30 »
BASS_ERROR_FILEOPEN indicates that BASS_StreamCreateURL was unable to open the URL, eg. it couldn't connect to the server or the file doesn't exist on the server. Please try to play the same URL with the NETRADIO example (add your BASS_CONFIG_NET_AGENT setting if required), and check if it displays a "HTTP" status code. Also check whether the example presets are working. If no URLs are working, are you able to play them with any other software on the same device?

xStSx

  • Posts: 11
Re: BASS for Android
« Reply #166 on: 8 Jun '12 - 16:47 »
BASS_ERROR_FILEOPEN indicates that BASS_StreamCreateURL was unable to open the URL, eg. it couldn't connect to the server or the file doesn't exist on the server. Please try to play the same URL with the NETRADIO example (add your BASS_CONFIG_NET_AGENT setting if required), and check if it displays a "HTTP" status code. Also check whether the example presets are working. If no URLs are working, are you able to play them with any other software on the same device?

Yes , Ian , the URL is alive , and working with other applications on Android ,as well on PC.

About Netradio examp . I'm just started with Android/Java/Eclipse , I didn't figure out how to open it in Eclipse  ;D , so I just started a new Android project (the libs and BASS.java are in correct place . BASS.BASS_GetVersion() working and BASS.BASS_Init(...) as well).

Does BASS.BASS_StreamCreateURL accept URL in UTF-8 encodings ? , or it has to be converted to ISO-8859-1 ?
Or to make whole project in ISO-8859-1..
Thank you.
Stas.

Ian @ un4seen

  • Administrator
  • Posts: 20393
Re: BASS for Android
« Reply #167 on: 8 Jun '12 - 17:52 »
To play with the NETRADIO example, you can use the "New > Android Project > Create project from existing source" option to create a project for it in Eclipse. Also 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 NETRADIO example's folder.

After adding your BASS_CONFIG_NET_AGENT setting to the NETRADIO example, I was able to play your URL with it. If it still isn't working there, are other URLs working, eg. the example presets? If none are working, do you know if the other software that you tried is connecting via a proxy? If it is, you can try telling the NETRADIO example to use that too (in the box at the bottom of the display).

xStSx

  • Posts: 11
Re: BASS for Android
« Reply #168 on: 8 Jun '12 - 19:08 »
To play with the NETRADIO example, you can use the "New > Android Project > Create project from existing source" option to create a project for it in Eclipse. Also 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 NETRADIO example's folder.

After adding your BASS_CONFIG_NET_AGENT setting to the NETRADIO example, I was able to play your URL with it. If it still isn't working there, are other URLs working, eg. the example presets? If none are working, do you know if the other software that you tried is connecting via a proxy? If it is, you can try telling the NETRADIO example to use that too (in the box at the bottom of the display).

You are magician  :D . Yesterday I tried excatly same thing on Linux.. it gived me again and again same error(Eclipse Error) .
Now I tried on Windows , everything works , my URL , and all the rest presets.
Thanks for repeating the explanation , this time it works.

I will try to figure out why my code didn't worked.
Thank you again Ian.


Ian @ un4seen

  • Administrator
  • Posts: 20393
Re: BASS for Android
« Reply #169 on: 11 Jun '12 - 15:36 »
Another NEON optimized BASS update is up in the first post, this time giving the MP3 decoder a performance boost.

elimmedia

  • Posts: 11
Re: BASS for Android
« Reply #170 on: 19 Jun '12 - 02:58 »
Hello Ian,

This is Elim Media from Korea.

I have found that BASS_MIDI_StreamCreateEvents function is missing on Android platform.

Could you please let us know when it would be available,

any other way around to play an array of midi events( sequence) ?

Thank you in advance.

elimmedia

  • Posts: 11
Re: BASS for Android
« Reply #171 on: 19 Jun '12 - 07:46 »
I have stuttering output problem on LG Optimus Lte 2 ( Android platform) model.

What I found so far is below.

1. Using Default Sound output ( OpenSL) :

- Init BASS as "BASS.BASS_Init(-1, 44100, 0)" and output is stuttering.

- Tried changing BASS_CONFIG_DEV_BUFFER size and all possible buffer size, same result

2. Using No Sound :

- Init BASS as "BASS.BASS_Init(0, 44100, 0))", set AudioTrack minBufferSize to the value from "AudioTrack.getMinBufferSize" and output is stuttering, minBufferSize was 3760,

- set minBufferSize double of the value (3760*2) and output is OK.

* What i found is that OpenSLES is implemented on top of AudioTrack ( http://connect.creativelabs.com/developer/SoundFont/sfspec21.pdf).
I am guessing that LG Developer sets too small buffer size on AudioTrack, so that even output from OpenSL gets stuttering.

* I cannot just use AudioTrack, because there are so many drawings and calculation beside playing sounds and using AudioTrack affects drawing time.

Anyone have any idea for this issue?

ps. sorry for my english :(

Ian @ un4seen

  • Administrator
  • Posts: 20393
Re: BASS for Android
« Reply #172 on: 19 Jun '12 - 16:30 »
I have found that BASS_MIDI_StreamCreateEvents function is missing on Android platform.

Could you please let us know when it would be available,

The next BASSMIDI release, including that new function, should be available shortly. In the meantime, I have put the latest stuff (including the function) up in the package in the first post. I have also put up provisional documentation for the function here:

   www.un4seen.com/doc/bassmidi/BASS_MIDI_StreamCreateEvents.html

I have stuttering output problem on LG Optimus Lte 2 ( Android platform) model.

What I found so far is below.

1. Using Default Sound output ( OpenSL) :

- Init BASS as "BASS.BASS_Init(-1, 44100, 0)" and output is stuttering.

- Tried changing BASS_CONFIG_DEV_BUFFER size and all possible buffer size, same result

Did you set the BASS_CONFIG_DEV_BUFFER value (via BASS_SetConfig) before you made the BASS_Init call? If not, please try that, as changes will not affect an already initialized device. Also, do you get the stuttering with everything that you try to play, including PCM WAV files?

elimmedia-shin

  • Guest
Re: BASS for Android
« Reply #173 on: 20 Jun '12 - 02:24 »
I have found that BASS_MIDI_StreamCreateEvents function is missing on Android platform.

Could you please let us know when it would be available,

The next BASSMIDI release, including that new function, should be available shortly. In the meantime, I have put the latest stuff (including the function) up in the package in the first post. I have also put up provisional documentation for the function here:

   www.un4seen.com/doc/bassmidi/BASS_MIDI_StreamCreateEvents.html

I have stuttering output problem on LG Optimus Lte 2 ( Android platform) model.

What I found so far is below.

1. Using Default Sound output ( OpenSL) :

- Init BASS as "BASS.BASS_Init(-1, 44100, 0)" and output is stuttering.

- Tried changing BASS_CONFIG_DEV_BUFFER size and all possible buffer size, same result

Did you set the BASS_CONFIG_DEV_BUFFER value (via BASS_SetConfig) before you made the BASS_Init call? If not, please try that, as changes will not affect an already initialized device. Also, do you get the stuttering with everything that you try to play, including PCM WAV files?
I have found that BASS_MIDI_StreamCreateEvents function is missing on Android platform.

Could you please let us know when it would be available,

The next BASSMIDI release, including that new function, should be available shortly. In the meantime, I have put the latest stuff (including the function) up in the package in the first post. I have also put up provisional documentation for the function here:

   www.un4seen.com/doc/bassmidi/BASS_MIDI_StreamCreateEvents.html

I have stuttering output problem on LG Optimus Lte 2 ( Android platform) model.

What I found so far is below.

1. Using Default Sound output ( OpenSL) :

- Init BASS as "BASS.BASS_Init(-1, 44100, 0)" and output is stuttering.

- Tried changing BASS_CONFIG_DEV_BUFFER size and all possible buffer size, same result

Did you set the BASS_CONFIG_DEV_BUFFER value (via BASS_SetConfig) before you made the BASS_Init call? If not, please try that, as changes will not affect an already initialized device. Also, do you get the stuttering with everything that you try to play, including PCM WAV files?

I have tried changing BASS_CONFIG_DEV_BUFFER value  before BASS_Init call and still sturrering, and haven't tried PCM WAV files, (we are using AAC)
I will try using PCM WAV and let you know the result shortly.

I really appreciate for your quick response.

elimmedia

  • Posts: 11
Re: BASS for Android
« Reply #174 on: 29 Jun '12 - 03:36 »
Hi Ian,

I have a question regarding BASSMIDI,

I have created Events and init with  BASS_MIDI_StreamCreateEvents.

let's say that i have midi data with two channel.

if events has only one channel, it works fine, but if i merge both of channel,i got an error.

I also got the same error with one channel.

Any idea?

ps. I have found that I cannot create streamEvents if number of events exceed 250



06-29 11:27:54.754: E/dalvikvm(26242): JNI ERROR (app bug): local reference table overflow (max=512)
06-29 11:27:54.754: W/dalvikvm(26242): JNI local reference table (0x16a3d70) dump:
06-29 11:27:54.754: W/dalvikvm(26242):   Last 10 entries (of 512):
06-29 11:27:54.754: W/dalvikvm(26242):       511: 0x414f56a0 java.lang.Class<com.un4seen.bass.BASSMIDI$BASS_MIDI_EVENT>
06-29 11:27:54.754: W/dalvikvm(26242):       510: 0x414fb8d0 com.un4seen.bass.BASSMIDI$BASS_MIDI_EVENT
06-29 11:27:54.754: W/dalvikvm(26242):       509: 0x414f56a0 java.lang.Class<com.un4seen.bass.BASSMIDI$BASS_MIDI_EVENT>
06-29 11:27:54.754: W/dalvikvm(26242):       508: 0x414fb808 com.un4seen.bass.BASSMIDI$BASS_MIDI_EVENT
06-29 11:27:54.754: W/dalvikvm(26242):       507: 0x414f56a0 java.lang.Class<com.un4seen.bass.BASSMIDI$BASS_MIDI_EVENT>
06-29 11:27:54.754: W/dalvikvm(26242):       506: 0x414fb8b0 com.un4seen.bass.BASSMIDI$BASS_MIDI_EVENT
06-29 11:27:54.754: W/dalvikvm(26242):       505: 0x414f56a0 java.lang.Class<com.un4seen.bass.BASSMIDI$BASS_MIDI_EVENT>
06-29 11:27:54.754: W/dalvikvm(26242):       504: 0x414fb7e8 com.un4seen.bass.BASSMIDI$BASS_MIDI_EVENT
06-29 11:27:54.754: W/dalvikvm(26242):       503: 0x414f56a0 java.lang.Class<com.un4seen.bass.BASSMIDI$BASS_MIDI_EVENT>
06-29 11:27:54.754: W/dalvikvm(26242):       502: 0x414fb720 com.un4seen.bass.BASSMIDI$BASS_MIDI_EVENT
06-29 11:27:54.754: W/dalvikvm(26242):   Summary:
06-29 11:27:54.754: W/dalvikvm(26242):       256 of java.lang.Class (5 unique instances)
06-29 11:27:54.754: W/dalvikvm(26242):         2 of java.lang.String (2 unique instances)
06-29 11:27:54.754: W/dalvikvm(26242):         1 of java.lang.String[] (2 elements)
06-29 11:27:54.754: W/dalvikvm(26242):       252 of com.un4seen.bass.BASSMIDI$BASS_MIDI_EVENT (252 unique instances)
06-29 11:27:54.754: W/dalvikvm(26242):         1 of com.un4seen.bass.BASSMIDI$BASS_MIDI_EVENT[] (281 elements)
06-29 11:27:54.757: E/dalvikvm(26242): Failed adding to JNI local ref table (has 512 entries)
« Last Edit: 29 Jun '12 - 03:58 by elimmedia »