Author Topic: BASS for Android  (Read 392343 times)

Ian @ un4seen

  • Administrator
  • Posts: 20437
Re: BASS for Android
« Reply #950 on: 26 Aug '15 - 15:22 »
There is indeed such an option, which you can enable by adding the BASS_STREAM_PRESCAN flag to your BASS_StreamCreateFile call.

bracken

  • Posts: 9
Re: BASS for Android
« Reply #951 on: 31 Aug '15 - 02:43 »
Yes, thanks very much.  The BASS_STREAM_PRESCAN flag works well.

cameronkkk

  • Posts: 4
Re: BASS for Android
« Reply #952 on: 4 Sep '15 - 07:58 »
Hi Ian,

Used the sample code to play midi and some notes are missing(played the same midi  file with the sample code

and windows media player) 

How could I correct this problem? I've changed the midi file attached to format 0

but didn't solved the missing notes problem.

URL for  sample code downloaded
 www.un4seen.com/stuff/bass24-android.zip


Ian @ un4seen

  • Administrator
  • Posts: 20437
Re: BASS for Android
« Reply #953 on: 4 Sep '15 - 17:09 »
That MIDI file uses the sustain pedal a lot, so there may be quite a lot of notes playing at times. The default limit of 40 voices on Android might not be enough. You could try raising that via the BASS_ATTRIB_MIDI_VOICES (or BASS_CONFIG_MIDI_VOICES) option. For example, you could add this line after the MIDITEST example's BASS_MIDI_StreamCreateFile call to raise its limit to 100 voices:

Code: [Select]
BASS.BASS_ChannelSetAttribute(chan, BASSMIDI.BASS_ATTRIB_MIDI_VOICES, 100);

cameronkkk

  • Posts: 4
Re: BASS for Android
« Reply #954 on: 7 Sep '15 - 09:38 »
 :o

Hi Ian,

I've read it on the book
but never occur to me that cc64 will cause the missing notes issue

Some Android APP use BASSMIDI has similar issue but the
bug still exist.

I'll modify the code and test again

Regards,
Yuanhou

gicci

  • Posts: 34
Re: BASS for Android
« Reply #955 on: 16 Sep '15 - 21:48 »
Hi,

If I call:

BASS.BASS_SetConfig(BASS.BASS_CONFIG_REC_BUFFER, bufferTime);

with bufferTime set to 3000 I get the following error in the log:

09-16 22:43:59.641  32038-32038/E/libOpenSLES﹕ pAudioSnk: numBuffers=300
09-16 22:43:59.641  32038-32038/W/libOpenSLES﹕ Leaving Engine::CreateAudioRecorder (SL_RESULT_PARAMETER_INVALID)

If I use 2000 (the default value?) it works. Am I doing something wrong?

Thank you!

Ian @ un4seen

  • Administrator
  • Posts: 20437
Re: BASS for Android
« Reply #956 on: 17 Sep '15 - 17:44 »
An update to fix that recording buffer size limitation in the Android BASS version is up now in the 1st post, so please re-download to get that.

gicci

  • Posts: 34
Re: BASS for Android
« Reply #957 on: 19 Sep '15 - 23:13 »
Works fine, thank you.  :)

norbert

  • Posts: 122
Re: BASS for Android
« Reply #958 on: 20 Sep '15 - 10:22 »
Is it correct that when using BASS_MIDI_DECAYEND this also applies to decoding channels, ie. when exporting to a wav file, the BASS.BASS_ChannelGetData might return more data at the end of file, ie. the exported wav file might be one or more seconds longer as when not using this flag ?

Ian @ un4seen

  • Administrator
  • Posts: 20437
Re: BASS for Android
« Reply #959 on: 21 Sep '15 - 15:56 »
Yes, the BASS_MIDI_DECAYEND option does apply to decoding channels too, so they may produce more data than BASS_ChannelGetLength suggests in that case.

jnyang

  • Guest
Re: BASS for Android
« Reply #960 on: 2 Oct '15 - 16:20 »
Hi,

I'm trying to use MP3-Free version of the BASS (the latest version) which uses native decoder in Android OS. However, when I tried to play 31st MP3 file, it always throws following JNI related error:

Code: [Select]
E/dalvikvm( 5223): JNI ERROR (app bug): local reference table overflow (max=512)
W/dalvikvm( 5223): JNI local reference table (0x66f81268) dump:
W/dalvikvm( 5223):   Last 10 entries (of 512):
W/dalvikvm( 5223):       511: 0x42a281a0 java.lang.String "sample-rate"
W/dalvikvm( 5223):       510: 0x41913980 java.lang.Class<java.nio.ByteBuffer>
W/dalvikvm( 5223):       509: 0x41914bb8 java.lang.Class<java.lang.Float>
W/dalvikvm( 5223):       508: 0x41915dd0 java.lang.Class<java.lang.Long>
W/dalvikvm( 5223):       507: 0x41915c80 java.lang.Class<java.lang.Integer>
W/dalvikvm( 5223):       506: 0x419100e0 java.lang.Class<java.lang.String>
W/dalvikvm( 5223):       505: 0x42aa93d8 java.lang.Object[] (3 elements)
W/dalvikvm( 5223):       504: 0x42aa93b8 java.lang.String[] (3 elements)
W/dalvikvm( 5223):       503: 0x42aa9290 android.media.MediaCodec
W/dalvikvm( 5223):       502: 0x42aa92c8 android.media.MediaFormat
W/dalvikvm( 5223):   Summary:
W/dalvikvm( 5223):       195 of java.lang.Class (9 unique instances)
W/dalvikvm( 5223):         1 of java.lang.Object[] (3 elements)
W/dalvikvm( 5223):         1 of java.lang.String
W/dalvikvm( 5223):         1 of java.lang.String[] (3 elements)
W/dalvikvm( 5223):        62 of java.nio.ByteBuffer[] (5 elements) (62 unique instances)
W/dalvikvm( 5223):        62 of java.nio.ByteBuffer[] (10 elements) (62 unique instances)
W/dalvikvm( 5223):        64 of android.media.MediaCodec (63 unique instances)
W/dalvikvm( 5223):        63 of android.media.MediaFormat (63 unique instances)
W/dalvikvm( 5223):        62 of android.media.MediaCodec$BufferInfo (62 unique instances)
E/dalvikvm( 5223): Failed adding to JNI local ref table (has 512 entries)

Other file formats (e.g. ogg, wav) work well. Could you give me a hand to solve this issue?

Thanks in advance for your help. :)

Ian @ un4seen

  • Administrator
  • Posts: 20437
Re: BASS for Android
« Reply #961 on: 2 Oct '15 - 17:40 »
That looks like there were too many Java object references, but I don't seem to be able to reproduce it here (I tried creating 100s of MP3 streams without freeing them), so I'm not sure what would be causing it. A few questions to perhaps get some clues... Do you have 31 MP3 streams in existence at the same time or is it one at a time, ie. are you freeing the old stream before creating a new stream? Does it make any difference? If it happens even when there is only one stream at a time, can you reproduce it with the examples included in the BASS package? Also, does it matter what MP3 files you open? Also, what Android version are you using, and are you able to reproduce the problem on multiple devices?

Nano-Tek

  • Posts: 9
Re: BASS for Android
« Reply #962 on: 3 Oct '15 - 22:16 »
Hi. When i try to call method Bass.Bass_ChannelBytes2Seconds(Bass.Bass_ChannelGetLength(....)), i receive this log:
A/libc(5525): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 5583 (MediaCodec_loop)

I work with mp3 files


Sorry, it's my error, i used mp3-free bass version, but i tested on android 4.1.2 and this version should to work.
« Last Edit: 4 Oct '15 - 11:38 by Nano-Tek »

UserAlexandr

  • Posts: 37
Re: BASS for Android
« Reply #963 on: 4 Oct '15 - 12:00 »
I try to play only part of the track, but I have an error while trying to use - "BASS.BASS_StreamFree(channelHandle)"

Error:
Code: [Select]
10-04 07:04:19.518: A/libc(2321): Fatal signal 11 (SIGSEGV) at 0x00000010 (code=1), thread 2335

In MixSync:
Code: [Select]
private final BASS.SYNCPROC MixSync = new BASS.SYNCPROC()
{
public void SYNCPROC(int handle, int channel, int data, Object user)
{
BASS.BASS_ChannelStop(channelHandle);
BASS.BASS_MusicFree(channelHandle);
//BASS.BASS_StreamFree(channelHandle); // Crash (100%)
//OpenStream(getPath(index + 1)); // Crash some time (50/50)
}
};

In OpenStream:
Code: (Java) [Select]
//BASS.BASS_ChannelSetSync(channelHandle, BASS.BASS_SYNC_END, 0, EndSync, 0); // Default
BASS.BASS_ChannelSetSync(channelHandle, BASS.BASS_SYNC_POS | BASS.BASS_SYNC_MIXTIME, BASS.BASS_ChannelSeconds2Bytes(channelHandle, 10), MixSync, 0);

I need to play only part of the song as it is necessary for the CUE file.
Maybe there is another way to play CUE (flac)?
« Last Edit: 5 Oct '15 - 11:47 by UserAlexandr »

