|
Ian @ un4seen
Administrator
Posts: 15253
|
 |
« Reply #40 on: 28 Dec '11 - 18:15 » |
Quote
|
There are plans for an Android version of BASS_FX, but it's at an early stage, so it's hard to say when it may become available at this point.
|
|
|
|
|
Logged
|
|
|
|
|
Mike
Posts: 3
|
 |
« Reply #41 on: 28 Dec '11 - 19:29 » |
Quote
|
This may be a daft question because I'm a newbie to Java, Android and Eclipse (I come from a C++/VS background), but I'm having difficulty getting the BASS MIDI test app to link against the libraries. I've copied the libs folder into the miditest folder (i.e. alongside assets, bin etc.), which I believe to be correct, but as soon as the app tries to call BASS.BASS_Init(-1, 44100, 0), it throws an 'UnsatisfiedLinkError' exception and dies.
In case it's of any relevance, I'm trying to run the app on the Samsung Galaxy Tab.
Any help or suggestions greatly appreciated!
Michael
P.S. My stupid mistake, which I pretty much expected would be the case! I'd somehow managed to stomp over the BASS .so files with the BASS MIDI ones, so they went missing from the libs folder.
|
|
|
|
« Last Edit: 29 Dec '11 - 16:54 by Mike »
|
Logged
|
|
|
|
|
Ian @ un4seen
Administrator
Posts: 15253
|
 |
« Reply #42 on: 29 Dec '11 - 16:54 » |
Quote
|
That looks like the BASS library is missing from the "libs" folder. Did you copy the contents of both the root and BASSMIDI "libs" folders into your "libs" folder? The folder's contents should look like this...
armeabi libbass.so libbassmidi.so armeabi-v7a libbass.so libbassmidi.so
Note after making a change to the "libs" folder, you may need to "Refresh" it in Eclipse.
|
|
|
|
|
Logged
|
|
|
|
|
helri
Posts: 10
|
 |
« Reply #43 on: 2 Jan '12 - 18:06 » |
Quote
|
Hi,
I'm using BASS for android and it's working perfectly in an Android device with API version 2.3.1.
But, in a device using 2.1 version i'm getting an error calling the method BASS.BASS_Init(-1, 44100, 0). The error is 39 which I think means BASS_ERROR_DX.
How can I bypass this error? should I use any flags in BASS_init? I only need audio, don't need any video capabilities, at least for now.
Thank you and good work!
|
|
|
|
|
Logged
|
|
|
|
|
Ian @ un4seen
Administrator
Posts: 15253
|
 |
« Reply #44 on: 3 Jan '12 - 15:16 » |
Quote
|
On the Android platform, the BASS_ERROR_DX error code indicates that OpenSL ES is unavailable, which is the native audio API that BASS uses (like DirectSound on Windows). Unfortunately, it was only introduced in Android 2.3, so playback/recording isn't supported with earlier Android versions. The "no sound" device is still available though, so it is possible to use "decoding channels" with that, eg. they could be fed into the older AudioTrack system.
|
|
|
|
|
Logged
|
|
|
|
|
helri
Posts: 10
|
 |
