Author Topic: BASS for Android  (Read 392191 times)

AndroidMediaPlayer

  • Guest
Re: BASS for Android
« Reply #100 on: 16 Mar '12 - 21:45 »
Nope, it still stutters, realy heavy. Don't know why it worked for a moment. I am adjusting BASS_CONFIG_DEV_BUFFER bevor BASS_Init. And other Players are not affected. :/

Ian @ un4seen

  • Administrator
  • Posts: 20437
Re: BASS for Android
« Reply #101 on: 19 Mar '12 - 15:16 »
OK. I think I will have to send you a debug version to find out what's going on. For an idea of where to look, please confirm what BASS functions you are using and any config (BASS_SetConfig) settings. Also, you mentioned callbacks. Is that BASS callbacks (SYNCPROC/etc), and if so, does removing them make any difference?

AndroidMediaPlayer

  • Posts: 21
Re: BASS for Android
« Reply #102 on: 20 Mar '12 - 02:46 »
So, got an account now! :)

The methods i am using:

BASS_StreamCreateFile
BASS_Init
BASS_ChannelBytes2Seconds
BASS_ChannelGetLength
BASS_ChannelGetPosition
BASS_ChannelGetInfo
BASS_ChannelGetData
BASS_ChannelIsActive
BASS_StreamFree
BASS_ChannelSeconds2Bytes
BASS_ChannelSetPosition
BASS_ChannelStop
BASS_StreamCreate
BASS_ChannelPlay
BASS_ChannelPause
BASS_SetConfig
BASS_PluginLoad
BASS_ChannelSetAttribute
BASS_ChannelRemoveFX
BASS_ChannelSetFX
BASS_FXSetParameters

Config: only BASS_CONFIG_DEV_BUFFER for testing.

Callbacks: STREAMPROC with BASS_StreamCreate, other Callbacks are JNI Callbacks used for updating infos like current play time, etc...

Removing them doesn't make any difference. Even this simple code stutters...:

Code: [Select]
BASS_Init(-1,44100,0,NULL,NULL);
char *file = "/sdcard/music/file_to_play.mp3";
HSTREAM stream = BASS_StreamCreateFile(FALSE, file, 0, 0, 0);
BASS_ChannelPlay(stream, FALSE);

A debug version would be nice.

Edit: Uhh, the whole playback stopped after switching two apps... Oo
« Last Edit: 20 Mar '12 - 11:54 by AndroidMediaPlayer »

Ian @ un4seen

  • Administrator
  • Posts: 20437
Re: BASS for Android
« Reply #103 on: 20 Mar '12 - 15:09 »
OK, I will send over a debug version shortly.

toob

  • Posts: 133
Re: BASS for Android
« Reply #104 on: 21 Mar '12 - 14:56 »
Is it still the case that the only DX8 effect that currently supported in android bass is PARAMEQ?
Will the other effects be added, ie echo, distortion etc?

Yes, PARAMEQ is currently the only DX8 effect supported on Android, but the others may well be added in future. I'll have a look at that next week.

Also I have a requirement to play a stream in reverse, is this something that can be done in bass android now or will I need to wait for BASS_FX for android?

It is possible to implement the reverse processing yourself, using a decoding channel (BASS_STREAM_DECODE) to decode the file and a custom stream (BASS_StreamCreate) to play it. Your STREAMPROC function would decode a block of data from the end of the file and reverse the order of the samples in it. It would then deliver the data to BASS as it is requested, and when it's finished that, it would set (using BASS_ChannelSetPosition) the decoder back to the next block and repeat. If you will be playing MP3 files, then you should use the BASS_STREAM_PRESCAN flag when doing this, to enable accurate seeking.

Hi Ian

Is there any news on when the additional PARAMEQ effects will be available?

Also will it be possible to implement BassFx.BASS_FX_TempoCreate stream in android?

Just revisiting the reverse effect, will  BASS_FX  be added at some point as I have that working in my .Net program which I'm trying to port to android, but struggling to achieve using the methods you described above. If BASS_FX is a long way off could you steer me in the direction of some sample code perhaps?

thanks
Mark

Ian @ un4seen

  • Administrator
  • Posts: 20437
Re: BASS for Android
« Reply #105 on: 21 Mar '12 - 16:14 »
Is there any news on when the additional PARAMEQ effects will be available?

Support for the other effects has now been added, and an update should be available here shortly (probably tomorrow). Just testing it a bit first :)

Also will it be possible to implement BassFx.BASS_FX_TempoCreate stream in android?

Just revisiting the reverse effect, will  BASS_FX  be added at some point as I have that working in my .Net program which I'm trying to port to android, but struggling to achieve using the methods you described above. If BASS_FX is a long way off could you steer me in the direction of some sample code perhaps?

