Author Topic: BASS for Android  (Read 390397 times)

Dodge

  • Posts: 32
Re: BASS for Android
« Reply #275 on: 23 Jan '13 - 18:40 »
just came back to ask if the "ByteBuffer buffer" in DOWNLOADPROC is the aac/mp3 encoded data or decoded wave data. as i found some jni stuff for lame that i could use with the wave data.

No, that will be fine. If you want to be clever, your DOWNLOADPROC could look for the beginning of the first frame in the MP3/AAC data to start writing from (the data sent by the server may begin mid-frame), but the written file will be playable even without doing that :)
okay, so if i the stream is playing for e.g. 5 minutes and i hit record the file that will be created on this point and filled with data until i hit stop will play fine like if its recorded w/ BASSenc?


-------
UPDATE:
I tested plain writing the ByteBuffer from DownlodaProc to a file, they dont play. MP3 does not, and AAC does not too. :(


------
Another question...
The Playback, does that use any codecs available on the device or built-in codecs that require a Patent licence? (for both, aac and mp3?)
« Last Edit: 24 Jan '13 - 08:52 by Dodge »

Ian @ un4seen

  • Administrator
  • Posts: 20400
Re: BASS for Android
« Reply #276 on: 24 Jan '13 - 16:27 »
just came back to ask if the "ByteBuffer buffer" in DOWNLOADPROC is the aac/mp3 encoded data or decoded wave data. as i found some jni stuff for lame that i could use with the wave data.

A DOWNLOADPROC function will receive the data as sent by the server, so MP3 or AAC from a Shoutcast server. If you would like to have the decoded PCM data, that is available via a DSPPROC function (see BASS_ChannelSetDSP).

I tested plain writing the ByteBuffer from DownlodaProc to a file, they dont play. MP3 does not, and AAC does not too. :(

Are you sure the file was written successfully, eg. it wasn't 0 bytes long? If you begin with the NETRADIO example, then it could be modified to write the stream to a file like this...

Code: [Select]
...
public class NetRadio extends Activity {
FileChannel fc;
...
BASS.DOWNLOADPROC StatusProc=new BASS.DOWNLOADPROC() {
public void DOWNLOADPROC(ByteBuffer buffer, int length, Object user) {
if ((Integer)user!=req) return; // make sure this is still the current request
if (buffer!=null && length==0) { // got HTTP/ICY tags
...
} else {
try {
if (buffer!=null) { // got data, write to file...
if (fc==null) fc=new FileOutputStream(new File(outputfilename)).getChannel();
fc.write(buffer);
} else if (fc!=null) // end of stream, close file...
fc.close();
} catch (IOException e) {
}
}
    }
    };

The Playback, does that use any codecs available on the device or built-in codecs that require a Patent licence? (for both, aac and mp3?)

BASS doesn't use the device's codecs as there unfortunately doesn't appear to be any good way to access them currently, so BASS has to use its own MP3 decoder (and BASS_AAC has its own AAC decoder).

Dodge

  • Posts: 32
Re: BASS for Android
« Reply #277 on: 25 Jan '13 - 15:38 »
yes, i'm sure that the file was written successfully, size was in about 200kb for my aac test and 600kb for my mp3 test.


but i'll test your code too. Thank you for the sample. :)


-- UPDATE --
write mp3/aac data works, with your code, but only after creating the file manually (if not creating the file manually, the file is created and >0byte but unplayable...) and for some strange reason my PC does not find the file or only the self crated 0 byte file... no fckn idea whats wrong with my phone... -.-

« Last Edit: 25 Jan '13 - 17:22 by Dodge »

Ian @ un4seen

  • Administrator
  • Posts: 20400
Re: BASS for Android
« Reply #278 on: 25 Jan '13 - 17:48 »
I forgot to mention that you will probably also need to add the "android.permission.WRITE_EXTERNAL_STORAGE" permission to the app's AndroidManifest.xml file. Regarding your PC not finding the file, perhaps that is a path issue, ie. the file isn't written where the PC is looking? Android's Environment class can be used to get various paths.

Dodge

  • Posts: 32
Re: BASS for Android
« Reply #279 on: 25 Jan '13 - 22:05 »
I forgot to mention that you will probably also need to add the "android.permission.WRITE_EXTERNAL_STORAGE" permission to the app's AndroidManifest.xml file. Regarding your PC not finding the file, perhaps that is a path issue, ie. the file isn't written where the PC is looking? Android's Environment class can be used to get various paths.

i have added WRITE_EXTERNAL_STORAGE permission (after getting io exceptions for no write permissions :P)

also i use the Environment.getStoragePath() function

chuckd

  • Posts: 67
Re: BASS for Android
« Reply #280 on: 28 Jan '13 - 03:50 »
Quick question here.... how is the Opus portion of BASS implemented in Android?  Does it use an NDK port of the actual libraries, or was the Opus code actually ported to Java?  An NDK implementation might be limiting on certain devices.

Chuck

Ian @ un4seen

  • Administrator
  • Posts: 20400
Re: BASS for Android
« Reply #281 on: 28 Jan '13 - 16:00 »
All of the Android BASS libraries are native code with Java/JNI wrappers, so built using the NDK. I'm curious, what device limitation do you have in mind that would specifically apply to Opus?

Dodge

  • Posts: 32
Re: BASS for Android
« Reply #282 on: 29 Jan '13 - 18:26 »
Hey Ian,

is there a mp3-free version of BASS for Android? Like the win32 version has an mp3-free dll?

thanks in advance

Ian @ un4seen

  • Administrator
  • Posts: 20400
Re: BASS for Android
« Reply #283 on: 30 Jan '13 - 17:31 »
No, I'm afraid there's isn't currently an "mp3-free" BASS version for Android, as there doesn't appear to be any good way to access the device's codecs (hopefully that will improve in future). If you don't need MP3 support, I can put up an "mp3-free" build without any.

Dodge

  • Posts: 32
Re: BASS for Android
« Reply #284 on: 30 Jan '13 - 17:37 »
No, I'm afraid there's isn't currently an "mp3-free" BASS version for Android, as there doesn't appear to be any good way to access the device's codecs (hopefully that will improve in future). If you don't need MP3 support, I can put up an "mp3-free" build without any.

yea, i would like to have a mp3 free version w/o any mp3 at all. as if i'm not mistaken there are patent fees if there is an mp3 encoder and i'm only using aac streams for now

kcheong

  • Posts: 2
Re: BASS for Android
« Reply #285 on: 31 Jan '13 - 03:48 »
Hi, I am developing an Android music mixer app. I tested BASS and it is so great.
Is there any BASSmix extension for Android I can use for the mixing fucntion?
I cannot find it in the android version.

Ian @ un4seen

  • Administrator
  • Posts: 20400
Re: BASS for Android
« Reply #286 on: 31 Jan '13 - 17:10 »
yea, i would like to have a mp3 free version w/o any mp3 at all. as if i'm not mistaken there are patent fees if there is an mp3 encoder and i'm only using aac streams for now

An "mp3-free" BASS build (without any MP3 support) is now up in the package in the 1st post. The standard BASS build has also been updated to the latest stuff at the same time, as have the BASSWV and BASS_ALAC add-ons. An Android version of the TAGS add-on has also been introduced.

Regarding patented technology, note AAC is patented too. If you would like to avoid that stuff, there is Ogg Vorbis.

Hi, I am developing an Android music mixer app. I tested BASS and it is so great.
Is there any BASSmix extension for Android I can use for the mixing fucntion?
I cannot find it in the android version.

An Android version of the BASSmix add-on is included in the BASS package in the 1st post, in the "bassmix" folder :)

kcheong

  • Posts: 2
Re: BASS for Android
« Reply #287 on: 1 Feb '13 - 04:11 »
yea, i would like to have a mp3 free version w/o any mp3 at all. as if i'm not mistaken there are patent fees if there is an mp3 encoder and i'm only using aac streams for now

An "mp3-free" BASS build (without any MP3 support) is now up in the package in the 1st post. The standard BASS build has also been updated to the latest stuff at the same time, as have the BASSWV and BASS_ALAC add-ons. An Android version of the TAGS add-on has also been introduced.

Regarding patented technology, note AAC is patented too. If you would like to avoid that stuff, there is Ogg Vorbis.

Hi, I am developing an Android music mixer app. I tested BASS and it is so great.
Is there any BASSmix extension for Android I can use for the mixing fucntion?
I cannot find it in the android version.

An Android version of the BASSmix add-on is included in the BASS package in the 1st post, in the "bassmix" folder :)

Thanks so much :>

Dodge

  • Posts: 32
Re: BASS for Android
« Reply #288 on: 1 Feb '13 - 19:26 »
yea, i would like to have a mp3 free version w/o any mp3 at all. as if i'm not mistaken there are patent fees if there is an mp3 encoder and i'm only using aac streams for now

An "mp3-free" BASS build (without any MP3 support) is now up in the package in the 1st post. The standard BASS build has also been updated to the latest stuff at the same time, as have the BASSWV and BASS_ALAC add-ons. An Android version of the TAGS add-on has also been introduced.

Regarding patented technology, note AAC is patented too. If you would like to avoid that stuff, there is Ogg Vorbis.

Sure i know, licensing AAC is something we decided to do, but then we found that mp3 requires patent too, so we decided to drop mp3 to not need both patents. :)