« Reply #45 on: 3 Jan '12 - 15:29 » |
Quote
|
On the Android platform, the BASS_ERROR_DX error code indicates that OpenSL ES is unavailable, which is the native audio API that BASS uses (like DirectSound on Windows). Unfortunately, it was only introduced in Android 2.3, so playback/recording isn't supported with earlier Android versions. The "no sound" device is still available though, so it is possible to use "decoding channels" with that, eg. they could be fed into the older AudioTrack system.
Thank you Ian. It seems trickier then  Let me see if I understood correctly: - I should use BASS_Init with device 0. - then in the BASS_StreamCreateURL (which i'm using to play the track in 2.3) I use the flag BASS_STREAM_DECODE - then I should pass the decoded bytes to AudioTrack? To access to the decoded bytes from BASS should I use SYNCPROC? Thank you!
|
|
|
|
« Last Edit: 3 Jan '12 - 15:34 by helri »
|
Logged
|
|
|
|
|
Ian @ un4seen
Administrator
Posts: 15253
|
 |
« Reply #46 on: 3 Jan '12 - 15:49 » |
Quote
|
That is pretty much the right idea, but to access the decoded data, you would use BASS_ChannelGetData rather than a SYNCPROC. The code might look something like this... BASS.BASS_Init(0, 44100, 0); // initialize "no sound" device decoder=BASS.BASS_StreamCreateURL(url, 0, BASS.BASS_STREAM_DECODE, null, null); // create a "decoding channel" from a URL buffer=ByteBuffer.allocate(20000); // allocate buffer for decoded data
...
int res=BASS.BASS_ChannelGetData(decoder, buffer, buffer.capacity()); // decode some data if (res>0) audiotrack.write(buffer.array(), 0, res); // feed it to AudioTrack
You can use BASS_ChannelGetInfo to get the stream's sample format to initialize the AudioTrack output with.
|
|
|
|
|
Logged
|
|
|
|
|
helri
Posts: 10
|
 |
« Reply #47 on: 3 Jan '12 - 16:10 » |
Quote
|
That is pretty much the right idea, but to access the decoded data, you would use BASS_ChannelGetData rather than a SYNCPROC. The code might look something like this... BASS.BASS_Init(0, 44100, 0); // initialize "no sound" device decoder=BASS.BASS_StreamCreateURL(url, 0, BASS.BASS_STREAM_DECODE, null, null); // create a "decoding channel" from a URL buffer=ByteBuffer.allocate(20000); // allocate buffer for decoded data
...
int res=BASS.BASS_ChannelGetData(decoder, buffer, buffer.capacity()); // decode some data if (res>0) audiotrack.write(buffer.array(), 0, res); // feed it to AudioTrack
You can use BASS_ChannelGetInfo to get the stream's sample format to initialize the AudioTrack output with. Thank you! I'm working on it!
|
|
|
|
|
Logged
|
|
|
|
|
helri
Posts: 10
|
 |
« Reply #48 on: 3 Jan '12 - 16:24 » |
Quote
|
Ian, it is working but only for a few seconds. The music starts playing but after some seconds the app crashes with a SIGBUS in libbass.so: 01-03 16:19:55.304: I/DEBUG(25736): signal 7 (SIGBUS), fault addr 00000000 01-03 16:19:55.308: I/DEBUG(25736): scr 20000012 01-03 16:19:55.359: I/DEBUG(25736): #00 pc 0000adfc /data/data/com.example.miditest/lib/libbass.so 01-03 16:19:55.362: I/DEBUG(25736): #01 pc 00017f46 /data/data/com.example.miditest/lib/libbass.so 01-03 16:19:55.362: I/DEBUG(25736): #02 pc 00019260 /data/data/com.example.miditest/lib/libbass.so the code that i'm using is the following: chan=BASS.BASS_StreamCreateURL(url, 0, BASS.BASS_STREAM_DECODE, null, null) track = new AudioTrack( AudioManager.STREAM_MUSIC, 44100, AudioFormat.CHANNEL_CONFIGURATION_STEREO, AudioFormat.ENCODING_PCM_16BIT, AudioTrack.getMinBufferSize(44100, AudioFormat.CHANNEL_CONFIGURATION_STEREO, AudioFormat.ENCODING_PCM_16BIT), AudioTrack.MODE_STREAM); track.play(); new Thread(new Runnable(){ public void run() { ByteBuffer buffer = ByteBuffer.allocate(20000); // allocate buffer for decoded data int res=BASS.BASS_ChannelGetData(chan, buffer, buffer.capacity()); // decode some data while (res>0){ track.write(buffer.array(), 0, res); // feed it to AudioTrack res=BASS.BASS_ChannelGetData(chan, buffer, buffer.capacity()); // decode some data } } }).start();
The idea with the thread is to feed the audioTrack while there's data to decode... do you have any idea why i'm getting the SIGBUS error inside libbass.so?
|
|
|
|
« Last Edit: 4 Jan '12 - 12:31 by helri »
|
Logged
|
|
|
|
|
Ian @ un4seen
Administrator
Posts: 15253
|
 |
« Reply #49 on: 4 Jan '12 - 14:13 » |
Quote
|
That's strange; I gave your code a try, and it seems to be working fine. Is the crash happening with a particular URL, and is it happening in the BASS_ChannelGetData call or is it in another thread? Perhaps your thread has already exited before the crash occurred? Note BASS_ChannelGetData won't wait for data to become available (it will return 0 if there is no data currently available), so your "while" loop could exit earlier than expected. To leave on an error, you could modify it like this... while (res!=-1){ if (res>0) track.write(buffer.array(), 0, res); // feed it to AudioTrack else Thread.sleep(50); // wait a bit for more data to arrive res=BASS.BASS_ChannelGetData(chan, buffer, buffer.capacity()); // decode some data }
|
|
|
|
|
Logged
|
|
|
|
|
helri
Posts: 10
|
 |
« Reply #50 on: 4 Jan '12 - 14:29 » |
Quote
|
Thank you Ian. I tried your code and I keep getting the same error (i'm testing in a Samsung Galaxy, SDK version 2.2 and in a Sony Ericsson Xperia, SDK version 2.3) This is my entire code, url included: String url= "http://ia700401.us.archive.org/33/items/another007/01-allthelivingandthedead-IntheMoon.ogg"; BASS.BASS_StreamFree(chan); // free old stream before opening new chan=BASS.BASS_StreamCreateURL(url, 0, BASS.BASS_STREAM_DECODE, null, null); track = new AudioTrack( AudioManager.STREAM_MUSIC, 44100, AudioFormat.CHANNEL_CONFIGURATION_STEREO, AudioFormat.ENCODING_PCM_16BIT, AudioTrack.getMinBufferSize(44100, AudioFormat.CHANNEL_CONFIGURATION_STEREO, AudioFormat.ENCODING_PCM_16BIT), AudioTrack.MODE_STREAM); track.play(); new Thread(new Runnable(){ public void run() { ByteBuffer buffer = ByteBuffer.allocate(20000); // allocate buffer for decoded data int res=BASS.BASS_ChannelGetData(chan, buffer, buffer.capacity()); // decode some data while (res!=-1){ if (res>0) track.write(buffer.array(), 0, res); // feed it to AudioTrack else try { Thread.sleep(50); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } // wait a bit for more data to arrive res=BASS.BASS_ChannelGetData(chan, buffer, buffer.capacity()); // decode some data }
Log.e("MidiTest", "finished"); } }).start(); note that Log.e("MidiTest", "finished"); is never called nor the thread is interrupted. The error occurs calling BASS.BASS_ChannelGetData(chan, buffer, buffer.capacity()); inside the loop. That thread you see in the code is the only explicit thread i'm using. I'm using the MidiTest modified with that code. If you want I can send you the .apk or even the source code. It's weird that SIGBUS error happening... Thank you.
|
|
|
|
« Last Edit: 4 Jan '12 - 15:11 by helri »
|
Logged
|
|
|
|
|
Ian @ un4seen
Administrator
Posts: 15253
|
 |
