Author Topic: BASS for Android  (Read 656354 times)

MPage

  • Posts: 3
Re: BASS for Android
« Reply #1675 on: 24 Jan '20 - 12:22 »
:'(  :'(  :'(  I'm developing with Delphi 10.3.3 an app for Android. Compiling for Android 32-bits with Android SDK 25.2.5.

Please help me with 2 issues that I cannot yet resolve:

1) What libbass.so I need to have for above versions of development?  ???
  The options:
      armeabi\libbass.so size 248,304 bytes
      armeabi-v7a\libbass.so size 226,712 bytes
      arm64-v8a\libbass.so size 317,096 bytes - compilation error
      x86\libbass.so size 324,908 bytes - compilation error
      x86_64\libbass.so 309,104 bytes - compilation error

2) Where I can download a latest and correct bass.pass that is supports Android (and Windows too)?
Can someone attach it here?  ???

I tried both "armeabi\libbass.so" and "armeabi-v7a\libbass.so" - my test project apk building successfully. But when I trying to run on Android (9), it just crashes immediately after splash screen.  Test project APK is an empty form with only one thing added in code "use Bass;"
I spent hours and hours, but can't find a solution. Or "bass.so" is wrong, or "bass.pas" is wrong...

Attached bass.pas file that I use. It is a file from "Bass Windows" archive, where I added just these lines under 'type' section:
    PAnsiChar = system.MarshaledAString;
    AnsiChar = system.Byte;



Hi,

I'm developing with Delphi 10.2.3.
I also tried this new version of BASS for Android, but with everything I tried, I just got error messages or at the end, the the app just showed the splash screen.

I went back to the version of March 2019 and everything is fine again. But I also have to mention that the "bass.pas" also had to be "adjusted" to work with Android (uses statements and variable types).
I use "armeabi\libbass.so", which has to be deployed to "library/lib/armeabi-v7a/" in Delphi as the "Remote-Path". My app runs on various devices (Galaxy Note 3, Galaxy S7 Edge, Galaxy S10, Leagoo S10, Galaxy S5 mini...) and different Android versions (5.x to 10)

MPage
« Last Edit: 24 Jan '20 - 12:26 by MPage »

Ian @ un4seen

  • Administrator
  • Posts: 22305
Re: BASS for Android
« Reply #1676 on: 24 Jan '20 - 17:00 »
1) What libbass.so I need to have for above versions of development?  ???
  The options:
      armeabi\libbass.so size 248,304 bytes
      armeabi-v7a\libbass.so size 226,712 bytes
      arm64-v8a\libbass.so size 317,096 bytes - compilation error
      x86\libbass.so size 324,908 bytes - compilation error
      x86_64\libbass.so 309,104 bytes - compilation error

You would normally include all of them, or at least the ones that you want to support. You can leave out "armeabi" unless you want to support very old devices. If you want to include only one then I would suggest making that "armeabi-v7a" (arm64-v8a devices also support armeabi-v7a).

2) Where I can download a latest and correct bass.pass that is supports Android (and Windows too)?
Can someone attach it here?  ???

The latest BASS.PAS file can be taken from the Windows or Linux BASS packages. I guess it may need some modification for Android, but I'm not familiar with Delphi on Android, so I'm not sure about that.

I tried both "armeabi\libbass.so" and "armeabi-v7a\libbass.so" - my test project apk building successfully. But when I trying to run on Android (9), it just crashes immediately after splash screen.  Test project APK is an empty form with only one thing added in code "use Bass;"

To hopefully help identify what the problem is, please post the Logcat output from the crash.

I use "armeabi\libbass.so", which has to be deployed to "library/lib/armeabi-v7a/" in Delphi as the "Remote-Path". My app runs on various devices (Galaxy Note 3, Galaxy S7 Edge, Galaxy S10, Leagoo S10, Galaxy S5 mini...) and different Android versions (5.x to 10)

If you're going to include libraries for only one architecture in your app, I would suggest using "armeabi-v7a" rather than "armeabi". The armeabi BASS version does not include floating-point support (eg. BASS_SAMPLE_FLOAT flag) or NEON optimizations.

baylung

  • Posts: 2
Re: BASS for Android
« Reply #1677 on: 25 Jan '20 - 15:06 »

Hi,

I'm developing with Delphi 10.2.3.
I also tried this new version of BASS for Android, but with everything I tried, I just got error messages or at the end, the the app just showed the splash screen.

I went back to the version of March 2019 and everything is fine again. But I also have to mention that the "bass.pas" also had to be "adjusted" to work with Android (uses statements and variable types).
I use "armeabi\libbass.so", which has to be deployed to "library/lib/armeabi-v7a/" in Delphi as the "Remote-Path". My app runs on various devices (Galaxy Note 3, Galaxy S7 Edge, Galaxy S10, Leagoo S10, Galaxy S5 mini...) and different Android versions (5.x to 10)

