Author Topic: BASS for Android  (Read 390085 times)

Ian @ un4seen

  • Administrator
  • Posts: 20389
Re: BASS for Android
« Reply #425 on: 8 Oct '13 - 17:36 »
To support both arm and x86, what should be done ?  single apk can support both ? Then would you give me some guide about how to prepare for it ?   And I need another help.   I see that reverb you showed in MidiTest is working, which is turning on and off.  Now, how can I control amount(?) of reverb effect.  I appreciate if you show me some example.

Yes, a single APK package can support both arm and x86. An x86 version of the BASS library is available as a separate download in the 1st post; copy the "x86" folder from that into the "libs" folder from the main BASS package (alongside the "armeabi" and "armeabi-v7a" folders). If your Eclipse project is already open when doing that, be sure to "Refresh" the project's "libs" folder afterwards.

Regarding the reverb level, that can be adjusted via BASS_MIDI_StreamEvent and the MIDI_EVENT_REVERB_LEVEL event...

Code: [Select]
BASS_MIDI_StreamEvent(handle, 0, MIDI_EVENT_REVERB_LEVEL, level);

Please see the BASS_MIDI_StreamEvent documentation for details.

Is there any possibility to implement Musepack SV8 on BASS library for android?

Yep, an Android version of the BASS_MPC add-on has now been added to the 1st post.

Larry Fine

  • Posts: 16
Re: BASS for Android
« Reply #426 on: 8 Oct '13 - 19:22 »
Yep, an Android version of the BASS_MPC add-on has now been added to the 1st post.

I am truly grateful for your attention. :)

Greetings.

Alok

  • Guest
Re: BASS for Android
« Reply #427 on: 15 Oct '13 - 08:16 »
A patch for the NETRADIO example to have it write the downloaded data to a file can be found here...

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


Another problems :

Bass has any method to find the Chanel is playing or not ?

Regards
Alok

Ian @ un4seen

  • Administrator
  • Posts: 20389
Re: BASS for Android
« Reply #428 on: 15 Oct '13 - 14:27 »
You can use BASS_ChannelIsActive to check whether a BASS channel is playing. Please see the documentation for details on that.

alok

  • Guest
Re: BASS for Android
« Reply #429 on: 23 Oct '13 - 15:51 »
Hi,

Can we use bass library for call recording in android.

Appexperts

doomplay

  • Posts: 33
SeekTo
« Reply #430 on: 24 Oct '13 - 12:34 »
Hi everyone . How to seek to position in file if i stream it from net . (I use this code for seek to position ,but it works only if i play file from my sd card )
 public void seekTo(int to)
    {
        BASS.BASS_ChannelSetPosition(chan, BASS.BASS_ChannelSeconds2Bytes(chan, to), BASS.BASS_POS_BYTE);
    }

Ian @ un4seen

  • Administrator
  • Posts: 20389
Re: BASS for Android
« Reply #431 on: 24 Oct '13 - 16:49 »
Can we use bass library for call recording in android.

That isn't something that I have tried myself, so I'm not really sure. I guess it may be possible if you enable speakerphone for the call.

Hi everyone . How to seek to position in file if i stream it from net . (I use this code for seek to position ,but it works only if i play file from my sd card )
 public void seekTo(int to)
    {
        BASS.BASS_ChannelSetPosition(chan, BASS.BASS_ChannelSeconds2Bytes(chan, to), BASS.BASS_POS_BYTE);
    }

You can use the same code with internet streams opened via BASS_StreamCreateURL (so long as the BASS_STREAM_BLOCK flag isn't used), but it will only be able to seek within the currently download portion of the file, eg. you probably won't be able to immediately jump to the end of the file. BASS_StreamGetFilePosition can be used to monitor the download progress.

doomplay

  • Posts: 33
Re: BASS for Android
« Reply #432 on: 24 Oct '13 - 18:10 »
Thanks for answer , it solved my problem . Сould you answer one more question ? I want to build equalizer using code below.The problem is when i set gain more than 5  for first two bands , sound becomes bad (cracked) . How can i solve this problem?

Code: [Select]
void setFX(int gain)
{

p.fGain=gain;
        p.fBandwidth = 20;
        p.fCenter=31;
        BASS.BASS_FXSetParameters(fx[0], p);
        p.fCenter=63;
        BASS.BASS_FXSetParameters(fx[1], p);
        p.fCenter=87;
        BASS.BASS_FXSetParameters(fx[2], p);
        p.fCenter=125;
        BASS.BASS_FXSetParameters(fx[3], p);
        p.fCenter=250;
        BASS.BASS_FXSetParameters(fx[4], p);
}
« Last Edit: 25 Oct '13 - 10:26 by doomplay »

Ian @ un4seen

  • Administrator
  • Posts: 20389
Re: BASS for Android
« Reply #433 on: 25 Oct '13 - 17:06 »
What you're hearing could be a result of the EQ raising the sample data's level beyond the valid range, which means the data gets clipped back into range, which results in distortion. Do you still hear the noise when playing quiet music? I would suggest lowering the "fBandwidth" value as your bands are less than 20 semitones apart, and also removing the 87Hz band as it is out of sequence with the rest.

For improved sound quality, I would also recommend that you enable the BASS_CONFIG_FLOATDSP option (via BASS_SetConfig). Please see the documentation for details on that.

Larry Fine

  • Posts: 16
Re: BASS for Android
« Reply #434 on: 26 Oct '13 - 23:57 »
Yep, an Android version of the BASS_MPC add-on has now been added to the 1st post.

I am truly grateful for your attention. :)