thanks for mp3-free BASS :)

mrjoey

  • Posts: 31
Re: BASS for Android
« Reply #289 on: 7 Feb '13 - 22:38 »
quick question here : in bass_fx.java there '
//   public static final int BASS_FX_BFX_PHASER = 0x1000b;
//   public static final int BASS_FX_BFX_ECHO3 = 0x1000c;
//   public static final int BASS_FX_BFX_CHORUS = 0x1000d;
//   public static final int BASS_FX_BFX_APF = 0x1000e;
   public static final int BASS_FX_BFX_COMPRESSOR = 0x1000f;
//   public static final int BASS_FX_BFX_DISTORTION = 0x10010;
   public static final int BASS_FX_BFX_COMPRESSOR2 = 0x10011;
   public static final int BASS_FX_BFX_VOLUME_ENV = 0x10012;
//   public static final int BASS_FX_BFX_BQF = 0x10013;

   // Volume
   public static class BASS_BFX_VOLUME {
      public int lChannel;
      public float fVolume;
   }

    public static class BASS_BFX_COMPRESSOR2 {
       public float fGain;
        public float fThreshold;
        public float fRatio;
        public float fAttack;
        public float fRelease;
        public int lChannel;

    }
where BASS_FX_BFX_COMPRESSOR2 is commented..i removed the comment dashes and i created new static class for it and i run it but no effect...BASS_ChannelSetFX(chan, BASS_FX_BFX_COMPRESSOR2,1) return 0 where
BASS_ChannelSetFX(chan, BASS_FX_BFX_PEAKEQ,0) return the parameter number...so bass developpers didnt make functions for compressors and other dsps in the so library? cz i need all the dsp functions