I think the availability of a complete Android port of BASS_FX is still some way off at the moment (it requires quite a bit of modification to use fixed-point instead of floating-point), but I guess it may be possible to have a partial port sooner. Regarding sample code for reversing, here is the original code that BASS_FX's reverse processing is based on...

   www.un4seen.com/forum/?topic=897.msg4764#msg4764

toob

  • Posts: 133
Re: BASS for Android
« Reply #106 on: 23 Mar '12 - 16:37 »
Quote

I think the availability of a complete Android port of BASS_FX is still some way off at the moment (it requires quite a bit of modification to use fixed-point instead of floating-point), but I guess it may be possible to have a partial port sooner. Regarding sample code for reversing, here is the original code that BASS_FX's reverse processing is based on...

   www.un4seen.com/forum/?topic=897.msg4764#msg4764

Thanks Ian, Converting that reverse code looks to be a bit beyond my experience specially being new to Java and not a C programmer either. I guess I'll have to wait for the partial port of BASS_FX. I'd be ideally looking for the reverse and  tempocreate functions  ;D

Would you update the date of the android download on page 1 when the DX8 update has been added then I will give it a go?

thanks again.
Mark

Ian @ un4seen

  • Administrator
  • Posts: 20437
Re: BASS for Android
« Reply #107 on: 23 Mar '12 - 18:09 »
The update including the other DX8 effects (CHORUS/DISTORTION/ECHO/FLANGER/REVERB) is now up in the 1st post. The effects seem to be working quite nicely so far, but please report if you encounter any problems with them.

toob

  • Posts: 133
Re: BASS for Android
« Reply #108 on: 23 Mar '12 - 18:41 »
The update including the other DX8 effects (CHORUS/DISTORTION/ECHO/FLANGER/REVERB) is now up in the 1st post. The effects seem to be working quite nicely so far, but please report if you encounter any problems with them.

Brilliant!

I can confirm that echo, distortion, chorus & flanger all work perfectly for me, big thanks.

Without seeming to be two pushy, when you say BASS_FX is still some way off would we be talking about more than a month away. Reason being is that I'd hold off on publishing this app if there was a chance it was on it's way in round about that time frame?

Mark ;D
« Last Edit: 24 Mar '12 - 15:13 by toob »

slaveoffear

  • Posts: 5
Re: BASS for Android
« Reply #109 on: 26 Mar '12 - 22:52 »
Hi

When will support formats (Add-ons): BASS_ALAC, BASS_APE, BASS_TTA, BASSWMA and maybe effect "stereo enhancer"?
« Last Edit: 27 Mar '12 - 11:47 by slaveoffear »

Ian @ un4seen

  • Administrator
  • Posts: 20437
Re: BASS for Android
« Reply #110 on: 27 Mar '12 - 17:25 »
Without seeming to be two pushy, when you say BASS_FX is still some way off would we be talking about more than a month away. Reason being is that I'd hold off on publishing this app if there was a chance it was on it's way in round about that time frame?

I'll check with Arthur to see what can be done.

When will support formats (Add-ons): BASS_ALAC, BASS_APE, BASS_TTA, BASSWMA and maybe effect "stereo enhancer"?

A BASS_ALAC port is now up in the first post. Unfortunately, I don't think a BASSWMA port will be possible as the required libraries (eg. WMVCORE) aren't available on Android. I think a BASS_APE port will be possible but the core Monkey's Audio decoder needs some modification first. I'll look into that.

slaveoffear

  • Posts: 5
Re: BASS for Android
« Reply #111 on: 28 Mar '12 - 09:59 »
A BASS_ALAC port is now up in the first post.

Thanks so much

Unfortunately, I don't think a BASSWMA port will be possible as the required libraries (eg. WMVCORE) aren't available on Android.

WMA is not very important, if difficult to do

I think a BASS_APE port will be possible but the core Monkey's Audio decoder needs some modification first. I'll look into that.

I will wait

slaveoffear

  • Posts: 5
Re: BASS for Android
« Reply #112 on: 29 Mar '12 - 20:21 »
I want to EQ without distortion, preamp and other effects.

BASS_FX better to use? When do you plan to share BASS_FX?

Mr.Green

  • Posts: 3
Re: BASS for Android
« Reply #113 on: 1 Apr '12 - 20:31 »
Hi. Greate lib! Many thanks.

I tried to use 10-band equalizer. There are a lot of distursion on high db. I have read on this forum, that compressor effect could help. But I found out that it's not working now. When do you play to implement compressor effect for Android?

And second question about id3 tags. Do you plan to implement read/write album covers? It's realy needed.

AndroidMediaPlayer

  • Posts: 21
Re: BASS for Android
« Reply #114 on: 3 Apr '12 - 00:09 »
Ian, do you have some plans to port Tags to other platforms? Or why is it only available for Windows? :)

