Author Topic: BASS for Android  (Read 679860 times)

firemen

  • Posts: 153
Re: BASS for Android
« Reply #1750 on: 1 Jul '20 - 08:34 »
please check the 64 bit version of the android midi library.
there is no sound when playing midi. the SF2 bank is loaded without errors. or maybe there are some nuances?

with 32 bit compilation of an application with a 32 bit midi library everything works fine.


Code: [Select]
var
  sf  : BASS_MIDI_FONT;
  fStream  : HSTREAM;
  fSoundfont : HSOUNDFONT;
  DocumentPath : string;

begin

  DocumentPath:= IncludeTrailingPathDelimiter(System.IOUtils.TPath.GetDocumentsPath);

  if not BASS_Init(-1, 44100, BASS_DEVICE_DEFAULT, 0, nil) then ShowMessage('Error initializing audio!');

  fSoundfont := BASS_MIDI_FontInit(PChar(DocumentPath + 'myfonts.sf2'), BASS_UNICODE);

  if (fSoundfont = 0) then ShowMessage('Error font init!');

  sf.font := fSoundfont; sf.preset:= -1;  sf.bank:= 0;

  if not BASS_MIDI_StreamSetFonts(0, PBASS_MIDI_FONT(@SF), 1) then ShowMessage('Error set fonts!');

  fStream := BASS_MIDI_StreamCreateFile(false, PChar(DocumentPath + 'test.kar'), 0, 0, BASS_UNICODE, 1);

  if (fStream = 0) then ShowMessage('Error open kar!');

  if not BASS_ChannelPlay(fStream, false) then  ShowMessage('error play');


There are no errors. only with 64-bit compilation is playback without sound.
« Last Edit: 1 Jul '20 - 08:51 by firemen »

Ian @ un4seen

  • Administrator
  • Posts: 22821
Re: BASS for Android
« Reply #1751 on: 1 Jul '20 - 13:33 »
I suspect that is due to a difference in the size of Delphi's "LongInt" type on 32-bit and 64-bit Android. Try replacing all instances of that in the BASSMIDI.PAS file with "Integer".

firemen

  • Posts: 153
Re: BASS for Android
« Reply #1752 on: 1 Jul '20 - 13:38 »
thanks, it worked!

Ian @ un4seen

  • Administrator
  • Posts: 22821
Re: BASS for Android
« Reply #1753 on: 2 Jul '20 - 15:04 »
Great! An updated BASSMIDI.PAS file is up in the Win32 BASSMIDI package now.

In other news, an Android version of the SPECTRUM example has been added to the package in the 1st post. The LIVESPEC example has also been updated.

Antwan

  • Posts: 22
Re: BASS for Android
« Reply #1754 on: 15 Jul '20 - 20:08 »
[I figured it out!]

I've recently started learning to develop for Android. So far, having a good time with it but I hit a bit of a small block on this one.

I've imported the BASS java file and so files as instructed, they are in my APK and I can return the version number. When I go to init BASS though, the app crashes immediately.

Code: [Select]
2020-07-15 20:00:33.699 6807-6807/com.gibz.gibzmediaplayer E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.gibz.gibzmediaplayer, PID: 6807
    java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.gibz.gibzmediaplayer-PaxXh3Fty1KkLAzdZo-BqQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.gibz.gibzmediaplayer-PaxXh3Fty1KkLAzdZo-BqQ==/lib/x86, /data/app/com.gibz.gibzmediaplayer-PaxXh3Fty1KkLAzdZo-BqQ==/base.apk!/lib/x86, /system/lib, /system/product/lib]]] couldn't find "libnative-lib.so"
        at java.lang.Runtime.loadLibrary0(Runtime.java:1067)
        at java.lang.Runtime.loadLibrary0(Runtime.java:1007)
        at java.lang.System.loadLibrary(System.java:1667)
        at com.un4seen.bass.BASS.<clinit>(BASS.java:761)
        at com.un4seen.bass.BASS.BASS_Init(Native Method)
        at com.gibz.gibzmediaplayer.MainActivity.onCreate(MainActivity.kt:18)
        at android.app.Activity.performCreate(Activity.java:7802)
        at android.app.Activity.performCreate(Activity.java:7791)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1299)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3245)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

If I remove the BASS init, it works fine. I'm writing the application in Android Studio with Kotlin. Here is my current onCreate:

Code: [Select]
override fun onCreate(savedInstanceState: Bundle?) {
     super.onCreate(savedInstanceState)
     setContentView(R.layout.activity_main)

     // Initalize BASS Library
     if (!BASS.BASS_Init(-1, 44100, 0))
     {
         Toast.makeText(applicationContext,"Could not initialize the Audio System",Toast.LENGTH_SHORT).show()
         return
     }
}

Thanks for any help in advance.
« Last Edit: 16 Jul '20 - 11:29 by Antwan »