MPage

Thank you very much for your reply and help!
Now I can build APK and run on Android (and NOX android emulator)! I was so happy :)
But now I have another problem that I cannot solve with Android app.
Maybe you can guide me how to fix, or what is the right way to do? ???

This is what I'm doing in my Delphi code for Android app:

1) Added my 'wav' and 'mp3' files as resources in "Delphi Project/Resources and Images"
2) in code I'm saving all these resources locally, similar to this:
Code: [Select]
InStream := TResourceStream.Create(HInstance, 'sound_1_resource_name', RT_RCDATA);
strFileName := TPath.Combine(TPath.GetDocumentsPath, 'sound_1.wav')
InStream.SaveToFile(strFileName);
3) BASS initialization is Ok
Code: [Select]
BASS_Init(-1, 44100, 0, 0, nil)4) Trying to load these files as samples, and here I have problem:
Code: [Select]
f := PChar(strFileName);
SampleHandle := BASS_SampleLoad(False, f, 0, 0, 5, BASS_SAMPLE_OVER_POS);

SampleHandle is always 0, meaning have error. And BASS_ErrorGetCode returns:

Real Android device (Android 9, Huawei P30): always error code 2, BASS_ERROR_FILEOPEN - cannot load the file.
On NOX emulator: always error code 41, BASS_ERROR_FILEFORM - wrong file format (I tried many different wav and mp3)

Can you please advise me why that is BASS_ERROR_FILEOPEN happening on Android device?
Maybe need some special system permissions, or settings at BASS?

PS/ Saving PNG and JPG files from app resources to local storage and opening them in App I'm doing fine, no issues. But with BASS BASS_SampleLoad this is does not working...

MPage

  • Posts: 3
Re: BASS for Android
« Reply #1678 on: 25 Jan '20 - 17:56 »

Hi,

I'm developing with Delphi 10.2.3.
I also tried this new version of BASS for Android, but with everything I tried, I just got error messages or at the end, the the app just showed the splash screen.

I went back to the version of March 2019 and everything is fine again. But I also have to mention that the "bass.pas" also had to be "adjusted" to work with Android (uses statements and variable types).
I use "armeabi\libbass.so", which has to be deployed to "library/lib/armeabi-v7a/" in Delphi as the "Remote-Path". My app runs on various devices (Galaxy Note 3, Galaxy S7 Edge, Galaxy S10, Leagoo S10, Galaxy S5 mini...) and different Android versions (5.x to 10)

MPage

Thank you very much for your reply and help!
Now I can build APK and run on Android (and NOX android emulator)! I was so happy :)
But now I have another problem that I cannot solve with Android app.
Maybe you can guide me how to fix, or what is the right way to do? ???

This is what I'm doing in my Delphi code for Android app:

1) Added my 'wav' and 'mp3' files as resources in "Delphi Project/Resources and Images"
2) in code I'm saving all these resources locally, similar to this:
Code: [Select]
InStream := TResourceStream.Create(HInstance, 'sound_1_resource_name', RT_RCDATA);
strFileName := TPath.Combine(TPath.GetDocumentsPath, 'sound_1.wav')
InStream.SaveToFile(strFileName);
3) BASS initialization is Ok
Code: [Select]
BASS_Init(-1, 44100, 0, 0, nil)4) Trying to load these files as samples, and here I have problem:
Code: [Select]
f := PChar(strFileName);
SampleHandle := BASS_SampleLoad(False, f, 0, 0, 5, BASS_SAMPLE_OVER_POS);

SampleHandle is always 0, meaning have error. And BASS_ErrorGetCode returns:

Real Android device (Android 9, Huawei P30): always error code 2, BASS_ERROR_FILEOPEN - cannot load the file.
On NOX emulator: always error code 41, BASS_ERROR_FILEFORM - wrong file format (I tried many different wav and mp3)

Can you please advise me why that is BASS_ERROR_FILEOPEN happening on Android device?
Maybe need some special system permissions, or settings at BASS?

PS/ Saving PNG and JPG files from app resources to local storage and opening them in App I'm doing fine, no issues. But with BASS BASS_SampleLoad this is does not working...

Hi!

