Author Topic: BASS for Android  (Read 391887 times)

Ian @ un4seen

  • Administrator
  • Posts: 20424
Re: BASS for Android
« Reply #975 on: 12 Oct '15 - 17:24 »
That would explain it :) ... I'll look into a solution.

alexanderbaars

  • Posts: 6
Re: BASS for Android
« Reply #976 on: 13 Oct '15 - 10:43 »
I was just about to post the same issue.
Obviously I am not the only one...

Best regards,

Alex

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.

Ian @ un4seen

  • Administrator
  • Posts: 20424
Re: BASS for Android
« Reply #977 on: 13 Oct '15 - 16:32 »
Here's an update for both of you to try:

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

Please report how you get on with it.

alexanderbaars

  • Posts: 6
Re: BASS for Android
« Reply #978 on: 13 Oct '15 - 16:50 »
I tried quickly in the emulator and it seems to work fine.
I will keep you posted as soon as I tested on device.

Thanks alot!

doomplay

  • Posts: 33
Re: BASS for Android
« Reply #979 on: 13 Oct '15 - 17:42 »
Here's an update for both of you to try:

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

Please report how you get on with it.
Seems it's fine now. Don't know about speed, but it opens file correctly now
Thank you!

And question - Is there any difference in speed/resources between opening https and http?

alexanderbaars

  • Posts: 6
Re: BASS for Android
« Reply #980 on: 13 Oct '15 - 19:29 »
I tested the https modification for marshmallow on an android galaxy tab 10.1 running 4.0.4 just to be sure.
It works fine.
I also tested on a nexus5 running Marshmallow, also good.

Best regards,

Alex

I tried quickly in the emulator and it seems to work fine.
I will keep you posted as soon as I tested on device.

Thanks alot!

Ian @ un4seen

  • Administrator
  • Posts: 20424
Re: BASS for Android
« Reply #981 on: 14 Oct '15 - 13:07 »
Good to hear that the update is working well so far. Let me know if that changes.

And question - Is there any difference in speed/resources between opening https and http?

HTTPS is bound to use a bit more CPU and memory than HTTP, but probably nothing very noticeable. You could use a CPU/memory monitoring app to check that.

glook

  • Posts: 1
Re: BASS for Android
« Reply #982 on: 14 Oct '15 - 20:09 »
Hi,

I have downloaded the latest BASS update (9 oct 15) and I'm having some problems that seem to be volume-related. Every sample seems to be played at a very high volume that is overloading the speakers. I'm experiencing this issue on lenovo a5500. I'm using the mp3-free version of BASS. This problem doesn't happen with older libraries (i.e. 31 may 15).

Ian @ un4seen

  • Administrator
  • Posts: 20424
Re: BASS for Android
« Reply #983 on: 15 Oct '15 - 13:08 »
Oops! The last update did indeed introduce a bug resulting in distorted sample (HCHANNEL) playback. Another update to fix that is now up in the 1st post, so please re-download to get that. This update also includes the Android 6 HTTPS support.

UserAlexandr

  • Posts: 37
Re: BASS for Android
« Reply #984 on: 17 Oct '15 - 17:05 »
Hello, I have a little lag interface, from OpenStream, even when I try to run it in another thread...

Code: [Select]
final Thread t = new Thread(new Runnable() {
  @Override
  public void run() {
OpenStream(path);
  }        
});
t.start();

This code runs in main thread?  ???
Code: [Select]
public int OpenStream(String path) {
BASS.BASS_MusicFree(channelHandle);
BASS.BASS_StreamFree(channelHandle);

if((channelHandle=BASS.BASS_StreamCreateFile(path, 0, 0, BASS.BASS_MUSIC_STOPBACK))==0
&& (channelHandle=BASS.BASS_MusicLoad(path, 0, 0, BASS.BASS_SAMPLE_LOOP|BASS.BASS_MUSIC_RAMP, 1))==0) {
DEBUG.Log("BASS", "Can't play the file!");
DEBUG.Log("BASS", path);
return ERROR;
}
BASS.BASS_ChannelSetSync(channelHandle, BASS.BASS_SYNC_END, 0, EndSync, 0);
BASS.BASS_ChannelPlay(channelHandle, true);
return OK;
}
« Last Edit: 17 Oct '15 - 20:43 by UserAlexandr »