Ian @ un4seen

  • Administrator
  • Posts: 20437
Re: BASS for Android
« Reply #964 on: 5 Oct '15 - 14:59 »
It isn't safe to call BASS_StreamFree within a mixtime sync's SYNCPROC function. You probably don't actually want to free the stream at that point anyway as there will be buffered data that hasn't been played yet. If you want to free the stream at the sync position, you could set a 2nd non-mixtime sync for that, ie. the mixtime sync only calls BASS_ChannelStop and the non-mixtime sync only calls BASS_StreamFree.

UserAlexandr

  • Posts: 37
Re: BASS for Android
« Reply #965 on: 5 Oct '15 - 15:13 »
Thanks for the answer.

you could set a 2nd non-mixtime sync for that.

How to do this? MixSync only stop track...
I need to switch to another song (another file) after MixSync.
« Last Edit: 5 Oct '15 - 15:42 by UserAlexandr »

Ian @ un4seen

  • Administrator
  • Posts: 20437
Re: BASS for Android
« Reply #966 on: 5 Oct '15 - 17:49 »
Using the 2 syncs could look something like this:

Code: [Select]
private final BASS.SYNCPROC StopSync = new BASS.SYNCPROC()
{
public void SYNCPROC(int handle, int channel, int data, Object user)
{
BASS.BASS_ChannelStop(channel);
}
};

private final BASS.SYNCPROC FreeSync = new BASS.SYNCPROC()
{
public void SYNCPROC(int handle, int channel, int data, Object user)
{
if (!BASS.BASS_MusicFree(channel))
BASS.BASS_StreamFree(channel);
}
};

...

BASS.BASS_ChannelSetSync(channelHandle, BASS.BASS_SYNC_POS | BASS.BASS_SYNC_MIXTIME, BASS.BASS_ChannelSeconds2Bytes(channelHandle, 10), StopSync, 0);
BASS.BASS_ChannelSetSync(channelHandle, BASS.BASS_SYNC_POS, BASS.BASS_ChannelSeconds2Bytes(channelHandle, 10), FreeSync, 0);

Regarding switching to another song, you could call BASS_ChannelPlay on the next song's stream in the FreeSync function above, ie. when playback reaches the end of the current stream. To avoid delays, the next stream should be created some time before then, eg. the StopSync function could perhaps launch a worker thread to create the next stream.

UserAlexandr

  • Posts: 37
Re: BASS for Android
« Reply #967 on: 5 Oct '15 - 18:22 »
Using the 2 syncs could look something like this:

Code: [Select]
private final BASS.SYNCPROC StopSync = new BASS.SYNCPROC()
{
public void SYNCPROC(int handle, int channel, int data, Object user)
{
BASS.BASS_ChannelStop(channel);
}
};

private final BASS.SYNCPROC FreeSync = new BASS.SYNCPROC()
{
public void SYNCPROC(int handle, int channel, int data, Object user)
{
if (!BASS.BASS_MusicFree(channel))
BASS.BASS_StreamFree(channel);
}
};

...

BASS.BASS_ChannelSetSync(channelHandle, BASS.BASS_SYNC_POS | BASS.BASS_SYNC_MIXTIME, BASS.BASS_ChannelSeconds2Bytes(channelHandle, 10), StopSync, 0);
BASS.BASS_ChannelSetSync(channelHandle, BASS.BASS_SYNC_POS, BASS.BASS_ChannelSeconds2Bytes(channelHandle, 10), FreeSync, 0);

Regarding switching to another song, you could call BASS_ChannelPlay on the next song's stream in the FreeSync function above, ie. when playback reaches the end of the current stream. To avoid delays, the next stream should be created some time before then, eg. the StopSync function could perhaps launch a worker thread to create the next stream.

Thanks for your help, It works very well )))
« Last Edit: 5 Oct '15 - 18:29 by UserAlexandr »

popo0209

  • Posts: 2
I Found it bug
« Reply #968 on: 9 Oct '15 - 12:52 »
When I play the 1 channels file, I found it bug to set Position and get Position by BASS_POS_BYTE

1. stop play
2. call
    long pos1 = BASS.BASS_ChannelGetPosition(chan, BASS.BASS_POS_BYTE);
3. call
    BASS.BASS_ChannelSetPosition(chan, pos1, BASS.BASS_POS_BYTE);
4. start play

2 channels files play subsequently
but 1 channel files play other position

If you want example files
please send me e-mail

Ian @ un4seen

  • Administrator
  • Posts: 20437
Re: BASS for Android
« Reply #969 on: 9 Oct '15 - 16:48 »
I presume the "stop play" and "start play" steps are BASS_ChanneStop and BASS_ChannelPlay calls? I don't seem to be able to reproduce the problem here, so please do send an example file. You can upload it here:

   ftp.un4seen.com/incoming/