another question about BASS_ChannelGetPosition(chan2, a.BASS_POS_BYTE)
im drawing the peaks waveform of the chan but its slow while on pc is very fast..i tried it on galaxy s2(android 2.3) and on note 2 (android 4) is that normal due to cpu speed? is there any possible way to move fast?

thanks in advance.....

Ian @ un4seen

  • Administrator
  • Posts: 20400
Re: BASS for Android
« Reply #290 on: 8 Feb '13 - 14:49 »
where BASS_FX_BFX_COMPRESSOR2 is commented..i removed the comment dashes and i created new static class for it and i run it but no effect...BASS_ChannelSetFX(chan, BASS_FX_BFX_COMPRESSOR2,1) return 0 where
BASS_ChannelSetFX(chan, BASS_FX_BFX_PEAKEQ,0) return the parameter number...so bass developpers didnt make functions for compressors and other dsps in the so library? cz i need all the dsp functions

Not all of the BASS_ChannelSetFX options are currently included in the Android version of the BASS_FX add-on; those that are commented-out in BASS_FX.java are not currently implemented, and will appear in a future update. Is it just the BASS_FX_BFX_COMPRESSOR2 effect that you are wanting?

another question about BASS_ChannelGetPosition(chan2, a.BASS_POS_BYTE)
im drawing the peaks waveform of the chan but its slow while on pc is very fast..i tried it on galaxy s2(android 2.3) and on note 2 (android 4) is that normal due to cpu speed? is there any possible way to move fast?

