Author Topic: BASS for Android  (Read 388171 times)

Ian @ un4seen

  • Administrator
  • Posts: 20336
Re: BASS for Android
« Reply #1275 on: 24 May '17 - 16:51 »
You can use the MediaCodecList class to get all available codecs:

   https://developer.android.com/reference/android/media/MediaCodecList.html

Ionut Cristea

  • Posts: 1545
Re: BASS for Android
« Reply #1276 on: 12 Jun '17 - 07:11 »
  Hello Ian,

I am wondering if BASS_FILEPROCS functions are called by main thread using for example BASS_ChannelPlay function. If yes how i can avoid that?

Thanks,
Ionut

Ian @ un4seen

  • Administrator
  • Posts: 20336
Re: BASS for Android
« Reply #1277 on: 12 Jun '17 - 17:17 »
Yes, BASS_ChannelPlay will usually need to decode some data before starting playback, which is likely to require some file reading. You can avoid that by calling BASS_ChannelUpdate first, which you could do in another thread.

otherside

  • Posts: 24
Re: BASS for Android
« Reply #1278 on: 2 Jul '17 - 08:46 »
1.
A BASS update that adds support for using Android's built-in codecs is now up in the 1st post.
Do we need to add some code to use mentioned capabilities?

2. I constantly get error: 10 - SSL/HTTPS support isn't available. I remember that you added capabilities to play https in some version. Version of BASS is the newest.
« Last Edit: 3 Jul '17 - 08:57 by otherside »

Ian @ un4seen

  • Administrator
  • Posts: 20336
Re: BASS for Android
« Reply #1279 on: 3 Jul '17 - 17:50 »
A BASS update that adds support for using Android's built-in codecs is now up in the 1st post.
Do we need to add some code to use mentioned capabilities?

No, it is enabled by default. If wanted, it can be disabled by setting the BASS_CONFIG_AM_DISABLE option to 1 (via BASS_SetConfig).

2. I constantly get error: 10 - SSL/HTTPS support isn't available. I remember that you added capabilities to play https in some version. Version of BASS is the newest.

What device and Android version are you using? It might be that a supported SSL library (libssl or libboringssl) isn't present. To confirm what libraries are available, you can try running this code on the device:

Code: [Select]
File[] list=new File("/system/lib").listFiles();
for (int i=0; i<list.length; i++) {
Log.d("filelist", list[i].getName() + " = " + list[i].length());
}

Then go to the LogCat window and set the filter to "tag:filelist". You can also use a file explorer/manager app to see what's in the "/system/lib" folder.

otherside

  • Posts: 24
Re: BASS for Android
« Reply #1280 on: 3 Jul '17 - 21:02 »
A BASS update that adds support for using Android's built-in codecs is now up in the 1st post.
Do we need to add some code to use mentioned capabilities?

No, it is enabled by default. If wanted, it can be disabled by setting the BASS_CONFIG_AM_DISABLE option to 1 (via BASS_SetConfig).

2. I constantly get error: 10 - SSL/HTTPS support isn't available. I remember that you added capabilities to play https in some version. Version of BASS is the newest.

What device and Android version are you using? It might be that a supported SSL library (libssl or libboringssl) isn't present. To confirm what libraries are available, you can try running this code on the device:

Code: [Select]
File[] list=new File("/system/lib").listFiles();
for (int i=0; i<list.length; i++) {
Log.d("filelist", list[i].getName() + " = " + list[i].length());
}

Then go to the LogCat window and set the filter to "tag:filelist". You can also use a file explorer/manager app to see what's in the "/system/lib" folder.

The mentioned error pops on any device I try, my current is nexus 6p android 7.1.1.
Output from logcat - libssl.so = 157172. The links I tried are playable from browser.

What can I do next to help?

Ian @ un4seen

  • Administrator
  • Posts: 20336
Re: BASS for Android
« Reply #1281 on: 4 Jul '17 - 14:38 »
I will send you a debug version to get more information.

otherside

  • Posts: 24