« Reply #51 on: 4 Jan '12 - 16:50 » |
Quote
|
Ah yes, I can reproduce the problem too with your test URL. It's actually crashing in the download thread rather than the BASS_ChannelGetData call. Once an OGG download is finished, BASS will look at the downloaded data to get the decoded length, and there was a memory alignment issue in that (ARM is fussy about alignment). An update to fix that is up now in the 1st post. Let me know if you have any more trouble with it.
|
|
|
|
|
Logged
|
|
|
|
|
helri
Posts: 10
|
 |
« Reply #52 on: 4 Jan '12 - 17:30 » |
Quote
|
Great! it's working!
Thank you Ian!
|
|
|
|
|
Logged
|
|
|
|
|
helri
Posts: 10
|
 |
« Reply #53 on: 6 Jan '12 - 09:39 » |
Quote
|
Ian, I keep noticing some glitches when playing the song, looks like either the write of bytes to the AudioTrack isn't fast enough or the decoding is leaving some "blanks" in the song. I changed the code a bit so I could write some bytes before starting the audioTrack but I still get a lot of glitches (like when someone scratches a disc). It seems rather deterministic, the glitches happen with some frequency...
Do you have any idea why this can be happening and ways to improve this (I need to use AudioTrack to support older versions of Android)?
thank you!
|
|
|
|
« Last Edit: 6 Jan '12 - 09:50 by helri »
|
Logged
|
|
|
|
|
Ian @ un4seen
Administrator
Posts: 15253
|
 |
