Author Topic: BASS for Android  (Read 392187 times)

LikeAndroid

  • Guest
Re: BASS for Android
« Reply #700 on: 25 Sep '14 - 05:55 »
just to let you know, the obfuscated app crashes when i'm calling the bass library. using the android mediaplayer api is working ok.

Ian @ un4seen

  • Administrator
  • Posts: 20437
Re: BASS for Android
« Reply #701 on: 25 Sep '14 - 15:19 »
I haven't tried it myself, but another user reported a similar issue a while ago and posted a solution here...

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

LikeAndroid

  • Guest
Re: BASS for Android
« Reply #702 on: 25 Sep '14 - 20:00 »
hm, maybe this could help. i give it a try. thanky you :-)

Ian @ un4seen

  • Administrator
  • Posts: 20437
Re: BASS for Android
« Reply #703 on: 3 Oct '14 - 17:28 »
The latest version (2.4.12) of the BASSenc add-on is now up in the 1st post, adding support for user-provided encoders, eg. it is now possible to use the LAME library instead of the standalone LAME executable (which isn't available on Android).

Vladislav

  • Guest
Re: BASS for Android
« Reply #704 on: 5 Oct '14 - 10:09 »
Hi, Ian
I have one annoing problem with bass, when i try to play file from https (StreamCreateUrl) app really frequently crashes. (every third or second call streamCreateUrl). I use the last version of bass lib (03 oct '14). Is there any workaround? https://dl.dropbox.com/s/vlhbnruxvh4bkvy/VALI%20-%20Forlatt%20%282004%29%20-%2002.Dypt%20Inne%20I%20Skogen.mp3?dl=0 (sample of link)
Here is configs i use:
Code: [Select]
BASS.BASS_SetConfig(BASS.BASS_CONFIG_FLOATDSP, 1);
        BASS.BASS_SetConfig(BASS.BASS_CONFIG_NET_PREBUF, 0);

        BASS.BASS_SetConfig(BASS.BASS_CONFIG_VERIFY,6000);

Here is stacktrace from Logcat: (Link to full stacktrace http://pastebin.com/JYvb2b3t )
Code: [Select]
10-05 11:48:48.654      182-182/? I/DEBUG﹕ *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
10-05 11:48:48.654      182-182/? I/DEBUG﹕ Build fingerprint: 'google/hammerhead/hammerhead:L/LPV79/1236599:user/release-keys'
10-05 11:48:48.654      182-182/? I/DEBUG﹕ Revision: '11'
10-05 11:48:48.654      182-182/? I/DEBUG﹕ pid: 18087, tid: 18524, name: Thread-3129  >>> com.perm.doomplay <<<
10-05 11:48:48.654      182-182/? I/DEBUG﹕ signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x1a0
10-05 11:48:48.669      182-182/? I/DEBUG﹕ r0 00000000  r1 00000000  r2 00000000  r3 ffffffff
10-05 11:48:48.669      182-182/? I/DEBUG﹕ r4 b8196b00  r5 b53918bd  r6 5a7c4d90  r7 00000000
10-05 11:48:48.669      182-182/? I/DEBUG﹕ r8 000186a0  r9 00000000  sl 9a8b3551  fp 9a8ca45c
10-05 11:48:48.669      182-182/? I/DEBUG﹕ ip b6ae7e98  sp 5a56cd40  lr b6a4dd0b  pc b5391100  cpsr 40070030
10-05 11:48:48.669      182-182/? I/DEBUG﹕ d0  00004000789349f0  d1  00000000000000e5
10-05 11:48:48.669      182-182/? I/DEBUG﹕ d2  00c24a497c1a20ae  d3  87fdf06295b5f670
10-05 11:48:48.669      182-182/? I/DEBUG﹕ d4  752617331c269188  d5  0ddbb9a6ca48f5d0
10-05 11:48:48.669      182-182/? I/DEBUG﹕ d6  d54314bb32119805  d7  314de026dcdc3347
10-05 11:48:48.669      182-182/? I/DEBUG﹕ d8  0000000000000000  d9  0000000000000000
10-05 11:48:48.669      182-182/? I/DEBUG﹕ d10 0000000000000000  d11 0000000000000000
10-05 11:48:48.669      182-182/? I/DEBUG﹕ d12 0000000000000000  d13 0000000000000000
10-05 11:48:48.669      182-182/? I/DEBUG﹕ d14 0000000000000000  d15 0000000000000000
10-05 11:48:48.669      182-182/? I/DEBUG﹕ d16 0000000000000000  d17 e166af51304fc84e
10-05 11:48:48.669      182-182/? I/DEBUG﹕ d18 a5922786b2a0f57a  d19 0ee1c9f2fc80076b
10-05 11:48:48.669      182-182/? I/DEBUG﹕ d20 0ee1c9f2fc80076b  d21 a5922786b2a0f57a
10-05 11:48:48.669      182-182/? I/DEBUG﹕ d22 0d94000000000000  d23 0000000000000000
10-05 11:48:48.669      182-182/? I/DEBUG﹕ d24 0000000000000000  d25 0000000000000000
10-05 11:48:48.669      182-182/? I/DEBUG﹕ d26 f408eaf26206acb6  d27 009a6a2862605e04
10-05 11:48:48.669      182-182/? I/DEBUG﹕ d28 0000000000000000  d29 0000000000000000
10-05 11:48:48.669      182-182/? I/DEBUG﹕ d30 27c373276d4f400a  d31 ae74720b14b3319c
10-05 11:48:48.669      182-182/? I/DEBUG﹕ scr 60000011
10-05 11:48:48.669      182-182/? I/DEBUG﹕ backtrace:
10-05 11:48:48.669      182-182/? I/DEBUG﹕ #00 pc 0001d100  /system/lib/libssl.so
10-05 11:48:48.669      182-182/? I/DEBUG﹕ #01 pc 00011b23  /data/app-lib/com.perm.doomplay-1/libbass.so
10-05 11:48:48.669      182-182/? I/DEBUG﹕ #02 pc 00011b55  /data/app-lib/com.perm.doomplay-1/libbass.so
10-05 11:48:48.669      182-182/? I/DEBUG﹕ #03 pc 000183c9  /data/app-lib/com.perm.doomplay-1/libbass.so
10-05 11:48:48.669      182-182/? I/DEBUG﹕ #04 pc 0001b5bd  /data/app-lib/com.perm.doomplay-1/libbass.so
10-05 11:48:48.669      182-182/? I/DEBUG﹕ #05 pc 00015b0f  /system/lib/libc.so (__pthread_start(void*)+30)
10-05 11:48:48.669      182-182/? I/DEBUG﹕ #06 pc 00013eef  /system/lib/libc.so (__bionic_clone_entry+6)
10-05 11:48:48.669      182-182/? I/DEBUG﹕ stack:
10-05 11:48:48.670      182-182/? I/DEBUG﹕ 5a56cd00  b51136a5  /system/lib/libart.so (art::CheckJNI::NewDirectByteBuffer(_JNIEnv*, void*, long long))
10-05 11:48:48.670      182-182/? I/DEBUG﹕ 5a56cd04  5a7c0d90  [anon:libc_malloc]
10-05 11:48:48.670      182-182/? I/DEBUG﹕ 5a56cd08  00000000
10-05 11:48:48.670      182-182/? I/DEBUG﹕ 5a56cd0c  9a8b3551  /data/app-lib/com.perm.doomplay-1/libbass.so
10-05 11:48:48.670      182-182/? I/DEBUG﹕ 5a56cd10  9a8ca45c  /data/app-lib/com.perm.doomplay-1/libbass.so
10-05 11:48:48.670      182-182/? I/DEBUG﹕ 5a56cd14  b5109b11  /system/lib/libart.so (art::CheckJNI::PopLocalFrame(_JNIEnv*, _jobject*)+80)
10-05 11:48:48.671      182-182/? I/DEBUG﹕ 5a56cd18  25fce6f7
10-05 11:48:48.671      182-182/? I/DEBUG﹕ 5a56cd1c  b8196b00  [heap]
10-05 11:48:48.671      182-182/? I/DEBUG﹕ 5a56cd20  b53918bd  /system/lib/libssl.so (ssl3_read_bytes)
10-05 11:48:48.671      182-182/? I/DEBUG﹕ 5a56cd24  5a7c4d90  [anon:libc_malloc]
10-05 11:48:48.671      182-182/? I/DEBUG﹕ 5a56cd28  00000000
10-05 11:48:48.671      182-182/? I/DEBUG﹕ 5a56cd2c  000186a0
10-05 11:48:48.671      182-182/? I/DEBUG﹕ 5a56cd30  00000000
10-05 11:48:48.671      182-182/? I/DEBUG﹕ 5a56cd34  9a8b3551  /data/app-lib/com.perm.doomplay-1/libbass.so
10-05 11:48:48.671      182-182/? I/DEBUG﹕ 5a56cd38  9a8ca45c  /data/app-lib/com.perm.doomplay-1/libbass.so
10-05 11:48:48.671      182-182/? I/DEBUG﹕ 5a56cd3c  b53910d1  /system/lib/libssl.so
10-05 11:48:48.671      182-182/? I/DEBUG﹕ #00  5a56cd40  00000000
10-05 11:48:48.671      182-182/? I/DEBUG﹕ 5a56cd44  00000004
10-05 11:48:48.672      182-182/? I/DEBUG﹕ 5a56cd48  b834bf48  [heap]
10-05 11:48:48.672      182-182/? I/DEBUG﹕ 5a56cd4c  b834bf48  [heap]
10-05 11:48:48.672      182-182/? I/DEBUG﹕ 5a56cd50  000186a0
10-05 11:48:48.672      182-182/? I/DEBUG﹕ 5a56cd54  5a7c4d90  [anon:libc_malloc]
10-05 11:48:48.672      182-182/? I/DEBUG﹕ 5a56cd58  b834bf58  [heap]
10-05 11:48:48.672      182-182/? I/DEBUG﹕ 5a56cd5c  9a8a9b25  /data/app-lib/com.perm.doomplay-1/libbass.so
10-05 11:48:48.672      182-182/? I/DEBUG﹕ #01  5a56cd60  b834bf20  [heap]
10-05 11:48:48.672      182-182/? I/DEBUG﹕ 5a56cd64  9a8a9b59  /data/app-lib/com.perm.doomplay-1/libbass.so
10-05 11:48:48.672      182-182/? I/DEBUG﹕ #02  5a56cd68  b834bf20  [heap]
10-05 11:48:48.672      182-182/? I/DEBUG﹕ 5a56cd6c  9a8ce2fc
10-05 11:48:48.673      182-182/? I/DEBUG﹕ 5a56cd70  000186a0
10-05 11:48:48.673      182-182/? I/DEBUG﹕ 5a56cd74  00000000
10-05 11:48:48.673      182-182/? I/DEBUG﹕ 5a56cd78  b834bf58  [heap]
10-05 11:48:48.673      182-182/? I/DEBUG﹕ 5a56cd7c  9a8b03cb  /data/app-lib/com.perm.doomplay-1/libbass.so

doomplay

  • Posts: 33
Re: BASS for Android
« Reply #705 on: 5 Oct '14 - 11:04 »
I did report about problem above as Vladislav

UPD: App crashes when i dispose channel that have not fully buffered (i mean BASS_FILEPOS_BUFFER)
If i call dispose on channel when
Code: [Select]
BASS.BASS_StreamGetFilePosition(chan,BASS.BASS_FILEPOS_BUFFER) == BASS.BASS_StreamGetFilePosition(chan,BASS.BASS_FILEPOS_END) //is true everything fine.
Note: How i exactly create channel:
Code: [Select]
int tempChan = BASS.BASS_StreamCreateURL(url, 0, BASS.BASS_SAMPLE_SOFTWARE|BASS.BASS_STREAM_DECODE, null, r);

 tempChan = BASS_FX.BASS_FX_TempoCreate(tempChan,BASS.BASS_SAMPLE_SOFTWARE|BASS_FX.BASS_FX_FREESOURCE);

Can you fix this trouble? Or give me please any advice.
If you need, i can build sample app for you.

stellion

  • Guest
Re: BASS for Android
« Reply #706 on: 5 Oct '14 - 15:44 »
I have completely the same problem with playing https links.
Please fix this critical issue.

Ian @ un4seen

  • Administrator
  • Posts: 20437
Re: BASS for Android
« Reply #707 on: 6 Oct '14 - 15:39 »
HTTPS support was added to the Android version quite recently and it is still a bit experimental. Here's the latest build, which should be more stable...

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

Let me know if you still have any trouble with HTTPS URLs.

mrjoey

  • Posts: 31
Re: BASS for Android
« Reply #708 on: 8 Oct '14 - 15:03 »
hello , is possible to choose the recording inputs? i have samsung s3 wich has 2 mics , currently its recording from the default mic .
thanks.
« Last Edit: 8 Oct '14 - 15:51 by mrjoey »

Ian @ un4seen

  • Administrator
  • Posts: 20437
Re: BASS for Android
« Reply #709 on: 8 Oct '14 - 18:12 »
If you record in stereo (ie. BASS_RecordStart with chans=2), do you get the sound from both mics, ie. one in each channel? If so, you could then extract the wanted channel from the data received in your RECORDPROC function, ie. the even samples (0/2/4/etc) for the 1st channel/mic or the odd samples (1/3/5/etc) for the 2nd channel/mic.

doomplay

  • Posts: 33
Re: BASS for Android
« Reply #710 on: 8 Oct '14 - 18:49 »
HTTPS support was added to the Android version quite recently and it is still a bit experimental. Here's the latest build, which should be more stable...

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

Let me know if you still have any trouble with HTTPS URLs.
Thanks! Seems everything fine. It would be great if you include this update in the main package

mrjoey

  • Posts: 31
Re: BASS for Android
« Reply #711 on: 8 Oct '14 - 20:27 »
If you record in stereo (ie. BASS_RecordStart with chans=2), do you get the sound from both mics, ie. one in each channel? If so, you could then extract the wanted channel from the data received in your RECORDPROC function, ie. the even samples (0/2/4/etc) for the 1st channel/mic or the odd samples (1/3/5/etc) for the 2nd channel/mic.
no i dont get sound from both , all i get is 1 left channel for the left mic and the second is low in volume and a bit noisy , my recordproc is empty , just returning true , not doing anything with the data.
BASS_RecordGetInputName , BASS_RecordSetInput , BASS_RecordGetInput do help?if so how to use it? thank u.

Ian @ un4seen

  • Administrator
  • Posts: 20437
Re: BASS for Android
« Reply #712 on: 9 Oct '14 - 15:37 »
Thanks! Seems everything fine. It would be great if you include this update in the main package

Yep, the latest build is now up in the 1st post.

If you record in stereo (ie. BASS_RecordStart with chans=2), do you get the sound from both mics, ie. one in each channel? If so, you could then extract the wanted channel from the data received in your RECORDPROC function, ie. the even samples (0/2/4/etc) for the 1st channel/mic or the odd samples (1/3/5/etc) for the 2nd channel/mic.
no i dont get sound from both , all i get is 1 left channel for the left mic and the second is low in volume and a bit noisy , my recordproc is empty , just returning true , not doing anything with the data.
BASS_RecordGetInputName , BASS_RecordSetInput , BASS_RecordGetInput do help?if so how to use it? thank u.

Are you sure it's not recording from both mics? I don't have a Samsung S3 at hand to test with, but when recording in stereo on another device with 2 mics, it is capturing from both. If you modify the RECTEST.JAVA example to record in stereo by changing the "CHANS" value to 2, and then blow into/over each mic in turn while recording, and then plug in headphones and playback the recording, do you not hear the noise alternating between left and right channels?

There doesn't appear to be any way to switch recording inputs on Android, so the BASS recording input selection functions aren't available (you'll get a BASS_ERROR_NOTAVAIL error). But here's an update for you to try...

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

It adds a "Camcorder" recording device (#1), which is meant to use the "microphone audio source with the same orientation as the camera" but it seems to capture from the 2nd mic even when it's not facing the same way as the camera. It captures from the 1st mic if there is no 2nd mic. Let me know if you can record from the 2nd mic with it on your device.

mrjoey

  • Posts: 31
Re: BASS for Android
« Reply #713 on: 9 Oct '14 - 17:30 »
Thanks! Seems everything fine. It would be great if you include this update in the main package

Yep, the latest build is now up in the 1st post.

If you record in stereo (ie. BASS_RecordStart with chans=2), do you get the sound from both mics, ie. one in each channel? If so, you could then extract the wanted channel from the data received in your RECORDPROC function, ie. the even samples (0/2/4/etc) for the 1st channel/mic or the odd samples (1/3/5/etc) for the 2nd channel/mic.
no i dont get sound from both , all i get is 1 left channel for the left mic and the second is low in volume and a bit noisy , my recordproc is empty , just returning true , not doing anything with the data.
BASS_RecordGetInputName , BASS_RecordSetInput , BASS_RecordGetInput do help?if so how to use it? thank u.

Are you sure it's not recording from both mics? I don't have a Samsung S3 at hand to test with, but when recording in stereo on another device with 2 mics, it is capturing from both. If you modify the RECTEST.JAVA example to record in stereo by changing the "CHANS" value to 2, and then blow into/over each mic in turn while recording, and then plug in headphones and playback the recording, do you not hear the noise alternating between left and right channels?

There doesn't appear to be any way to switch recording inputs on Android, so the BASS recording input selection functions aren't available (you'll get a BASS_ERROR_NOTAVAIL error). But here's an update for you to try...

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

It adds a "Camcorder" recording device (#1), which is meant to use the "microphone audio source with the same orientation as the camera" but it seems to capture from the 2nd mic even when it's not facing the same way as the camera. It captures from the 1st mic if there is no 2nd mic. Let me know if you can record from the 2nd mic with it on your device.
Thank you Mr Ian , changing the recording device to 1 and channels to stereo does help ,
another question , is possible to hear the recording chan live? like the VB example "livefx" ? thank u , best regards.

Ian @ un4seen

  • Administrator
  • Posts: 20437
Re: BASS for Android
« Reply #714 on: 10 Oct '14 - 14:22 »
It should be possible to implement the LIVEFX example on Android, but I'm not sure how well it would work, ie. latency could be quite high. You could give it a try and see how it goes. The code could basically look something like this...

Code: [Select]
output=BASS.BASS_StreamCreate(freq, chans, 0, StreamProc, null); // create a stream to play the recording
BASS.BASS_ChannelSetAttribute(output, BASS.BASS_ATTRIB_NOBUFFER, 1); // disable playback buffering on the stream to minimize latency
input=BASS.BASS_RecordStart(freq, chans, 0, null, null); // start recording without a RECORDPROC
BASS.BASS_ChannelPlay(output, false); // start the output

BASS.STREAMPROC StreamProc=new BASS.STREAMPROC() {
public int STREAMPROC(int handle, ByteBuffer buffer, int length, Object user) {
return BASS.BASS_ChannelGetData(input, buffer, length); // get data from the recording
}
};


SimonH

  • Posts: 9
Re: BASS for Android
« Reply #715 on: 10 Oct '14 - 17:47 »
I want to determine the sample rate of an audio file before calling BASS_Init.  I see that android.media.MediaPlayer has getTrackInfo() method but it's not available below API level 16.   

Anyone know how to do this on Android with minimum API level of 10?


Ian @ un4seen

  • Administrator
  • Posts: 20437
Re: BASS for Android
« Reply #716 on: 13 Oct '14 - 15:24 »
I guess the aim is to avoid the need for resampling by using the file's sample rate in the BASS_Init call. If so, it may be that Android will need to resample anyway to match the device's output rate, as it's not possible for BASS to change the device's output rate; the BASS_Init "freq" parameter only determines the sample rate of BASS's output. The main thing (for quality and performance) is to avoid BASS and Android both resampling. You could do that by calling BASS_Init with the file's sample rate, but that means you will need to call BASS_Init again each time you want to play a file with a different sample rate. Another option is to just call BASS_Init once with the device's sample rate, which is available from AudioTrack's getNativeOutputSampleRate method...

Code: [Select]
BASS.BASS_Init(-1, AudioTrack.getNativeOutputSampleRate(AudioManager.STREAM_MUSIC), 0); // initialize BASS output with the device's output rate

That should avoid the need for Android to resample, and if resampling is required, it will be performed by BASS (configurable via BASS_CONFIG_SRC and BASS_ATTRIB_SRC).

If you would still prefer to have BASS output at the file's rate, then one way you could do that is to use the "no sound" device for the info retrieval before calling BASS_Init on the real device, something like this...

Code: [Select]
// initialization
BASS.BASS_Init(0, 44100, 0); // initialize "no sound" device

...

// playing a file
BASS_SetDevice(0); // set the device context to the "no sound" device
int infostream=BASS.BASS_StreamCreateFile(filename, 0, 0, BASS.BASS_STREAM_DECODE); // open the file to get info
BASS.BASS_CHANNELINFO info=new BASS.BASS_CHANNELINFO();
BASS.BASS_ChannelGetInfo(infostream, info); // get the info
BASS.BASS_StreamFree(infostream); // free the stream
BASS.BASS_Init(-1, info.freq, 0); // initialize output device
stream=BASS.BASS_StreamCreateFile(filename, 0, 0, 0); // open the file for playback

Please see the documentation for details on the aforementioned functions.

SimonH

  • Posts: 9
Re: BASS for Android
« Reply #717 on: 13 Oct '14 - 18:36 »
Thanks Ian, that cleared a few things up for me.

mrjoey

  • Posts: 31
Re: BASS for Android
« Reply #718 on: 13 Oct '14 - 22:08 »
It should be possible to implement the LIVEFX example on Android, but I'm not sure how well it would work, ie. latency could be quite high. You could give it a try and see how it goes. The code could basically look something like this...

Code: [Select]
output=BASS.BASS_StreamCreate(freq, chans, 0, StreamProc, null); // create a stream to play the recording
BASS.BASS_ChannelSetAttribute(output, BASS.BASS_ATTRIB_NOBUFFER, 1); // disable playback buffering on the stream to minimize latency
input=BASS.BASS_RecordStart(freq, chans, 0, null, null); // start recording without a RECORDPROC
BASS.BASS_ChannelPlay(output, false); // start the output

BASS.STREAMPROC StreamProc=new BASS.STREAMPROC() {
public int STREAMPROC(int handle, ByteBuffer buffer, int length, Object user) {
return BASS.BASS_ChannelGetData(input, buffer, length); // get data from the recording
}
};

thank u mr Ian , i will try it , but now im busy trying to mess around the casting BASS_Encode_CastInit , can u provide me a small exmple on how to start casting , and what about BASS_Encode_ServerInit , what is the best choice for me if i want to stream out my playing channel to winamp , cast helps? and Encode_Server is to stream out to another bass app? thank u

Ian @ un4seen

  • Administrator
  • Posts: 20437
Re: BASS for Android
« Reply #719 on: 14 Oct '14 - 15:08 »
For casting, you will need an encoder. There aren't any command-line encoders on Android (eg. no LAME or OGGENC executables), so you will need to include an encoder library built into your app, which can be used with BASSenc via the new BASS_Encode_StartUser function. Some info/code on doing that with the LAME library can be found in this thread...

   www.un4seen.com/forum/?topic=15657

emile_b

  • Posts: 12
Re: BASS for Android
« Reply #720 on: 21 Oct '14 - 14:00 »
Hi,

I am trying to use BASS_ChannelGetData in order to send data to a visualisation library, I need the sample data that is current being played.

The issue is I just seem to be getting zeros and no data.

Firstly, I am setting up the player, and playing the MP3s from Java, BUT I want to call BASS_ChannelGetData from Native C code because that is where it is needed, is this possible?

Here is my setup and playing of the file:

SETUP:
Code: [Select]
if (!BASS.BASS_Init(-1, AudioTrack.getNativeOutputSampleRate(AudioManager.STREAM_MUSIC), 0)) {
Utils.MyLog(-1, LOG, "Error initalising BASS");
return false;
}
if (BASS.BASS_PluginLoad(ctx.getApplicationInfo().nativeLibraryDir+"/libbass_aac.so", 0)==0)
{
Utils.MyLog(-1, LOG, "Error initalising AAC");
return false;
}
if (BASS.BASS_PluginLoad(ctx.getApplicationInfo().nativeLibraryDir+"/libbass_alac.so", 0)==0)
{
Utils.MyLog(-1, LOG, "Error initalising ALAC");
return false;
}
if (BASS.BASS_PluginLoad(ctx.getApplicationInfo().nativeLibraryDir+"/libbass_ape.so", 0)==0)
{
Utils.MyLog(-1, LOG, "Error initalising APE");
return false;
}

PLAY:
Code: [Select]
BASS.BASS_MusicFree(chan);
BASS.BASS_StreamFree(chan);
if ((chan=BASS.BASS_StreamCreateFile(file, 0, 0, BASS.BASS_SAMPLE_LOOP|BASS.BASS_STREAM_DECODE))==0) {
// whatever it is, it ain't playable
Utils.MyLog(-1,LOG,"Error opening file " + file);
}

chan = BASS_FX.BASS_FX_TempoCreate(chan,  BASS_FX.BASS_FX_FREESOURCE);

mixer = BASSmix.BASS_Mixer_StreamCreate(AudioTrack.getNativeOutputSampleRate(AudioManager.STREAM_MUSIC),2,0);

BASSmix.BASS_Mixer_StreamAddChannel(mixer, chan, 0);


BASS.BASS_ChannelSetAttribute(chan, BASS_FX.BASS_ATTRIB_TEMPO,0);


boolean ret = BASS.BASS_ChannelPlay(chan, false);



Then in the C code:
Code: [Select]
short fakePCM[512];
int ret = BASS_ChannelGetData(mixerChan, fakePCM, 512);
LOGI("ret = %d",ret);
for (int x = 20; x< 30;x++)
{
LOGI("%d", fakePCM[x]);
}

One thing I am not sure of is that 'channel' I need to give to BASS_ChannelGetData, I have tried the channel and mixer handles, neither seem to work.

EDIT, OK I seem to be getting some data now, I needed to pass in (BASS_DATA_FLOAT | 2048), data looks a little wierd but I will check it out. THANKS

Thanks
Emile
« Last Edit: 21 Oct '14 - 14:43 by emile_b »

emile_b

  • Posts: 12
Re: BASS for Android
« Reply #721 on: 21 Oct '14 - 15:16 »
OK I sorted out the above issue, I am now getting data from the channel, I left the message incase it was useful to anyone but feel free to delete it if you want.

Now I would like to know the best method of reading the data into the visualiser, without repeating or missing data?
The visualizer works on another thread, so how would I get a continuous stream of data? It seems if I read too fast I will repeat samples using BASS_ChannelGetData? And too slow I will miss sample.
Obviously it does not have to be perfect as its just a visualisation, but it should look like its kind of following the music!

Thanks
Emile.

Ian @ un4seen

  • Administrator
  • Posts: 20437
Re: BASS for Android
« Reply #722 on: 21 Oct '14 - 16:41 »
Are you still using the mixer mentioned in your 1st post? It doesn't look like it is needed, or indeed used. To play through the mixer, the "PLAY" code would need to look something like this...

Code: [Select]
BASS.BASS_StreamFree(chan);
if ((chan=BASS.BASS_StreamCreateFile(file, 0, 0, BASS.BASS_SAMPLE_LOOP|BASS.BASS_STREAM_DECODE))==0) {
// whatever it is, it ain't playable
Utils.MyLog(-1,LOG,"Error opening file " + file);
}

chan = BASS_FX.BASS_FX_TempoCreate(chan,  BASS_FX.BASS_FX_FREESOURCE|BASS.BASS_STREAM_DECODE); // a decoding channel so it can be plugged in mixer

mixer = BASSmix.BASS_Mixer_StreamCreate(AudioTrack.getNativeOutputSampleRate(AudioManager.STREAM_MUSIC),2,0);

BASSmix.BASS_Mixer_StreamAddChannel(mixer, chan, 0);

BASS.BASS_ChannelSetAttribute(chan, BASS_FX.BASS_ATTRIB_TEMPO,0);

boolean ret = BASS.BASS_ChannelPlay(mixer, false); // start the mixer

But, as I say, it doesn't look like you actually need the mixer. In which case, that code could look like this...

Code: [Select]
BASS.BASS_StreamFree(chan);
if ((chan=BASS.BASS_StreamCreateFile(file, 0, 0, BASS.BASS_SAMPLE_LOOP|BASS.BASS_STREAM_DECODE))==0) {
// whatever it is, it ain't playable
Utils.MyLog(-1,LOG,"Error opening file " + file);
}

chan = BASS_FX.BASS_FX_TempoCreate(chan,  BASS_FX.BASS_FX_FREESOURCE);

BASS.BASS_ChannelSetAttribute(chan, BASS_FX.BASS_ATTRIB_TEMPO,0);

boolean ret = BASS.BASS_ChannelPlay(chan, false);

In the 1st case, you would use the "mixer" handle in the BASS_ChannelGetData call. In the 2nd case, you would use the "chan" handle. On Android, using the BASS_DATA_FLOAT flag will result in 8.24 fixed-point data being delivered, so a 32-bit "int" (rather than 16-bit "short") array would be needed in that case. Note that the BASS_ChannelGetData "length" parameter is in bytes, so if you want to get 512x 16-bit samples, you would do this...

Code: [Select]
short fakePCM[512];
int ret = BASS_ChannelGetData(mixerChan, fakePCM, 512*sizeof(short));

Regarding how often to call BASS_ChannelGetData, that will depend on how much data you get each time. For example, if you get 512 samples from a stereo 44100Hz stream, then that will cover 5.8ms (512/2/44100), so you would need to call BASS_ChannelGetData every 5.8ms (at least) if you don't want to miss anything during playback.

emile_b

  • Posts: 12
Re: BASS for Android
« Reply #723 on: 21 Oct '14 - 18:22 »
Are you still using the mixer mentioned in your 1st post? It doesn't look like it is needed, or indeed used. To play through the mixer, the "PLAY" code would need to look something like this...

Ha you're correct of course, seems that wasn't even used, thank you for spotting that.

Regarding how often to call BASS_ChannelGetData, that will depend on how much data you get each time. For example, if you get 512 samples from a stereo 44100Hz stream, then that will cover 5.8ms (512/2/44100), so you would need to call BASS_ChannelGetData every 5.8ms (at least) if you don't want to miss anything during playback.

OK so I would actually need to time it accurately, the issue it's called when ever the visualization frame is finished which varies a lot. I guess I need to time how long it was since the last data was retrieved, then work out how much I need to request? If the visualisation is too slow I will miss data and there is not much I can do about that. If the visualtation is really fast it will only get a small amount of data.

Thanks for the help!


Alene Pander

  • Posts: 3
Re: BASS for Android
« Reply #724 on: 22 Oct '14 - 07:20 »
Hi, I heard it is easy to get a BASS apps for Android. According to what I read, there is a BASS booster  apps that can help enhance clarity of music. Is anyone familiar with this application?