Greetings.

I came back just to thank you once again for the Musepack SV8 support. So, was launched a new version of the Aimp for Android which uses the BASS libraries and mpc has shown excellent results on this platform.
The Aimp development is a beta stage, but it has shown a good balance between performance and resource usage.

If anyone is interested, please do a search or visit the forum aimp.ru

Salud

v1toko

  • Posts: 3
Re: BASS for Android
« Reply #435 on: 7 Nov '13 - 17:00 »
Hi everybody, i'm new in the forum, so i have a question about getting the song position, in android (obviously).

i'm getting position like this:

long pos = BASS_ChannelGetPosition(g_stream, BASS_POS_BYTE);
double elapsedtime = BASS_ChannelBytes2Seconds(g_stream, pos);

I have tested in windows and linux and the accuracy is high, this works as expected, but in android i'm getting
some problems because this returns repeated positions, and this is a problem in a music game.

by example (illustrative mode):

0.0002
0.0005
0.0008
0.0011
0.0011
0.0015
0.0019
0.0022
0.0022

i  don't know if it is a android issue (apparently yes) or a bass issue, so how i said, in windows and linux works perfect.

sorry if my english is bad.

thanks to everyone  ;)

Ian @ un4seen

  • Administrator
  • Posts: 20389
Re: BASS for Android
« Reply #436 on: 8 Nov '13 - 15:31 »
Are you outputting the result (eg. via Log) after each BASS_ChannelGetPosition call? If so, the gaps may be due to delays in that. What happens if you log the positions to an array, and then output the array afterwards? For example...

Code: [Select]
long[] pos=new long[20];
for (int a=0; a<20; a++) pos[a]=BASS.BASS_ChannelGetPosition(handle, BASS.BASS_POS_BYTE);
for (int a=0; a<20; a++) Log.v("blah", "pos="+pos[a]);

Trying that here, I'm seeing the position advance in single sample steps.
« Last Edit: 8 Nov '13 - 18:29 by Ian @ un4seen »

v1toko

  • Posts: 3
Re: BASS for Android
« Reply #437 on: 10 Nov '13 - 05:55 »
Ian, I'm feel a bit dumb after your response.
I reviewed my code and I find some problems in my draw methods.
the logs seems fine with the method that you propose.

many thank's ian.

dmhuisma

  • Posts: 1
Re: BASS for Android
« Reply #438 on: 11 Nov '13 - 17:26 »
Has anybody tried this using android 4.4?  I am now getting error code 5 from BASS.BASS_ChannelSetFX, with no changes have being made from before.

Ian @ un4seen

  • Administrator
  • Posts: 20389
Re: BASS for Android
« Reply #439 on: 11 Nov '13 - 17:39 »
Error code 5 is BASS_ERROR_HANDLE, which means an invalid channel handle was used. My guess is that the handle is 0 because its creation failed, eg. a BASS_StreamCreateFile call? Please check the error code from that call.

To check whether the problem is something specific to your app or something more general, please also try running one of the examples (eg. FXTEST) included in the BASS package.

v1toko

  • Posts: 3
Re: BASS for Android
« Reply #440 on: 12 Nov '13 - 04:13 »
Are you outputting the result (eg. via Log) after each BASS_ChannelGetPosition call? If so, the gaps may be due to delays in that. What happens if you log the positions to an array, and then output the array afterwards? For example...

