Author Topic: BASS for Android  (Read 478819 times)

mcooper

  • Posts: 53
Re: BASS for Android
« Reply #1450 on: 10 Sep '18 - 09:41 »
The BASS_STREAM_RESTRATE flag doesn't have any effect during stream creation (it only limits the download rate afterwards), so it was probably just coincidence if you did notice a difference.

Please also give the numerical "ctype" values, just to be sure.

Thank you.  I think I've noticed two separate issues, one of which might only be occuring in my simple test app.  I'll add some more logging to the original app to double check the stream handle after creation and the ctype.  I'll also try to repro the error in the test app again.

mcooper

  • Posts: 53
Re: BASS for Android
« Reply #1451 on: 11 Sep '18 - 11:41 »
In both success and failure case, a non-zero stream handle is returned form BASS_StreamCreateURL and BASS_ChannelGetInfo returns a value of 68353 ( MP4, 44100Hz, Stereo, 16bit).  I can then call BASS_ChannelPlay which returns true and BASS_Start also returns true.  BASS_ErrorGetCode returns BASS_OK.  No audio output is heard though.
« Last Edit: 11 Sep '18 - 11:53 by mcooper »

Ian @ un4seen

  • Administrator
  • Posts: 21363
Re: BASS for Android
« Reply #1452 on: 11 Sep '18 - 13:53 »
OK. If you monitor the BASS_ChannelGetPosition and BASS_ChannelGetLevel return values (eg. in a timer), do they show the playback position advancing and the stream having sound?

From the "ctype" value, it looks like you're currently using the BASS_AAC add-on. For comparison, what happens if you try to play the file without the BASS_AAC add-on?

mcooper

  • Posts: 53
Re: BASS for Android
« Reply #1453 on: 11 Sep '18 - 16:39 »
BASS_ChannelGetPosition is used, and it doesn't show the playback position advancing. 

I'll try adding BASS_ChannelGetLevel to see if that returns anything.

I've tested again with and without BASS_STREAM_RESTRATE and it definitely makes a difference.  When I remove it, I can't repro the issue.  When I add it back in, the problem returns.  I've also noticed the the tracks that fail to play are usually longer tracks / bigger media files.

Bass_AAC plugin is used.  I think the files don't play without it, but I can retest.

mcooper

  • Posts: 53
Re: BASS for Android
« Reply #1454 on: 12 Sep '18 - 11:25 »
BASS_ChannelGetPosition is used, and it doesn't show the playback position advancing. 

I'll try adding BASS_ChannelGetLevel to see if that returns anything.

I've tested again with and without BASS_STREAM_RESTRATE and it definitely makes a difference.  When I remove it, I can't repro the issue.  When I add it back in, the problem returns.  I've also noticed the the tracks that fail to play are usually longer tracks / bigger media files.

Bass_AAC plugin is used.  I think the files don't play without it, but I can retest.

I've also added in BASS_ChannelGetLevel which returns 0 in the failure case (and a value for streams that play).

Without the Bass_AAC plugin, BASS_StreamCreateURL returns 0 with an error of BASS_ERROR_HANDLE.

I'm rebuilding the app without BASS_STREAM_RESTRATE and extra logging.  I think the removal of that flag solves most or all of the errors.



Ian @ un4seen

  • Administrator
  • Posts: 21363
Re: BASS for Android
« Reply #1455 on: 12 Sep '18 - 17:39 »
BASS_ChannelGetPosition is used, and it doesn't show the playback position advancing. 

OK. That sounds like the stream stops early rather than playing silence. What position is it stopping at, and what does BASS_ChannelIsActive say then? Also check what BASS_StreamGetFilePosition with BASS_FILEPOS_CONNECTED says.

BASS_STREAM_RESTRATE will limit the download rate after the stream has been created, so as the problem is happening after the stream has created then it is possible that it is having some bearing. Of course, it shouldn't result in the stream ending early, so that is something that will need to be fixed in BASS_AAC if it is. The effect of BASS_STREAM_RESTRATE is determined by the BASS_CONFIG_NET_BUFFER setting and the file's bitrate. What BASS_CONFIG_NET_BUFFER setting are you using, and does increasing that prevent the problem happening?