doomplay

  • Posts: 33
Re: BASS for Android
« Reply #985 on: 19 Oct '15 - 10:15 »
Hello, I have a little lag interface, from OpenStream, even when I try to run it in another thread...

Code: [Select]
final Thread t = new Thread(new Runnable() {
  @Override
  public void run() {
OpenStream(path);
  }        
});
t.start();


This code runs in main thread?  ???
Code: [Select]
public int OpenStream(String path) {
BASS.BASS_MusicFree(channelHandle);
BASS.BASS_StreamFree(channelHandle);

if((channelHandle=BASS.BASS_StreamCreateFile(path, 0, 0, BASS.BASS_MUSIC_STOPBACK))==0
&& (channelHandle=BASS.BASS_MusicLoad(path, 0, 0, BASS.BASS_SAMPLE_LOOP|BASS.BASS_MUSIC_RAMP, 1))==0) {
DEBUG.Log("BASS", "Can't play the file!");
DEBUG.Log("BASS", path);
return ERROR;
}
BASS.BASS_ChannelSetSync(channelHandle, BASS.BASS_SYNC_END, 0, EndSync, 0);
BASS.BASS_ChannelPlay(channelHandle, true);
return OK;
}

Depends on where you call OpenStream method. If call it in new Thread(new Runnable(.....)); then NO It runs in another thread.
You could google it first...

UserAlexandr

  • Posts: 37
Re: BASS for Android
« Reply #986 on: 19 Oct '15 - 10:54 »
I found my error...

doomplay

  • Posts: 33
Re: BASS for Android
« Reply #987 on: 26 Oct '15 - 22:33 »
Hi. I have big issue! Some files are played with 2x acceleration (speed and pitch). Here's link on example of such files https://mega.nz/#!rwcXmADD!qhk8qNZS-czBWGTw7Pjxnds1dpKG1Ln-p9knkRZ0qt8

Here is code how i play the file. Have you any suggestions how to fix it?

Code: [Select]
        final int chan = BASS.BASS_StreamCreateFile(url, 0, 0, BASS.BASS_STREAM_DECODE);

        BASS.BASS_CHANNELINFO info = new BASS.BASS_CHANNELINFO();
        BASS.BASS_ChannelGetInfo(chan,info);
       
        int sampleRateInHz = info.freq;

        final int audioFormat = AudioFormat.ENCODING_PCM_16BIT;
        final int audioBufferSizeBytes = AudioTrack.getMinBufferSize(sampleRateInHz, AudioFormat.CHANNEL_OUT_STEREO,
                audioFormat);
        final AudioTrack audioTrack = new AudioTrack(AudioManager.STREAM_MUSIC,sampleRateInHz,
                AudioFormat.CHANNEL_OUT_STEREO, audioFormat, audioBufferSizeBytes
                , AudioTrack.MODE_STREAM,audioTrackSessionId);

        new Thread(new Runnable() {
            @Override public void run() {
                ByteBuffer buffer = ByteBuffer.allocate(audioBufferSizeBytes);
                int res = 0;
                while (res != -1) {

                    while (audioTrack.getPlayState() != AudioTrack.PLAYSTATE_PLAYING) {
                        try {
                            Thread.sleep(50);
                        } catch (InterruptedException e) {
                        }
                    }

                    res = BASS.BASS_ChannelGetData(chan, buffer, audioBufferSizeBytes);

                    if (res > 0) {
                        try {
                            audioTrack.write(buffer.array(), 0, res); // feed it to AudioTrack
                        }catch (IllegalStateException e){
                            break;
                        }
                    } else {
                        try {
                            Thread.sleep(1000);
                        } catch (InterruptedException e) {
                        }
                    }
                }
            }
        }).start();
 audioTrack.play();

Ian @ un4seen

  • Administrator
  • Posts: 20424
Re: BASS for Android
« Reply #988 on: 27 Oct '15 - 15:21 »
The issue there appears to be that the file is mono while your AudioTrack output is stereo (AudioFormat.CHANNEL_OUT_STEREO). This modification should fix it:

Code: [Select]
        final AudioTrack audioTrack = new AudioTrack(AudioManager.STREAM_MUSIC,sampleRateInHz,
                info.chans==2?AudioFormat.CHANNEL_OUT_STEREO:AudioFormat.CHANNEL_OUT_MONO, audioFormat, audioBufferSizeBytes
                , AudioTrack.MODE_STREAM,audioTrackSessionId);