To clarify, are you saying the BASS_ChannelGetPosition call is slow or your waveform drawing is slow? BASS_ChannelGetPosition doesn't really have anything to do with waveform drawing, so perhaps you meant BASS_ChannelGetData? In any case, please time your code/calls (eg. log that to the console) to confirm what is being slow.

mrjoey

  • Posts: 31
Re: BASS for Android
« Reply #291 on: 8 Feb '13 - 16:39 »
thanks mr IAN for ur quick reply..however i need almost all of dsp effects (chorus, flanger , delays , compressor2 , revebs) cz im developing an app that handles these effects and lets the user choose them...anyway im waiting the update ...
im using B4a..so i created a jar library in eclipse for the "bass.java " and "bass_fx" and working fine...and i have the VB project called "custloop" wish draws the song waveform using (BASS_ChannelGetPosition(chan2, a.BASS_POS_BYTE)) ..here is my code in B4A:
 Dim cpos As Int , peak(2) As Int
 Dim Level As Int, pos As Int
   c2.DrawText(text1,0dip,15dip,Typeface.DEFAULT_BOLD,15,Colors.White,"LEFT")
    Do While boo
       
        Level = a.BASS_ChannelGetLevel(chan2)  ' scan peaks
        pos = a.BASS_ChannelGetPosition(chan2, a.BASS_POS_BYTE) / bpp
      
        If (peak(0) < u.LOWORD(Level / 100)) Then peak(0) = u.LOWORD(Level)  ' set left peak
        If (peak(1) < u.HIWORD( Level / 100)) Then peak(1) = u.HIWORD(Level)  ' set right peak
        If (a.BASS_ChannelIsActive(chan2) = 0) Then
            pos = -1 ' reached the end
        Else
            pos = a.BASS_ChannelGetPosition(chan2, a.BASS_POS_BYTE) / bpp
              End If
        If (pos > cpos) Then
            Dim ablo As Int
                     For ablo = 0 To (peak(0) * (100/ 2) / 32768) - 1
         '
                ' draw left peak
               ' wavebuf(IIF( (150 / 2 - 1 - ablo) * 100 + cpos > 12060, 12060, (150/ 2 - 1 - ablo) * 150 + cpos)) =1-ablo
                     c2.DrawPoint(pos,75-ablo,Colors.Green)
         Panel2.Invalidate
         Next
            For ablo = 0 To (peak(1) * (100 / 2) / 32768) - 1
         c2.DrawPoint(pos,(75+ablo),Colors.Green)
         Panel2.Invalidate
                ' draw right peak
               ' wavebuf(IIF((150/ 2 + 1 + ablo) * 100 + cpos > 12060, 12060, (150 / 2 + 1 + ablo) * 100 + cpos)) =1+ablo
            Next
         'Activity.Title= pos & "    " & cpos & "    " & a.BASS_ChannelIsActive(chan2)
            If (pos >= 500) Then Exit ' gone off end of display
          cpos = pos
            peak(0) = 0
            peak(1) = 0
         End If
        DoEvents
   Loop


i tried to bypass or comment the "for" loop and monitor the "pos" and it s increasing slowly without doing any draw just monitoring the pos increment...while its increasing i tried to stop the playing and it increased a little bit fast but still slow....i think then "BASS_ChannelGetPosition" loop in the so lib is slow...isnt? thank u

Dahaka

  • Posts: 8
Re: BASS for Android
« Reply #292 on: 9 Feb '13 - 14:23 »
Hi, Ian. I have problems. When i call function BASS.BASS_StreamCreateFile for  OGG file - Application crash (Fly IQ 441 Android 4.0). LogCat:
02-09 17:30:04.870: A/libc(21953): Fatal signal 7 (SIGBUS) at 0x00000000 (code=128)
My code:
public String GetTimeTrack(String namefile) {
      int chan=0;
      chan=BASS.BASS_StreamCreateFile(namefile, 0, 0, 0);
      Log.e("GetTime", namefile+" "+Integer.toString(chan));
      if (chan==0) return "(00:00)";
      double time=BASS.BASS_ChannelBytes2Seconds(chan, BASS.BASS_ChannelGetLength(chan, BASS.BASS_POS_BYTE)); // the length in seconds
      BASS.BASS_StreamFree(chan);
      return getDurationString((long)time);
   }
