B4A Library Midi Driver Lib

stevel05

Expert
Licensed User
Longtime User
OK, If it was originally based on an example, let me know which one and I will make sure that there is not a conflict in it. Just for peace of mind.
 

kimstudio

Active Member
Licensed User
Longtime User
Hi Steve, I checked the github and there is a latest version of mididriver 1.26 available. The demo shows that the reverb seems works.
With #AdditionalJar: MidiDriver-1.26.aar added I can make it sound using Javaobject directly.

The problem is the engine configuration can't be set like sampling rate, currently is 22050 which I want 44100. Anyway this seems is the simpler method to play midi directly comparing to via mediaplayer or other libs like Fluidsynth, which should be better with soundfont support.
 

stevel05

Expert
Licensed User
Longtime User
The demo shows that the reverb seems works.
That's interesting, When I get some time I might look at wrapping the new version to work with the Midi library.
engine configuration can't be set
It appears that it is not wrapped in the github project, I haven't looked at the underlying sonivox library to see if it's possible but I wouldn't be creating a native library anyway so we have what is wrapped in the github project.

As you have proved it works, I would probably wrap it as a b4xlib, rather than a Java library.
 

kimstudio

Active Member
Licensed User
Longtime User
That would be great to have a B4X lib. I don't know how to call the "OnMidiStartListener" by using JavaObejct. Although by looking at the code it seems without this callback also fine.
 

toby_pd

Member
Hi Steve,
trying to compile your midi driver test app, I have this error:
C:\Android\tools\..\extras\b4a_local\unpacked-midisystem-63834279686718\dex_v1\midisystem.zip:classes.dex:B4A Versione: 12.50
Analisi del Codice. (0.00s)
Java Versione: 11
Building folders structure. (0.10s)
Compilazione del codice. (0.01s)
Compilazione del codice di layouts (0.01s)
Organizzazione Librerie. (0.31s)
(AndroidX SDK)
Compilazione risorse (0.51s)
Collegamento risorse (0.59s)
Compilazione del codice debugger. (0.50s)
Compilazione del codice Java prodotto. (2.49s)
Ricerca librerie che necessitano di essere "dexed". (0.01s)
Dex code (3.10s)
Dex merge Error
Error in C:\Android\tools\..\extras\b4a_local\unpacked-mididriver-63645035592233\dex_v1\mididriver.zip:classes.dex:
Type com.stevel05.MidiDriverWrapper is defined multiple times: C:\Android\tools\..\extras\b4a_local\unpacked-mididriver-63645035592233\dex_v1\mididriver.zip:classes.dex, C:\B4A\SourceCode\MidiDriverTest\Objects\dexed\com\stevel05\MidiDriverWrapper.dex
Compilation failed
Exception in thread "main" java.lang.RuntimeException: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: C:\Android\tools\..\extras\b4a_local\unpacked-mididriver-63645035592233\dex_v1\mididriver.zip:classes.dex
at com.android.tools.r8.internal.vj.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:98)
at com.android.tools.r8.D8.main(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:4)
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: C:\Android\tools\..\extras\b4a_local\unpacked-mididriver-63645035592233\dex_v1\mididriver.zip:classes.dex
at Version.fakeStackEntry(Version_3.3.20-dev+aosp1.java:0)
at com.android.tools.r8.internal.vj.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:75)
at com.android.tools.r8.internal.vj.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:28)
at com.android.tools.r8.internal.vj.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:27)
at com.android.tools.r8.internal.vj.b(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:2)
at com.android.tools.r8.D8.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:22)
at com.android.tools.r8.D8.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:17)
at com.android.tools.r8.internal.vj.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:85)
... 1 more
Caused by: com.android.tools.r8.internal.f: Type com.stevel05.MidiDriverWrapper is defined multiple times: C:\Android\tools\..\extras\b4a_local\unpacked-mididriver-63645035592233\dex_v1\mididriver.zip:classes.dex, C:\B4A\SourceCode\MidiDriverTest\Objects\dexed\com\stevel05\MidiDriverWrapper.dex
at com.android.tools.r8.internal.YS.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:14)
at com.android.tools.r8.internal.YS.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:22)
at com.android.tools.r8.internal.cN.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:36)
at com.android.tools.r8.internal.cN.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:10)
at java.base/java.util.concurrent.ConcurrentHashMap.merge(ConcurrentHashMap.java:2048)
at com.android.tools.r8.internal.cN.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:6)
at com.android.tools.r8.graph.E2$a.e(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:4)
at com.android.tools.r8.dex.b.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:105)
at com.android.tools.r8.dex.b.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:28)
at com.android.tools.r8.D8.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:25)
at com.android.tools.r8.D8.d(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:609)
at com.android.tools.r8.D8.c(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:1)
at com.android.tools.r8.internal.vj.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:24)
... 5 more
What is wong?
Many thanks!
toby
 

stevel05

Expert
Licensed User
Longtime User
This is the problem:
Caused by: com.android.tools.r8.internal.f: Type com.stevel05.MidiDriverWrapper is defined multiple times: C:\Android\tools\..\extras\b4a_local\unpacked-mididriver-63645035592233\dex_v1\mididriver.zip:classes.dex, C:\B4A\SourceCode\MidiDriverTest\Objects\dexed\com\stevel05\MidiDriverWrapper.dex

Which test app are you running? The MidiPiano in this thread?
 

stevel05

Expert
Licensed User
Longtime User
I just downloaded and ran it without issue. If you've amended the project can you zip and post your project. From the menu File/ExportAsZip

You will need to change the android:targetSdkVersion to 31 as shown in the logs. From the Menu Project/ManifestEditor
 
Last edited:

toby_pd

Member
Hi Steve, this is the project. I added only "#AdditionalJar: com.android.support:support-v4" to avoid the error: "Impossibile trovare: C:\Program Files (x86)\Anywhere Software\Basic4android\libraries\android-support-v4.jar".
I also tried to compile it on another pc with this result result.:
Convert byte code - optimized dex. Error
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lorg/billthefarmer/mididriver/MidiDriver;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lorg/billthefarmer/mididriver/MidiDriver$OnMidiStartListener;
2 errors; aborting

Thank you!
 

Attachments

  • MDT.zip
    7.2 KB · Views: 38

toby_pd

Member
I don't know how but the attached project is successfully compilated but, when run on the target phone this error is raised:

Logger connected to: samsung SM-S908B
--------- beginning of main
Copying updated assets files (1)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
Error occurred on line: 35 (Main)
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.stevel05.midilib.midireceiver.IsInitialized()' on a null object reference
at com.stevel05.midilib.mididevice_static._getdefaultreceiverdevice(mididevice_static.java:358)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
at b4a.example.main.afterFirstLayout(main.java:105)
at b4a.example.main.access$000(main.java:17)
at b4a.example.main$WaitForLayout.run(main.java:83)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.app.ActivityThread.main(ActivityThread.java:8762)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:604)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)
 

Attachments

  • midi.zip
    10 KB · Views: 47

toby_pd

Member
Hi Steve, exscuse me and ignore the previous posts. I succeded to run the project in midi.zip decommenting line 31.
Now i can go on with my project.
Thanks again!
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…