mcooper

  • Posts: 53
Re: BASS for Android
« Reply #1456 on: 14 Sep '18 - 15:28 »
BASS_ChannelGetPosition is used, and it doesn't show the playback position advancing. 

OK. That sounds like the stream stops early rather than playing silence. What position is it stopping at, and what does BASS_ChannelIsActive say then? Also check what BASS_StreamGetFilePosition with BASS_FILEPOS_CONNECTED says.

BASS_STREAM_RESTRATE will limit the download rate after the stream has been created, so as the problem is happening after the stream has created then it is possible that it is having some bearing. Of course, it shouldn't result in the stream ending early, so that is something that will need to be fixed in BASS_AAC if it is. The effect of BASS_STREAM_RESTRATE is determined by the BASS_CONFIG_NET_BUFFER setting and the file's bitrate. What BASS_CONFIG_NET_BUFFER setting are you using, and does increasing that prevent the problem happening?

The playback doesn't start at all - position remains at 0.

BASS_StreamGetFilePosition returns 1 and BASS_ChannelIsActive returns BASS_ACTIVE_STALLED.

BASS_CONFIG_NET_BUFFER was left as the default value (5s?).  I've tried increasing to 30s and I've not been able to repro the problem with that value yet.  I'll keep testing and try some smaller values too.


Ian @ un4seen

  • Administrator
  • Posts: 21363
Re: BASS for Android
« Reply #1457 on: 14 Sep '18 - 16:18 »
BASS_StreamGetFilePosition returns 1 and BASS_ChannelIsActive returns BASS_ACTIVE_STALLED.

That indicates that playback was stalled by BASS because the decoder (BASS_AAC) isn't providing any data to play. I suspect that is happening because the decoder needs data from a later position in the file and it's waiting for the download to reach there, but that is happening very slowly due to BASS_STREAM_RESTRATE being enabled. Here's an update for you to try, which should temporarily disable BASS_STREAM_RESTRATE in that situation:

   www.un4seen.com/stuff/bass_aac-android.zip

Let me know if you still get the problem happening with that.

mcooper

  • Posts: 53
Re: BASS for Android
« Reply #1458 on: 17 Sep '18 - 11:04 »
BASS_StreamGetFilePosition returns 1 and BASS_ChannelIsActive returns BASS_ACTIVE_STALLED.

That indicates that playback was stalled by BASS because the decoder (BASS_AAC) isn't providing any data to play. I suspect that is happening because the decoder needs data from a later position in the file and it's waiting for the download to reach there, but that is happening very slowly due to BASS_STREAM_RESTRATE being enabled. Here's an update for you to try, which should temporarily disable BASS_STREAM_RESTRATE in that situation:

   www.un4seen.com/stuff/bass_aac-android.zip

Let me know if you still get the problem happening with that.

That does seem to fix the issue.  I've added back the BASS_STREAM_RESTRATE flag and have left BASS_CONFIG_NET_BUFFER as the default, and I've not yet been able to repro the issue.

Ian @ un4seen

  • Administrator
  • Posts: 21363
Re: BASS for Android
« Reply #1459 on: 17 Sep '18 - 13:48 »
That's great. I can't think of any other currently supported file formats (besides MP4) that might have this issue, but it would probably be best to have BASS handle the temporary BASS_STREAM_RESTRATE disabling anyway, just in case. So here's a BASS update for you to try:

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

Please see if you can reproduce the problem with that and the previous BASS_AAC version. If you don't still have the previous BASS_AAC version, I've put it back up here:

   www.un4seen.com/stuff/bass_aac-android.zip

mcooper

  • Posts: 53
Re: BASS for Android
« Reply #1460 on: 17 Sep '18 - 14:55 »
That also seems to solve the problem.  Thank you
« Last Edit: 17 Sep '18 - 15:31 by mcooper »