thanks

Ian @ un4seen

  • Administrator
  • Posts: 20400
Re: BASS for Android
« Reply #293 on: 11 Feb '13 - 15:40 »
im using B4a..so i created a jar library in eclipse for the "bass.java " and "bass_fx" and working fine...and i have the VB project called "custloop" wish draws the song waveform using (BASS_ChannelGetPosition(chan2, a.BASS_POS_BYTE)) ..here is my code in B4A:
...
i tried to bypass or comment the "for" loop and monitor the "pos" and it s increasing slowly without doing any draw just monitoring the pos increment...while its increasing i tried to stop the playing and it increased a little bit fast but still slow....i think then "BASS_ChannelGetPosition" loop in the so lib is slow...isnt? thank u

Your code looks like it is based on the CUSTLOOP example's ScanPeaks function. Please note that is actually decoding an entire file via the BASS_ChannelGetLevel calls ("chan2" is a decoding channel), so I think that (rather than BASS_ChannelGetPosition) will be what is taking longer on the Android device than on a PC. The Android device is likely to be less powerful, so decoding will be slower.

I have problems. When i call function BASS.BASS_StreamCreateFile for  OGG file - Application crash...

Please upload the OGG file to have a look at here...

   ftp.un4seen.com/incoming/

Please also confirm that you are using the latest BASS version (in the 1st post).

Dahaka

  • Posts: 8
Re: BASS for Android
« Reply #294 on: 11 Feb '13 - 21:00 »
im using B4a..so i created a jar library in eclipse for the "bass.java " and "bass_fx" and working fine...and i have the VB project called "custloop" wish draws the song waveform using (BASS_ChannelGetPosition(chan2, a.BASS_POS_BYTE)) ..here is my code in B4A:
...
i tried to bypass or comment the "for" loop and monitor the "pos" and it s increasing slowly without doing any draw just monitoring the pos increment...while its increasing i tried to stop the playing and it increased a little bit fast but still slow....i think then "BASS_ChannelGetPosition" loop in the so lib is slow...isnt? thank u

Your code looks like it is based on the CUSTLOOP example's ScanPeaks function. Please note that is actually decoding an entire file via the BASS_ChannelGetLevel calls ("chan2" is a decoding channel), so I think that (rather than BASS_ChannelGetPosition) will be what is taking longer on the Android device than on a PC. The Android device is likely to be less powerful, so decoding will be slower.

I have problems. When i call function BASS.BASS_StreamCreateFile for  OGG file - Application crash...

Please upload the OGG file to have a look at here...

   ftp.un4seen.com/incoming/

Please also confirm that you are using the latest BASS version (in the 1st post).
already have

thanks

Ian @ un4seen

  • Administrator
  • Posts: 20400
Re: BASS for Android
« Reply #295 on: 12 Feb '13 - 16:43 »
Unfortunately, the uploaded file seems to be corrupt; perhaps it was uploaded in text mode rather than binary? As the file is pretty small, please try attaching it to a forum post (after ZIPing) instead.

Dahaka

  • Posts: 8
Re: BASS for Android
« Reply #296 on: 12 Feb '13 - 19:43 »
Unfortunately, the uploaded file seems to be corrupt; perhaps it was uploaded in text mode rather than binary? As the file is pretty small, please try attaching it to a forum post (after ZIPing) instead.
already have
Archive contains two files.
thanks
« Last Edit: 12 Feb '13 - 19:49 by Dahaka »

Ian @ un4seen

  • Administrator
  • Posts: 20400
Re: BASS for Android
« Reply #297 on: 13 Feb '13 - 17:05 »
Those files seem to be corrupt too. Are you sure they're not, eg. can you play them with other software?

Dahaka

  • Posts: 8
Re: BASS for Android
« Reply #298 on: 14 Feb '13 - 16:17 »
Those files seem to be corrupt too. Are you sure they're not, eg. can you play them with other software?
Yes, i can play them with other software (standart mediaplayer)

Ian @ un4seen

  • Administrator
  • Posts: 20400
Re: BASS for Android
« Reply #299 on: 14 Feb '13 - 16:47 »
Are you sure you are playing the exact same files that you posted above? If so, please confirm what software is able to play them, as they have been unplayable with all software that I've tried so far.