doomplay

  • Posts: 33
Re: BASS for Android
« Reply #989 on: 28 Oct '15 - 16:51 »
The issue there appears to be that the file is mono while your AudioTrack output is stereo (AudioFormat.CHANNEL_OUT_STEREO). This modification should fix it:

Code: [Select]
        final AudioTrack audioTrack = new AudioTrack(AudioManager.STREAM_MUSIC,sampleRateInHz,
                info.chans==2?AudioFormat.CHANNEL_OUT_STEREO:AudioFormat.CHANNEL_OUT_MONO, audioFormat, audioBufferSizeBytes
                , AudioTrack.MODE_STREAM,audioTrackSessionId);
Thank you! It works well

Aleksandr

  • Guest
How to specify charset encoding for meta?
« Reply #990 on: 29 Oct '15 - 08:04 »
Hi!
I have issues with encoding of the meta tags received from some shoutcast/icecast streaming servers. If server uses non-UTF8 encoding (particularly Windows-1251) and meta contains non-ASCII characters, I got unreadable string from BASS.
For example, server http://radio-tochka.com:6180/; sends meta "StreamTitle='ч.2 - Россия перед пришествием антихриста'" but BASS return "StreamTitle='ч.2 - Россия перед пришествием антихриста'".
I use this code for extracting meta tags:
Code: [Select]
private BASS.SYNCPROC metaCallback = new BASS.SYNCPROC() {
    public void SYNCPROC(int handle, int channel, int data, Object user) {
        String meta = (String) BASS.BASS_ChannelGetTags(streamHandle, BASS.BASS_TAG_META);
    }
};
I think BASS uses default encoding (UTF-8 on Android) for decoding meta tags. Is there any way to specify which encoding to use or, alternatively, to receive the raw bytes of the meta tags?

Ian @ un4seen

  • Administrator
  • Posts: 20424