Also, how far away is the heard position from where it should be?

doomplay

  • Posts: 33
Re: BASS for Android
« Reply #970 on: 9 Oct '15 - 17:43 »
Critical issue comes with Android 6.0!
When i try to play any audio from internet which url starts from https:// i get the error - 10 (error code)
Everything fine with http or on android 5.1.
Please fix it, i'm using the latest version of BASS

popo0209

  • Posts: 2
Re: BASS for Android
« Reply #971 on: 10 Oct '15 - 08:43 »
I uploaded the problem file. (TED: Ilona Szabo-de-Carvalho (2014 Global).mp3)

and heard position is 7 seconds which presenter start to tell

1.
BASS.BASS_ChannelStop(chan);

2.             
long pos = BASS.BASS_StreamGetFilePosition(chan, BASS.BASS_POS_BYTE);

3.             
BASS.BASS_ChannelSetPosition(chan, pos, BASS.BASS_POS_BYTE);

4.            
BASS.BASS_ChannelPlay(chan, false);

5.
The file play other position

morenoadan22

  • Posts: 1
Re: BASS for Android
« Reply #972 on: 10 Oct '15 - 09:35 »
Is it possible to modify the playback tempo of a stream where I have created using:

BASS_StreamCreateURL(....)

I have tried using the following calls with no success:

- BASS.BASS_ChannelSetAttribute(channel, BASS.BASS_ATTRIB_MUSIC_BPM, <new bpm>);

- BASS.BASS_ChannelSetAttribute(channel, BASS_FX.BASS_ATTRIB_TEMPO, <new bpm>);

I am trying to follow the NetRadio and the BPM example from the bass and bass_fx libraries.

Ian @ un4seen

  • Administrator
  • Posts: 20437
Re: BASS for Android
« Reply #973 on: 12 Oct '15 - 12:58 »
Critical issue comes with Android 6.0!
When i try to play any audio from internet which url starts from https:// i get the error - 10 (error code)
Everything fine with http or on android 5.1.
Please fix it, i'm using the latest version of BASS

Error code 10 is BASS_ERROR_SSL, which means that the OpenSSL library couldn't be loaded/initialized. I'll send you a debug version to get more info on what's happening on your device.

I uploaded the problem file. (TED: Ilona Szabo-de-Carvalho (2014 Global).mp3)

That's a VBR MP3 file, which unfortunately don't support accurate seeking because they only include a very basic seek table. You can use the BASS_STREAM_PRESCAN flag in your BASS_StreamCreateFile call to have BASS build its own seek table (note that the call will take longer then as it has to scan the entire file). Another option is to add the BASS_POS_SCAN flag to the BASS_ChannelSetPosition call, to have the seek table built while seeking.

Is it possible to modify the playback tempo of a stream where I have created using:

BASS_StreamCreateURL(....)

I have tried using the following calls with no success:

- BASS.BASS_ChannelSetAttribute(channel, BASS.BASS_ATTRIB_MUSIC_BPM, <new bpm>);

- BASS.BASS_ChannelSetAttribute(channel, BASS_FX.BASS_ATTRIB_TEMPO, <new bpm>);

The BASS_FX.BASS_ATTRIB_TEMPO is the option you want, but you will need to call BASS_FX_TempoCreate first. Something like this:

Code: [Select]
channel=BASS.BASS_StreamCreate(url, 0, BASS.BASS_STREAM_DECODE, null, null);
channel=BASS_FX.BASS_FX_StreamCreate(channel, BASS_FX.BASS_FX_FREESOURCE);
BASS.BASS_ChannelSetAttribute(channel, BASS_FX.BASS_ATTRIB_TEMPO, bpmchange); // note "bpmchange" is a percentage

If you're playing an internet radio stream, then changing the tempo won't work very well because the playback rate won't match the server's broadcast rate. Changing the pitch (BASS_ATTRIB_TEMPO_PITCH) should be fine though.

doomplay

  • Posts: 33
Re: BASS for Android
« Reply #974 on: 12 Oct '15 - 14:10 »
Critical issue comes with Android 6.0!
When i try to play any audio from internet which url starts from https:// i get the error - 10 (error code)
Everything fine with http or on android 5.1.
Please fix it, i'm using the latest version of BASS

Error code 10 is BASS_ERROR_SSL, which means that the OpenSSL library couldn't be loaded/initialized. I'll send you a debug version to get more info on what's happening on your device.


Okay.
And please read it https://developer.android.com/about/versions/marshmallow/android-6.0-changes.html
Docs say that android move away from OpenSSL library.