Re: BASS for Android
« Reply #1282 on: 4 Jul '17 - 18:51 »
I will send you a debug version to get more information.
Okay, I will be waiting

Ian @ un4seen

  • Administrator
  • Posts: 20336
Re: BASS for Android
« Reply #1283 on: 5 Jul '17 - 15:20 »
The email (subject "Re: BASS for Android") was sent yesterday. If you haven't received it, please check your spam/junk folder, in case it has ended up there. Let me know if it isn't there either.

otherside

  • Posts: 24
Re: BASS for Android
« Reply #1284 on: 5 Jul '17 - 21:44 »
Oops I usually don't use my mailbox.
I made reply with the data from test.

Ian @ un4seen

  • Administrator
  • Posts: 20336
Re: BASS for Android
« Reply #1285 on: 14 Jul '17 - 15:43 »
A new BASS_SSL add-on is up in the 1st post, which will be needed to support HTTPS URLs in apps that target Android 7 due to the system's SSL libraries being unavailable then. See the 1st post for more details. A BASS update is also up, to add support for the new add-on.

jnyang

  • Guest
Re: BASS for Android
« Reply #1286 on: 16 Jul '17 - 16:50 »
A BASS update that adds support for using Android's built-in codecs is now up in the 1st post.

Hi, I've tried the updated BASS version which supports Android's built-in codecs, but it crashes on BASS_StreamCreateFile for specific m4a files.
It was tested on Samsung Galaxy A5 (2017) running Android 6.0.1.
I uploaded one of files named as "AndroidNativeCodecCrash.m4a" to ftp.un4seen.com. Thanks in advance for your help.

Ian @ un4seen

  • Administrator
  • Posts: 20336
Re: BASS for Android
« Reply #1287 on: 17 Jul '17 - 17:58 »
Your test file is playing fine when I try it on an Android 6 device here, so that's strange. Please post the crash log (including call stack) when playing that file on your device to have a look at.

Michal

  • Guest
Read audio from FileInputStream
« Reply #1288 on: 20 Jul '17 - 14:49 »
I have to encrypt my audio file with CipherInputStream.
I am able to pass FileInputStrem to android.media.MediaPlayer with FileDescriptor (getFD()). It is possible to do it with Bass player?
It is possible to create BASS channel with FileInputStrem?

Ian @ un4seen

  • Administrator
  • Posts: 20336
Re: BASS for Android
« Reply #1289 on: 20 Jul '17 - 17:52 »
BASS won't read directly from a FileInputStream, but you could use BASS_StreamCreateFileUser (instead of BASS_StreamCreateFile) and read from the FileInputStream in your FILEREADPROC callback function. Another user posted some code for doing that here:

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

ekstro

  • Posts: 7
Re: BASS for Android
« Reply #1290 on: 26 Jul '17 - 08:38 »
We have got a big problem with BASS. The users often report poor sound quality to us.

So far we have used:

Code: [Select]
BASS.BASS_Init(-1, 44100, 0);
Finally, we were able to purchase the device in which this problem occurs. It is, for example, the mobile phone Sony Xperia Z1 z Android 5.1.1 – here the sound ‘jams’. We have tried various settings – in the end we noticed that the setting BASS.BASS_Init(-1, 44100, BASS.BASS_DEVICE_FREQ) fixes this problem.

I would like to ask if we can safely use such a setting for all the phones, or perhaps, we should add a condition that this setting is only valid for Sony and Xiaomi (here we usually receive the reports about poor sound quality). Or maybe we should set it in some different way?

Maybe something like that:

Code: [Select]
int r = AudioTrack.getNativeOutputSampleRate(AudioManager.STREAM_MUSIC);
String m = Build.MANUFACTURER.toLowerCase();
if(m.contains("xiaomi") || m.contains("sony")) {
    r = 44100;
}
BASS.BASS_Init(-1, r, BASS.BASS_DEVICE_FREQ);

I am kindly asking for your help.
« Last Edit: 26 Jul '17 - 08:57 by ekstro »