Re: BASS for Android
« Reply #991 on: 29 Oct '15 - 17:54 »
Yep, Java strings are UTF-8, so BASS_ChannelGetTags does indeed convert the Shoutcast metadata to UTF-8 (if isn't already) for Java (not for native code). That conversion is currently assuming ISO-8859-1 (Windows-1252). I will look into adding an option to have it deliver a ByteBuffer containing the original unmodified data (like delivered to native code).

sunny

  • Guest
Re: BASS for Android
« Reply #992 on: 30 Oct '15 - 08:20 »
Hi:
     I'd like to make a tape recorder with background music. Are your library files supported?
if can,could you help me?
                                    Thanks

Tyler Smith

  • Guest
Re: BASS for Android
« Reply #993 on: 30 Oct '15 - 11:29 »
Hi.
I try to use BASS, but it takes a lot of cpu in compare with default MediaPlayer class. Can you give me some advices how to decrease cpu usage? May be there are some configs for its? I also use equalizer BASS_FX.

Ian @ un4seen

  • Administrator
  • Posts: 20424
Re: BASS for Android
« Reply #994 on: 30 Oct '15 - 15:50 »
I will look into adding an option to have it deliver a ByteBuffer containing the original unmodified data (like delivered to native code).

A BASS update is now up in the 1st post, adding a new BASS_TAG_BYTEBUFFER flag that can be used in BASS_ChannelGetTags calls to request a ByteBuffer instead of a String. For example, you could do something like this:

Code: [Select]
ByteBuffer metabuf=(ByteBuffer)BASS.BASS_ChannelGetTags(streamHandle, BASS.BASS_TAG_META|BASS.BASS_TAG_BYTEBUFFER); // get Shoutcast metadata in ByteBuffer form
byte[] b=new byte[metabuf.capacity()]; // allocate byte array
metabuf.get(b); // copy ByteBuffer content to byte array
try {
meta=new String(b, "cp1251"); // convert bytes to string using cp1251 character set
} catch (UnsupportedEncodingException e) {
}
...

As well as string tag types, the BASS_TAG_BYTEBUFFER flag can also be used with ID3v1 tags (BASS_TAG_ID3).

     I'd like to make a tape recorder with background music. Are your library files supported?
if can,could you help me?

If I understand correctly, you want to record from the mic, mix that with an existing audio file, and write the mix to a new file? If so, that should be possible, but perhaps not the simplest task to begin with. You would need to create a recording channel and a decoder for the audio file, and create a mixer to mix them. That could look something like this:

Code: [Select]
decoder=BASS.BASS_StreamCreateFile(filename, 0, 0, BASS.BASS_STREAM_DECODE); // create decoder for audio file
recorder=BASS.BASS_RecordStart(44100, 1, 0, null, null); // create recording channel
mixer=BASSmix.BASS_Mixer_StreamCreate(44100, 2, BASS.BASS_STREAM_DECODE); // create mixer
BASSmix.BASS_Mixer_StreamAddChannel(mixer, decoder, 0); // add the decoder to the mix
BASSmix.BASS_Mixer_StreamAddChannel(mixer, recorder, BASSmix.BASS_MIXER_LIMIT); // add the recorder to the mix

...

// processing loop in worker thread
ByteBuffer buffer=ByteBuffer.allocateDirect(20000);
while (!quit) {
int got=BASS.BASS_ChannelGetData(mixer, buffer, 20000); // get data from the mixer
if (got<0) break; // error
if (got>0) {
// do something with "got" bytes of data in "buffer" here, eg. write it
} else
Thread.sleep(100); // wait for more data from the recording
}

Please see the documentation for details on the mentioned functions. The BASSenc add-on (eg. BASS_Encode_Start) could be used to write the mix to a file, but it only supports WAV writing by default. To write an encoded file, you will need to include an encoder library (eg. LAME) in your app, or perhaps use Android's MediaCodec class.

I try to use BASS, but it takes a lot of cpu in compare with default MediaPlayer class. Can you give me some advices how to decrease cpu usage? May be there are some configs for its? I also use equalizer BASS_FX.

What CPU does your device have, and what CPU usage levels are you seeing in each case, also without the BASS_FX equalizer? Also, are you having the issue with a particular file/format?

Nano-Tek

  • Posts: 9
Re: BASS for Android
« Reply #995 on: 30 Oct '15 - 17:12 »
HTC One S Caused Exception Why?

if (!BASS.BASS_Init(-1, 44100, 0))
   throw new ExceptionInInitializerError("Bass initialize error");

Ian @ un4seen

  • Administrator
  • Posts: 20424
Re: BASS for Android
« Reply #996 on: 30 Oct '15 - 17:19 »
To find out why the BASS_Init call failed, please call BASS_ErrorGetCode to get an error code and then look that up in the BASS_Init documentation.

Aleksandr

  • Guest
Re: BASS for Android
« Reply #997 on: 31 Oct '15 - 11:24 »
A BASS update is now up in the 1st post, adding a new BASS_TAG_BYTEBUFFER flag that can be used in BASS_ChannelGetTags calls to request a ByteBuffer instead of a String. For example, you could do something like this:
Great! Thank you so much for efficiency!

Tyler Smith

  • Guest
Re: BASS for Android
« Reply #998 on: 4 Nov '15 - 11:28 »

I try to use BASS, but it takes a lot of cpu in compare with default MediaPlayer class. Can you give me some advices how to decrease cpu usage? May be there are some configs for its? I also use equalizer BASS_FX.

What CPU does your device have, and what CPU usage levels are you seeing in each case, also without the BASS_FX equalizer? Also, are you having the issue with a particular file/format?

0. After tests i found that a music shutters even without BASS_FX equalizer.
0. The device is Samsung Galaxy S3
1. What CPU hast the device - Sansung Exynos 4412, 1.4 GHz, ARMv7
2. CPU usage levels - 10% (with equalizer). Another player (jetAudio) has 4%
3. It doesn't depend on file. Music shutters on mp3 and flac.




Tyler Smith

  • Guest
Re: BASS for Android
« Reply #999 on: 4 Nov '15 - 11:31 »


0. After tests i found that a music shutters even without BASS_FX equalizer.
0. The device is Samsung Galaxy S3
1. What CPU hast the device - Sansung Exynos 4412, 1.4 GHz, ARMv7
2. CPU usage levels - 10% (with equalizer). Another player (jetAudio) has 4%
3. It doesn't depend on file. Music shutters on mp3 and flac.
[/quote]

Shutters - stutters*. Music stutters, skips because of big cpu usage level.