mcooper

  • Posts: 53
Re: BASS for Android
« Reply #1461 on: 10 Oct '18 - 16:07 »
Hello Ian,

We are having another issue preventing playback from working when the android app is in the background.  If we play a track (in the foreground) and then background the app - the next track fails to load.  We think this is related to Android Doze mode (https://developer.android.com/training/monitoring-device-state/doze-standby).  Some devices seem unaffected by this, but by forcing doze mode (adb shell dumpsys deviceidle force-idle) the issue is seems to be reproducible on any device.  We didn't notice this issue before, so it appears to have only started after we included bass_ssl, which we think we require as ssl streams fail on some devices without it.

So, we think that bass_sll doesn't cope with android doze mode.  Is that possible, or do you have any suggestions that we can use to try to debug further?

Thanks,

Matt

Ian @ un4seen

  • Administrator
  • Posts: 21363
Re: BASS for Android
« Reply #1462 on: 10 Oct '18 - 17:40 »
According to the Android documentation, Doze does suspend network access, so BASS_SSL could be affected that way but I would expect the problem to happen without BASS_SSL too, ie. not BASS_SSL specifically. Does the problem not happen when you play a HTTP URL instead of a HTTPS one?

Does your app implement a foreground service? And does whitelisting the app in Android's "Battery optimization" settings page make a difference? I believe either of those things should prevent the app being affected.

mcooper

  • Posts: 53
Re: BASS for Android
« Reply #1463 on: 12 Oct '18 - 10:02 »
Thank you for the suggestion.  Actually the problem did happen with http urls too, so it's not related to bass_sll.

Yes, the app does implement a foreground service, and the problem seemed to be caused by calling Android.App.Service.StopForeground(true) when pausing playback (to allow the user to dismiss the notification).  After this call and subsequently re-promoting the service to the foreground, networking fails. We've taken out the StopForeground call for now.

Ian @ un4seen

  • Administrator
  • Posts: 21363
Re: BASS for Android
« Reply #1464 on: 12 Oct '18 - 15:32 »
A BASS update is up in the first post, to fix support for STREAMPROC constants (eg. STREAMPROC_PUSH) on the arm64-v8a architecture.

Ian @ un4seen

  • Administrator
  • Posts: 21363
Re: BASS for Android
« Reply #1465 on: 30 Oct '18 - 17:15 »
The Android version of the BASSOPUS 2.4.1.12 release is up now in the 1st post.

MB_SOFT

  • Posts: 262
Re: BASS for Android
« Reply #1466 on: 30 Oct '18 - 17:32 »
The Android version of the BASSOPUS 2.4.1.12 release is up now in the 1st post.

thank you for this update! is there an upcoming update for BASSenc_OPUS ?

Ian @ un4seen

  • Administrator
  • Posts: 21363
Re: BASS for Android
« Reply #1467 on: 30 Oct '18 - 18:01 »
Yes, that should be coming later this week.

koczmen22

  • Posts: 2
Re: BASS for Android
« Reply #1468 on: 3 Nov '18 - 10:50 »
Hey Ian,

I'm building a music player for Android and I'm wondering if this would be a good order in a chain of streams:

1. Decoding stream from file  -  This channel applies equalizer, filter and reverb effects.
2. Playback or decoding stream from stream 1 - I split previous stream into 2 to make a multiband compressor. LPF, HPF and compressor are applied on splits, then they are mixed together.
3. (optional) Tempo stream - if enabled, stream 2 is set to decoding and tempo, pitch and sample rate are applied to this one.
4. (optional) If there are more than 2 audio channels in the file I split them, assign them to available speakers and mix them together.

Also, where would be the best place to put BASS_FX_BFX_VOLUME?
« Last Edit: 3 Nov '18 - 13:22 by koczmen22 »

Ian @ un4seen

  • Administrator
  • Posts: 21363
Re: BASS for Android
« Reply #1469 on: 5 Nov '18 - 17:10 »
The Android versions of the new BASSenc_MP3 and BASSenc_OPUS releases are now up in the 1st post.

Ian @ un4seen

  • Administrator
  • Posts: 21363
Re: BASS for Android
« Reply #1470 on: 6 Nov '18 - 17:22 »
I'm building a music player for Android and I'm wondering if this would be a good order in a chain of streams:

1. Decoding stream from file  -  This channel applies equalizer, filter and reverb effects.
2. Playback or decoding stream from stream 1 - I split previous stream into 2 to make a multiband compressor. LPF, HPF and compressor are applied on splits, then they are mixed together.
3. (optional) Tempo stream - if enabled, stream 2 is set to decoding and tempo, pitch and sample rate are applied to this one.
4. (optional) If there are more than 2 audio channels in the file I split them, assign them to available speakers and mix them together.

Also, where would be the best place to put BASS_FX_BFX_VOLUME?

If you want to support seeking, it may be better to apply the tempo processing to the file stream rather than the split/remixed stream. You will then be able to make the BASS_ChannelSetPosition calls on the tempo stream, and it will forward the requests to the file stream. Otherwise you will need to seek on the file stream and separately reset the tempo stream.

For step 4, you could possibly use matrix mixing instead of splitting and remixing, but some effects don't support more than stereo, so I guess you may be splitting for that reason?

Do you have the BASS_FX_BFX_VOLUME effect in mind for playback volume control? If so, it's generally better to use the BASS_ATTRIB_VOL option for that, for lower latency in volume changes.

Ian @ un4seen

  • Administrator
  • Posts: 21363
Re: BASS for Android
« Reply #1471 on: 6 Nov '18 - 17:23 »
The Android version of the BASSenc_FLAC 2.4.2 release is up now in the 1st post.

koczmen22

  • Posts: 2
Re: BASS for Android
« Reply #1472 on: 6 Nov '18 - 23:12 »

If you want to support seeking, it may be better to apply the tempo processing to the file stream rather than the split/remixed stream. You will then be able to make the BASS_ChannelSetPosition calls on the tempo stream, and it will forward the requests to the file stream. Otherwise you will need to seek on the file stream and separately reset the tempo stream.


I've already implemented seeking on the first decoding stream and it seems to work fine.

For step 4, you could possibly use matrix mixing instead of splitting and remixing, but some effects don't support more than stereo, so I guess you may be splitting for that reason?

For now I just want to assign 6 / 8 channels to correct speakers when there are only 2 channels available on the device. I'll look into matrix mixing if it's a better way.

Do you have the BASS_FX_BFX_VOLUME effect in mind for playback volume control? If so, it's generally better to use the BASS_ATTRIB_VOL option for that, for lower latency in volume changes.

More like a preamp control for balancing the output gain when equalizer or filter parameters are modified.

Ian @ un4seen

  • Administrator
  • Posts: 21363
Re: BASS for Android
« Reply #1473 on: 7 Nov '18 - 14:32 »
For now I just want to assign 6 / 8 channels to correct speakers when there are only 2 channels available on the device. I'll look into matrix mixing if it's a better way.

If you want to downmix 6/8 channels to stereo then matrix mixing is what you want. BASSmix has default matrices for that, which you can enable via the BASS_MIXER_DOWNMIX flag (in the BASS_Mixer_StreamAddChannel/Ex call).

Do you have the BASS_FX_BFX_VOLUME effect in mind for playback volume control? If so, it's generally better to use the BASS_ATTRIB_VOL option for that, for lower latency in volume changes.

More like a preamp control for balancing the output gain when equalizer or filter parameters are modified.

OK, in that case, it should probably be applied after the EQ, on the same channel handle. You can enforce that by giving the BASS_FX_BFX_VOLUME (or BASS_FX_VOLUME) effect a lower "priority" value than the EQ effect(s) in their BASS_ChannelSetFX calls.

Ian @ un4seen

  • Administrator
  • Posts: 21363
Re: BASS for Android
« Reply #1474 on: 9 Nov '18 - 17:40 »
The Android version of the BASSMIDI 2.4.12 release is up now in the 1st post.