Ian @ un4seen

  • Administrator
  • Posts: 20336
Re: BASS for Android
« Reply #1291 on: 26 Jul '17 - 14:02 »
When the BASS_DEVICE_FREQ flag isn't used, BASS will use the device's native sample rate (ignoring the "freq" parameter) according to AudioTrack.getNativeOutputSampleRate. Unfortunately, it appears that AudioTrack.getNativeOutputSampleRate isn't correct on some devices and it may well be best to use the BASS_DEVICE_FREQ flag to override it then. Please confirm what value AudioTrack.getNativeOutputSampleRate gives on your devices, and also what value the following gives:

Code: [Select]
AudioManager am = (AudioManager)Context.getSystemService(Context.AUDIO_SERVICE);
String rate = am.getProperty(AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE);

And then also run this app on the devices and see what it says:

   https://play.google.com/store/apps/details?id=com.levien.audiobuffersize

ekstro

  • Posts: 7
Re: BASS for Android
« Reply #1292 on: 26 Jul '17 - 17:36 »
Sony C6903 5.1.1

Value from AudioManager.getProperty(AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE) = 48000

Audio Buffer Size:

Code: [Select]
from platform: sampleRate=48000 bufferSize=960
buffer size estimate = 880.0
sampleRate=44100 bufferSize=880
ms per tick = 19,954; jitter (lr) = 23,168
buffer size estimate = 212.11918312688317
sampleRate=48000 bufferSize=208
ms per tick = 4,334; jitter (lr) = 7,157
result: 208 48000

Ian @ un4seen

  • Administrator
  • Posts: 20336
Re: BASS for Android
« Reply #1293 on: 26 Jul '17 - 17:54 »
That looks like 48000 is actually the correct rate then, but you say 44100 sounds better? Please describe what goes wrong when you use 48000 on that device. Does adjusting the BASS_CONFIG_DEV_BUFFER and/or BASS_CONFIG_DEV_PERIOD settings via BASS_SetConfig (before calling BASS_Init) make any difference? The defaults are BASS_CONFIG_DEV_BUFFER = 30 and BASS_CONFIG_DEV_PERIOD = 10.

ekstro

  • Posts: 7
Re: BASS for Android
« Reply #1294 on: 26 Jul '17 - 20:52 »
If we set 48000 or default value, problems with sound appear imidiately - it crackles and stutters. If we set 44100 it works fine. If you wish I can send you the recording. Later I'll let you know if BASS_CONFIG_DEV_BUFFER and/or BASS_CONFIG_DEV_PERIOD causes any changes.


ekstro

  • Posts: 7
Re: BASS for Android
« Reply #1295 on: 27 Jul '17 - 11:36 »
Example audio file (with stutters) from Sony Z1 in attachment (BASS_DEVICE_FREQ, 48000). Also it seems that BASS_CONFIG_DEV_BUFFER and/or BASS_CONFIG_DEV_PERIOD don't make any differences (maybe minimal). With 44100 there is no problem, sound quality is good, without stutters. We checked different streams, different codecs, bitrates etc.
« Last Edit: 27 Jul '17 - 11:42 by ekstro »

Ian @ un4seen

  • Administrator
  • Posts: 20336
Re: BASS for Android
« Reply #1296 on: 27 Jul '17 - 13:32 »
OK. I will send you a debug version to get more info on what's happening on that device.

ekstro

  • Posts: 7
Re: BASS for Android
« Reply #1297 on: 28 Jul '17 - 13:01 »
Ok, I'm waiting. It's really important for us.

Ian @ un4seen

  • Administrator
  • Posts: 20336
Re: BASS for Android
« Reply #1298 on: 28 Jul '17 - 13:12 »
The debug version was sent yesterday. If you don't see it in your inbox, please also check your spam/junk folder.

ekstro

  • Posts: 7
Re: BASS for Android
« Reply #1299 on: 28 Jul '17 - 13:19 »
I didn't get the file. Can you send it one more time? I just sent you an email.