Ian @ un4seen

  • Administrator
  • Posts: 20437
Re: BASS for Android
« Reply #115 on: 3 Apr '12 - 18:10 »
I think a BASS_APE port will be possible but the core Monkey's Audio decoder needs some modification first. I'll look into that.

I will wait

An Android version of the BASS_APE add-on is now up in the first post. Note CPU usage can be quite high with some APE files (compared to other formats). That's true on all platforms, but it's more significant on a low powered mobile device than a high powered desktop system.

I want to EQ without distortion, preamp...

Distortion can result if the EQ takes the level of the sample data out of range. A preamp control can be used to bring it back into range, and that can be implemented via a DSP function, something like this...

Code: [Select]
int preamp; // gain in 8.24 fixed-point (0x1000000=normal)

BASS.DSPPROC PreAmpDsp=new BASS.DSPPROC() {
public void DSPPROC(int handle, int channel, ByteBuffer buffer, int length, Object user) {
if (preamp==0x1000000) return; // nothing to do
buffer.order(null); // little-endian byte order
IntBuffer ibuffer=buffer.asIntBuffer();
int[] b=new int[length/4]; // allocate an "int" array for the sample data
ibuffer.get(b); // get the data from the buffer into the array
for (int a=0; a<length/4; a++) {
long s=b[a]; // get a sample from the array
s=(s*preamp)>>24; // apply the preamp gain
b[a]=(int)s; // put the result back in the array
}
ibuffer.rewind();
ibuffer.put(b); // put the array back into the buffer
}
};

...

BASS.BASS_SetConfig(BASS.BASS_CONFIG_FLOATDSP, 1); // enable 8.24 fixed-point DSP

...

preamp=0x1000000; // start with normal gain
BASS.BASS_ChannelSetDSP(handle, PreAmpDsp, null, 1000); // set the preamp DSP on a BASS channel

You can then adjust the gain via the "preamp" value. Enabling the BASS_CONFIG_FLOATDSP option allows the data to flow through the effects without being clipped, as well as simplifying the DSP code.

I tried to use 10-band equalizer. There are a lot of distursion on high db. I have read on this forum, that compressor effect could help. But I found out that it's not working now. When do you play to implement compressor effect for Android?

In its emulated DX8 efects, BASS tries to match the original DX8/Windows effects, but the DX8 compressor effect is a bit buggy, so BASS doesn't currently bother to emulate that. You could try using the preamp DSP above to lower the level and avoid the distortion.

And second question about id3 tags. Do you plan to implement read/write album covers? It's realy needed.

No, I'm afraid there are currently no plans for built-in support for reading/writing album covers in ID3 tags, but perhaps there are other libraries/classes that can be used to provide that functionality.

Ian, do you have some plans to port Tags to other platforms? Or why is it only available for Windows? :)

The Tags add-on has some Windows-specific stuff, but I think it should be possible to add support for other platforms. I'll look into it.

toob

  • Posts: 133
Re: BASS for Android
« Reply #116 on: 4 Apr '12 - 08:59 »
Without seeming to be two pushy, when you say BASS_FX is still some way off would we be talking about more than a month away. Reason being is that I'd hold off on publishing this app if there was a chance it was on it's way in round about that time frame?

I'll check with Arthur to see what can be done.

Have you had a response back from Arthur? Just need the reverse and tempo elements...

Mr.Green

  • Posts: 3
Re: BASS for Android
« Reply #117 on: 5 Apr '12 - 09:28 »
You could try using the preamp DSP above to lower the level and avoid the distortion.

Thanks a lot! That's working perfect for Android >= 2.3. But for Android 2.2 when I use decode mode DSP doesn't work. I tried to set preamp after decoding and before writing to AudioTrack. In my right headphone it's working, but in my left headphone is only noise. Here is my code for Android 2.2:

Code: [Select]
mChan=BASS.BASS_StreamCreateFile(songPath, 0, 0, BASS.BASS_MUSIC_DECODE);
...
length = BASS.BASS_ChannelGetData(mChan, buffer, buffer.capacity());
if (length > 0) {
  buffer.order(null); // little-endian byte order
  IntBuffer ibuffer = buffer.asIntBuffer();
  int[] b=new int[length / 4]; // allocate an "int" array for the sample data
  ibuffer.get(b); // get the data from the buffer into the array
  for (int a = 0; a < length / 4; a++) {
  long s = b[a]; // get a sample from the array
  s=(s*mPreamp)>>24; // apply the preamp gain
  b[a]=(int)s; // put the result back in the array
}
ibuffer.rewind();
ibuffer.put(b);
                                   
mTrack.write(buffer.array(), 0, length);

Ian @ un4seen

  • Administrator
  • Posts: 20437
Re: BASS for Android
« Reply #118 on: 5 Apr '12 - 17:48 »
The problem there is that the preamp code is expecting 8.24 fixed-point data, but you will probably be getting 16-bit data from the BASS_ChannelGetData call. The preamp code also actually needs to be in a DSP function for it to have the desired effect on the EQ; it is too late once the data has been converted back to 16-bit. DSP will be applied in a BASS_ChannelGetData call, so there is no need to deviate from the original code in this case.

Meanwhile... a partial BASS_FX port is now up in the first post. The reverse/tempo/bpm/beat stuff is included, but not the BASS_FX_BFX_xxx effects, which need more work regarding conversion to fixed-point. One difference to note compared to other platforms is that the BASS_ATTRIB_TEMPO_OPTION_USE_QUICKALGO option is enabled by default on tempo streams for lower CPU usage, but it can be disabled via BASS_ChannelSetAttribute if wanted. A BASS library update is also up in the first post, which is required by the BASS_FX port.

Mr.Green

  • Posts: 3
Re: BASS for Android
« Reply #119 on: 5 Apr '12 - 19:43 »
The problem there is that the preamp code is expecting 8.24 fixed-point data, but you will probably be getting 16-bit data from the BASS_ChannelGetData call. The preamp code also actually needs to be in a DSP function for it to have the desired effect on the EQ; it is too late once the data has been converted back to 16-bit. DSP will be applied in a BASS_ChannelGetData call, so there is no need to deviate from the original code in this case.

That's working. I just forget to apply DSP=)

toob

  • Posts: 133
Re: BASS for Android
« Reply #120 on: 6 Apr '12 - 12:56 »
Meanwhile... a partial BASS_FX port is now up in the first post. The reverse/tempo/bpm/beat stuff is included, but not the BASS_FX_BFX_xxx effects, which need more work regarding conversion to fixed-point. One difference to note compared to other platforms is that the BASS_ATTRIB_TEMPO_OPTION_USE_QUICKALGO option is enabled by default on tempo streams for lower CPU usage, but it can be disabled via BASS_ChannelSetAttribute if wanted. A BASS library update is also up in the first post, which is required by the BASS_FX port.

Woo Hoo, Brilliant !

Thank you for the quick response. BASS_FX reverse and tempo working great.

Big big thanks to all concerned!

slaveoffear

  • Posts: 5
Re: BASS for Android
« Reply #121 on: 8 Apr '12 - 22:38 »
How to make a limit for the preamp in the equalizer?

Or

Quote
Can the limit 'according to peak level' be checked for replaygain+pre-amp adjustments together? If I use +12db pre-amp with the limit option on ,  only use the maximum possible portion out of the 12db that won't cause any clipping.

Ian @ un4seen

  • Administrator
  • Posts: 20437
Re: BASS for Android
« Reply #122 on: 10 Apr '12 - 18:13 »
From the quoted text, it sounds like you/they want to use the Replaygain peak level to normalize the stream, so that the level is just short of clipping. To do that, you can set the pre-amp gain to 1/peak. Note that applying EQ (and most other effects) will affect the level though, pretty much invalidating the Replaygain information.

Meanwhile... a BASS_FX update is up in the first post, which adds support for the BASS_FX_BFX_VOLUME effect. That can be used instead of a DSP function (eg. the one I posted earlier) to implement a pre-amp control. A BASS library update is also up, which is needed by the BASS_FX update (for Java effect parameter support). The BASSWV add-on has also been updated to the latest version (2.4.3).

Guy

  • Guest
Re: BASS for Android
« Reply #123 on: 11 Apr '12 - 10:24 »
Hello, has anyone tried the BPM functions on Android?

I tried using
int chan = BASS.BASS_StreamCreateFile(file, 0, 0, BASS.BASS_STREAM_DECODE);

and then:
boolean error = BASS_FX.BASS_FX_BPM_CallbackSet(chan,new CallbackHolder(),10,0,BASS_FX.BASS_FX_BPM_MULT2,null );

but it crashes with

04-11 12:07:58.742: A/libc(8247): Fatal signal 11 (SIGSEGV) at 0x000007d0 (code=1)

can someone help me, am I supposed to do some aditional calls?
Is there a BPM decode/Pitch shifting example for Android?

Thanks


Ian @ un4seen

  • Administrator
  • Posts: 20437
Re: BASS for Android
« Reply #124 on: 11 Apr '12 - 16:33 »
Something like this should work...

Code: [Select]
BASS_FX.BPMPROC bpmproc=new BASS_FX.BPMPROC() {
public void BPMPROC(int chan, float bpm, Object user) {
// do something here
}
};

BASS_FX.BASS_FX_BPM_CallbackSet(chan, bpmproc, 10, 0, BASS_FX.BASS_FX_BPM_MULT2, null);