« Reply #54 on: 6 Jan '12 - 15:27 » |
Quote
|
What number are you getting from the "AudioTrack.getMinBufferSize" call? Perhaps that isn't large enough; the documentation states "Note that this size doesn't guarantee a smooth playback". You could try increasing it and see if that helps.
|
|
|
|
|
Logged
|
|
|
|
|
Brannon
Posts: 16
|
 |
« Reply #55 on: 8 Jan '12 - 05:09 » |
Quote
|
Can you explain your fixed-point format a little more? Are you using ones or twos compliment? And that's only on the whole number portion? Or you're using a sign bit? Or it's unsigned or biased? Which byte is the high byte?
|
|
|
|
|
Logged
|
|
|
|
|
helri
Posts: 10
|
 |
« Reply #56 on: 9 Jan '12 - 14:38 » |
Quote
|
What number are you getting from the "AudioTrack.getMinBufferSize" call? Perhaps that isn't large enough; the documentation states "Note that this size doesn't guarantee a smooth playback". You could try increasing it and see if that helps.
8 yeah, that was the issue. I'm now passing getMinBufferSize*2 as buffer size and it's playing well. Thanks!
|
|
|
|
« Last Edit: 9 Jan '12 - 15:05 by helri »
|
Logged
|
|
|
|
|
Ian @ un4seen
Administrator
Posts: 15253
|
 |
« Reply #57 on: 9 Jan '12 - 14:47 » |
Quote
|
Can you explain your fixed-point format a little more? Are you using ones or twos compliment? And that's only on the whole number portion? Or you're using a sign bit? Or it's unsigned or biased? Which byte is the high byte?
The fixed-point sample data (and FFT data) is in native endian 8.24 fixed-point form, ie. 8 bits for the integer part and 24 bits for the fractional part. The relationship between fixed-point and floating-point is this: fixed=float*16777216.0 (or float=fixed/16777216.0) What number are you getting from the "AudioTrack.getMinBufferSize" call? Perhaps that isn't large enough; the documentation states "Note that this size doesn't guarantee a smooth playback". You could try increasing it and see if that helps.
yeah, that was the issue. I'm now passing 32678 as buffer size and it's playing very well. Jolly good 
|
|
|
|
|
Logged
|
|
|
|
|
helri
Posts: 10
|
 |