First, I want to ask what you want to do with the sound files and your app. Is it something like a music player?
In some of my apps I also have to distribute files with the Android app. I think, a much better way is to pack them into a ZIP file and provide them via the "Project deployment manager". After the APK is installed on your device, you could unpack and save the files to the path you would like to have them - for example in "/storage/emulated/0/Android/data/YOUR_APPLICATION/files". This would be ".\assets\" as the "Remote Path" in the deployment manager.
You also can store/save/extract them in a "user defined" folder in "/storage/emulated/0". With this you also can check if everything is fine on the device with a filebrowser app or at the connected PC. (your device doesn't have to be rooted for this access).

This is a function with which I play a file on an Android device with one of my apps:

Code: [Select]
function TMainform.PlayFile(strFilename: String): Boolean;
var
  ResultCode: Integer;

begin
  Result := false;
  ResultCode := 0;
  BASS_ChannelStop(FActiveChannel);
  BASS_StreamFree(FActiveChannel);
  FActiveChannel := 0;

  //Create stream
  FActiveChannel := BASS_StreamCreateFile(FALSE, pchar(strFilename),
                    0, 0, 0 {$IFDEF UNICODE} or BASS_UNICODE {$ENDIF});

  if FActiveChannel = 0 then
  begin
    FActiveChannel := BASS_MusicLoad(False, PChar(strFilename), 0, 0,
                      BASS_MUSIC_RAMPS or BASS_MUSIC_POSRESET or
                      BASS_MUSIC_PRESCAN {$IFDEF UNICODE} or BASS_UNICODE {$ENDIF}, 0);

    if (FActiveChannel = 0) then
    begin
      ResultCode := Bass_ErrorGetCode;
      Result := false;
      Exit;

    end;

  end;

  BASS_ChannelPlay(FActiveChannel , True);
  BASS_ChannelSetPosition(FActiveChannel, 0, BASS_POS_BYTE);
  Result := true;

end;


"FActiveChannel" if of type HSTREAM, but I think you know that. ;-)


Regards, MPage

wangbang

  • Posts: 3
Re: BASS for Android
« Reply #1679 on: 10 Feb '20 - 06:41 »
When i use   Bassmidi      boolean b = BASSMIDI.BASS_MIDI_StreamSetFilter(chan, false, MIDIFILTER, null);  APP  is crash   but Playing sf2 files is OK

    BASSMIDI.MIDIFILTERPROC MIDIFILTER = new BASSMIDI.MIDIFILTERPROC() {
        @Override
        public boolean MIDIFILTERPROC(int handle, int track, BASSMIDI.BASS_MIDI_EVENT event, boolean seeking, Object user) {
            BASSMIDI.BASS_MIDI_EVENT event1 = event;

            return true;
        }
    };


And  i dont load 

   BASS.BASS_PluginLoad(libpath + "/libbassflac.so", 0);
   BASS.BASS_PluginLoad(libpath + "/libbasswv.so", 0);



crash report:

JNI DETECTED ERROR IN APPLICATION: JNI GetMethodID called with pending exception java.lang.ClassNotFoundException: Didn't find class "com.un4seen.bass.BASSMIDI$BASS_MIDI_EVENT" on path: DexPathList[[directory "."],nativeLibraryDirectories=[/system/lib, /system/product/lib, /system/lib, /system/product/lib]]
2020-02-10 14:36:53.006 17846-17909/com.tuolu.drum A/com.tuolu.drum: java_vm_ext.cc:570]   at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:230)
2020-02-10 14:36:53.006 17846-17909/com.tuolu.drum A/com.tuolu.drum: java_vm_ext.cc:570]   at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:379)
2020-02-10 14:36:53.006 17846-17909/com.tuolu.drum A/com.tuolu.drum: java_vm_ext.cc:570]   at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
2020-02-10 14:36:53.006 17846-17909/com.tuolu.drum A/com.tuolu.drum: java_vm_ext.cc:570]
2020-02-10 14:36:53.006 17846-17909/com.tuolu.drum A/com.tuolu.drum: java_vm_ext.cc:570]     in call to GetMethodID

Ian @ un4seen

  • Administrator
  • Posts: 22305
Re: BASS for Android
« Reply #1680 on: 10 Feb '20 - 15:07 »
Are you using ProGuard (or similar) to obfuscate your Java code? If so, make sure you exclude the BASS classes from that. Instructions for ProGuard can be found in the first post.

wangbang

  • Posts: 3
Re: BASS for Android
« Reply #1681 on: 11 Feb '20 - 02:24 »
I used debug mode,but  is  targetsdk 28,Is the jni method declaration wrong? I can find BASSMIDIEVENT through reflection in the program

wangbang

  • Posts: 3
Re: BASS for Android
« Reply #1682 on: 11 Feb '20 - 02:32 »
In addition, I used Androidx to build the application. I want to get the events in the midi file in real time. In addition to setFilter, what should I do?

Ian @ un4seen

  • Administrator
  • Posts: 22305
Re: BASS for Android
« Reply #1683 on: 11 Feb '20 - 15:31 »
Is BASSMIDI working in your app if you don't use any classes from it, eg. just calling BASS_MIDI_StreamCreateFile? If so, check that you have set ProGuard to leave all of the BASS classes alone. If you have no luck with that, you could also try adding a "@Keep" line just before the "public class BASSMIDI" line in the BASSMIDI.java file.