Code: [Select]
long[] pos=new long[20];
for (int a=0; a<20; a++) pos[a]=BASS.BASS_ChannelGetPosition(handle, BASS.BASS_POS_BYTE);
for (int a=0; a<20; a++) Log.v("blah", "pos="+pos[a]);

Trying that here, I'm seeing the position advance in single sample steps.

Hi, i'm again.
I continue reviewing my code and I have some things about getPosition.

why if I update the game logic with deltaTime (instead music position) the game runs smoothly?
why I say this? because in my testing (in win and linux) the change (between deltaTime and music pos) makes no difference.

I'm testing over a Galaxy Tab 2 (7'') and Galaxy S4, making a simple comprobation:

Code: [Select]
if (fPositionSeconds == m_LastPositionSeconds)
{
        fPositionSeconds += m_LastPositionTimer.Ago();
        Log("Same position, applying ago: %f", m_LastPositionTimer.Ago());
}
else
{
        m_LastPositionTimer.Touch();
        m_LastPositionSeconds = fPositionSeconds;
}
I removed all others log calls. The galaxy tab call log here many times in comparison with galaxy s4.
but in both devices the game runs at 60 fps. I don't know if i'm wrong with my question or another thing, probably my code (again).
I'm still trying to find an explanation

thanks in advance.

Ian @ un4seen

  • Administrator
  • Posts: 20389
Re: BASS for Android
« Reply #441 on: 12 Nov '13 - 15:45 »
Please try without any logging, and also try running the app outside of the debugger (the debugger can slow things down).

doomplay

  • Posts: 33