« Reply #58 on: 10 Jan '12 - 12:45 » |
Quote
|
Ian, I'm getting a segmentation fault after doing BASS_StreamCreateURL The use case where i'm getting this is the following: I play a song using the same process we talked above. After a little while I seek to the end of the song using setPosition. The seek is successful and audio track plays the song at that position. I let the song play until it finishes. As I have a SYNCPROC to be triggered at BASS_SYNC_END I start playing a new song from a new URL when the SYNCPROC method is called. I do BASS_StreamFree and then BASS_StreamCreateURL and then I set again BASS_ChannelSetSync to BASS_SYNC_END. Before even starting writing bytes to audiotrack using BASS_ChannelGetData I get the error below: 01-10 12:32:39.534: I/DEBUG(30369): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0404030b 01-10 12:32:39.534: I/DEBUG(30369): r0 00000001 r1 afd4734c r2 00000000 r3 00000001 01-10 12:32:39.534: I/DEBUG(30369): r4 00348fa0 r5 04040303 r6 00006f60 r7 80006f60 01-10 12:32:39.534: I/DEBUG(30369): r8 00000001 r9 00006f60 10 00018000 fp 00018000 01-10 12:32:39.534: I/DEBUG(30369): ip 00000000 sp 46e6c9d8 lr afd10e04 pc 80725f96 cpsr 20000030 01-10 12:32:39.534: I/DEBUG(30369): d0 0000000000000033 d1 002d003100300000 01-10 12:32:39.534: I/DEBUG(30369): d2 0031005400300039 d3 00320033003a0000 01-10 12:32:39.534: I/DEBUG(30369): d4 00690062006f006d d5 0061006d0065006c 01-10 12:32:39.534: I/DEBUG(30369): d6 002e006300690067 d7 00730075006d006e 01-10 12:32:39.534: I/DEBUG(30369): d8 405a61ad3f285eef d9 3ff0000000000000 01-10 12:32:39.534: I/DEBUG(30369): d10 3ff0000000000000 d11 0000000000000000 01-10 12:32:39.534: I/DEBUG(30369): d12 0000000000000000 d13 0000000000000000 01-10 12:32:39.534: I/DEBUG(30369): d14 0000000000000000 d15 0000000000000000 01-10 12:32:39.534: I/DEBUG(30369): d16 0000002740648668 d17 3ff0000000000000 01-10 12:32:39.534: I/DEBUG(30369): d18 3fe0000000000000 d19 4000000000000000 01-10 12:32:39.534: I/DEBUG(30369): d20 3ff0000000000000 d21 4197d78400000000 01-10 12:32:39.534: I/DEBUG(30369): d22 bf656ac020000000 d23 b5b5b5b5b5b5b5b5 01-10 12:32:39.534: I/DEBUG(30369): d24 e6e6e6e6e6e6e6e6 d25 e6e6e6e6e6e6e6e6 01-10 12:32:39.534: I/DEBUG(30369): d26 e6e6e6e6e6e6e6e6 d27 ffffffffffffffff 01-10 12:32:39.534: I/DEBUG(30369): d28 0100010001000100 d29 4042c055a0000000 01-10 12:32:39.534: I/DEBUG(30369): d30 4042c055a0000000 d31 3ff0000000000000 01-10 12:32:39.534: I/DEBUG(30369): scr 60000012 01-10 12:32:39.745: I/DEBUG(30369): #00 pc 00025f96 /data/data/com.example.miditest/lib/libbass.so 01-10 12:32:39.745: I/DEBUG(30369): #01 lr afd10e04 /system/lib/libc.so 01-10 12:32:39.745: I/DEBUG(30369): code around pc: 01-10 12:32:39.745: I/DEBUG(30369): 80725f74 bf0c0f00 f0022200 b16a0201 20009906 01-10 12:32:39.753: I/DEBUG(30369): 80725f84 2300e9d1 90004629 f7f14620 682dff51 01-10 12:32:39.753: I/DEBUG(30369): 80725f94 68abb1ad d0e42b00 bf142b02 f0082300 01-10 12:32:39.753: I/DEBUG(30369): 80725fa4 2b000301 9906d0f3 e9d1980b 46292300 01-10 12:32:39.753: I/DEBUG(30369): 80725fb4 46209000 ff3cf7f1 2d00682d f1b8d1e9 01-10 12:32:39.753: I/DEBUG(30369): code around lr: 01-10 12:32:39.753: I/DEBUG(30369): afd10de4 e20c1001 ebffffe8 e1a00005 e8bd8070 01-10 12:32:39.753: I/DEBUG(30369): afd10df4 e92d4070 e1a05000 e5904000 ebffeee1 01-10 12:32:39.753: I/DEBUG(30369): afd10e04 e2044a02 e3843001 e1500003 08bd8070 01-10 12:32:39.753: I/DEBUG(30369): afd10e14 e5854000 e1a00005 e1a01004 e3a02001 01-10 12:32:39.753: I/DEBUG(30369): afd10e24 e8bd4070 eaffffd8 e2502000 e92d40f0 01-10 12:32:39.753: I/DEBUG(30369): stack: 01-10 12:32:39.753: I/DEBUG(30369): 46e6c998 00018000 01-10 12:32:39.753: I/DEBUG(30369): 46e6c99c 80716517 /data/data/com.example.miditest/lib/libbass.so 01-10 12:32:39.753: I/DEBUG(30369): 46e6c9a0 002d02e8 01-10 12:32:39.753: I/DEBUG(30369): 46e6c9a4 b0000001 01-10 12:32:39.753: I/DEBUG(30369): 46e6c9a8 00000000 01-10 12:32:39.753: I/DEBUG(30369): 46e6c9ac 80717e67 /data/data/com.example.miditest/lib/libbass.so 01-10 12:32:39.753: I/DEBUG(30369): 46e6c9b0 00018000 01-10 12:32:39.753: I/DEBUG(30369): 46e6c9b4 8070e1bf /data/data/com.example.miditest/lib/libbass.so 01-10 12:32:39.753: I/DEBUG(30369): 46e6c9b8 00348fa0 01-10 12:32:39.753: I/DEBUG(30369): 46e6c9bc 80729569 /data/data/com.example.miditest/lib/libbass.so 01-10 12:32:39.753: I/DEBUG(30369): 46e6c9c0 00348fa0 01-10 12:32:39.753: I/DEBUG(30369): 46e6c9c4 00348fa0 01-10 12:32:39.753: I/DEBUG(30369): 46e6c9c8 002d02e8 01-10 12:32:39.761: I/DEBUG(30369): 46e6c9cc 00006f60 01-10 12:32:39.761: I/DEBUG(30369): 46e6c9d0 df002777 01-10 12:32:39.761: I/DEBUG(30369): 46e6c9d4 e3a070ad 01-10 12:32:39.761: I/DEBUG(30369): #00 46e6c9d8 00000000 01-10 12:32:39.761: I/DEBUG(30369): 46e6c9dc 00000004 01-10 12:32:39.761: I/DEBUG(30369): 46e6c9e0 00000000 01-10 12:32:39.761: I/DEBUG(30369): 46e6c9e4 00018000 01-10 12:32:39.761: I/DEBUG(30369): 46e6c9e8 033f7b00 01-10 12:32:39.761: I/DEBUG(30369): 46e6c9ec 407136e0 01-10 12:32:39.761: I/DEBUG(30369): 46e6c9f0 003491e0 01-10 12:32:39.761: I/DEBUG(30369): 46e6c9f4 807116b9 /data/data/com.example.miditest/lib/libbass.so 01-10 12:32:39.761: I/DEBUG(30369): 46e6c9f8 80754f10 01-10 12:32:39.761: I/DEBUG(30369): 46e6c9fc 00000000 01-10 12:32:39.761: I/DEBUG(30369): 46e6ca00 0034a240 01-10 12:32:39.761: I/DEBUG(30369): 46e6ca04 00000000 01-10 12:32:39.761: I/DEBUG(30369): 46e6ca08 00000000 01-10 12:32:39.761: I/DEBUG(30369): 46e6ca0c 0034a240 01-10 12:32:39.761: I/DEBUG(30369): 46e6ca10 00000000 01-10 12:32:39.761: I/DEBUG(30369): 46e6ca14 00000001 01-10 12:32:39.761: I/DEBUG(30369): 46e6ca18 fff00000 01-10 12:32:39.761: I/DEBUG(30369): 46e6ca1c 00348fa0 This is probably some error in the download thread as I didn't even start doing BASS_ChannelGetData. Is there any other thing I should do when I want to start playing a new song besides calling streamFree before creating a new stream? Thank you
|
|
|
|
« Last Edit: 10 Jan '12 - 14:17 by helri »
|
Logged
|
|
|
|
|
Ian @ un4seen
Administrator
Posts: 15253
|
 |
« Reply #59 on: 10 Jan '12 - 15:35 » |
Quote
|
Are you making the BASS_StreamFree call from within the SYNCPROC? If so, that will be a problem as the BASS_SYNC_END sync will automatically be "mixtime" (due to the BASS_STREAM_DECODE flag), which means that there are some restrictions on what can be done in the SYNCPROC. Please see the SYNCPROC/STREAMPROC docs for details. If that is indeed what is happening, you could move the call to another thread, eg. via runOnUiThread.
|
|
|
|
|
Logged
|
|
|
|
|