Re: BASS for Android
« Reply #442 on: 13 Nov '13 - 23:13 »
Hi . I have one problem - I tried to play file with offset (without offset everything's fine) , but it's doesn't work .Channel = 0 and getErrorCode() return 41 (BASS_ERROR_FILEFORM) . and also param length doesn't work (just ignored).Look at code below.Can you help me?
Code: [Select]
public void prepareFile(String url,int offsetSeconds,int lengthSeconds) throws IOException
    {
         int tempChan = BASS.BASS_StreamCreateFile(url,0L,0L,BASS.BASS_STREAM_DECODE);
        if(tempChan == 0)
        {
            throw new IOException("prepare exception tempChan "+ BASS.BASS_ErrorGetCode());
        }
        long offset = BASS.BASS_ChannelSeconds2Bytes(tempChan,offsetSeconds);
        long length = BASS.BASS_ChannelSeconds2Bytes(tempChan,lengthSeconds);
        BASS.BASS_StreamFree(tempChan);


        chan = BASS.BASS_StreamCreateFile(url,offset,length,0);
        if(chan == 0)
        {
            throw new IOException("prepare exception chan "+ BASS.BASS_ErrorGetCode());
        }
        long bytes = BASS.BASS_ChannelGetLength(chan, BASS.BASS_POS_BYTE);
        totalTime = (int)BASS.BASS_ChannelBytes2Seconds(chan, bytes);
        BASS.BASS_CHANNELINFO info=new BASS.BASS_CHANNELINFO();
        BASS.BASS_ChannelGetInfo(chan, info);
        BASS.BASS_ChannelSetSync(chan, BASS.BASS_SYNC_END, 0, EndSync, 0);
    }

Ian @ un4seen

  • Administrator
  • Posts: 20389
Re: BASS for Android
« Reply #443 on: 14 Nov '13 - 15:14 »
What is the format of the file? It generally isn't possible to use an offset with file formats that have a header, as the header will be missed (resulting in a BASS_ERROR_FILEFORM error). If the aim is to start playback at an offset, then you should use BASS_ChannelSetPosition (before BASS_ChannelPlay) instead.

doomplay

  • Posts: 33
Re: BASS for Android
« Reply #444 on: 14 Nov '13 - 16:17 »
The format is m4a , i'll be use ChannelSetPosition as you advised , but what about param lenght? It's just ignored .
My aim is open audio file ,which contains several tracks .
« Last Edit: 14 Nov '13 - 17:17 by doomplay »

Ian @ un4seen

  • Administrator
  • Posts: 20389
Re: BASS for Android
« Reply #445 on: 14 Nov '13 - 17:35 »
What value are you using in the "length" parameter, eg. is it lower than the size of the file? Please note that it isn't possible to use BASS_ChannelSeconds2Bytes to calculate "offset" and "length" parameters for BASS_StreamCreateFile (as in your post above) because they deal in different things: BASS_ChannelSeconds2Bytes deals in decoded sample data positions, while the BASS_StreamCreateFile "offset" and "length" parameters deal in file positions.

To set a start and end position for playback, you can use BASS_ChannelSetPosition for the start and a BASS_SYNC_POS sync that stops playback for the end. Something like this...

Code: [Select]
long startBytes=BASS.BASS_ChannelSeconds2Bytes(handle, startSeconds); // get start position in bytes
BASS.BASS_ChannelSetPosition(handle, startBytes, BASS.BASS_POS_BYTE); // seek there
long endBytes=BASS.BASS_ChannelSeconds2Bytes(handle, endSeconds); // get end position in bytes
BASS.BASS_ChannelSetSync(handle, BASS.BASS_SYNC_POS|BASS.BASS_SYNC_MIXTIME, endBytes, EndSync, 0); // set a sync there
BASS.BASS_ChannelPlay(handle, 0); // start playing

...

BASS.SYNCPROC EndSync=new BASS.SYNCPROC() {
public void SYNCPROC(int handle, int channel, int data, Object user) {
BASS.BASS_ChannelStop(channel); // stop at current position
}
};

Please see the documentation for details on the aforementioned functions.

doomplay

  • Posts: 33
Re: BASS for Android
« Reply #446 on: 14 Nov '13 - 19:39 »
Thanks for help .It's solve my problem , but.. i've got new one .
If param length > 0  when track ended my activity close and a lot of logs messages appear .New code below
Code: [Select]
public void prepareFile(String url,int offsetSeconds,int lengthSeconds) throws IOException
    {
        chan = BASS.BASS_StreamCreateFile(url,0,0,0);
        if(chan == 0)
        {
            throw new IOException("prepare exception chan "+ BASS.BASS_ErrorGetCode());
        }
        if(lengthSeconds != 0)
        {
            totalTime = lengthSeconds - offsetSeconds;
            long endBytes = BASS.BASS_ChannelSeconds2Bytes(chan, lengthSeconds);
            BASS.BASS_ChannelSetSync(chan, BASS.BASS_SYNC_MIXTIME,endBytes, EndSync, 0);
        }
        else
        {
            long bytes = BASS.BASS_ChannelGetLength(chan, BASS.BASS_POS_BYTE);
            totalTime = (int)BASS.BASS_ChannelBytes2Seconds(chan, bytes) - offsetSeconds;
            BASS.BASS_ChannelSetSync(chan, BASS.BASS_SYNC_END,0, EndSync, 0);
        }
        if(offsetSeconds != 0)
        {
            seekTo(offsetSeconds);
        }
    }
and
Code: [Select]
private final BASS.SYNCPROC EndSync=new BASS.SYNCPROC()
    {
        public void SYNCPROC(int handle, int channel, int data, Object user)
        {
            BASS.BASS_ChannelStop(chan);
        BASS.BASS_StreamFree(chan);
        }
    };
« Last Edit: 14 Nov '13 - 19:48 by doomplay »

doomplay

  • Posts: 33
Re: BASS for Android
« Reply #447 on: 14 Nov '13 - 20:08 »
I've already solve my second problem .The couse is flag BASS_SYNC_MIXTIME in method BASS.BASS_ChannelSetSync . Thanks for help.

Ian @ un4seen

  • Administrator
  • Posts: 20389
Re: BASS for Android
« Reply #448 on: 15 Nov '13 - 18:07 »
Yep. The issue there was that it isn't safe for a stream to free itself (via BASS_StreamFree) in a "mixtime" SYNCPROC, so removing the BASS_SYNC_MIXTIME flag would avoid that. The advantage of using a mixtime sync for this is that it guarantees that playback will stop exactly at the wanted position because it is called when the decoder reaches the position (the fact that it's called mid-update cycle is why it's unsafe to free the stream there). A non-mixtime sync will be called when playback reaches the wanted position, but your BASS_ChannelStop call might be a fraction later, by which time a bit of sound beyond the end position was played.

If you would like to free the stream when it reaches the end position, you can achieve that while using a mixtime sync by adding the BASS_STREAM_AUTOFREE flag to your BASS_StreamCreateFile call, instead of calling BASS_StreamFree.

Alok

  • Guest
Re: SeekTo
« Reply #449 on: 17 Nov '13 - 07:04 »
Hi everyone . How to seek to position in file if i stream it from net . (I use this code for seek to position ,but it works only if i play file from my sd card )
 public void seekTo(int to)
    {
        BASS.BASS_ChannelSetPosition(chan, BASS.BASS_ChannelSeconds2Bytes(chan, to), BASS.BASS_POS_BYTE);
    }



My progress not change when we will play from file. Let me know what I did wrong !