B4J Library [B4j] Javax Midi Lib

Here is a wrap of the JavaxMidi Library as a B4xLib.

It is a large library and I haven't tested all of the available methods, it you get any problems let me know and I'll take a look.

The code is in the b4xlib, but only supports B4j feel free to unzip it and use it as you wish.

The example attached is a simple midi player and dump viewer for the midi tracks and has no additional dependencies.


Depends on: JavaObject and ByteConverter.

Documentation for the library is in the attached XMLfile which you can open with one of the Document viewers available on the Forum. Documentation and examples for the JavaxMidi package are available on the internet,

As always, if you try it, let me know how you get on with it and please report any bugs or problems.

Update to V1.2
Amended to work with external midi devices. (see post #7)

Update to V1.3
Fixed bug in soundfont initialization (Thanks luca1967 for finding it)

Update to V 1.4
  • Added TransposeTrack2 to MidiUtils which allows ignoring transpose on certain midi channels.
  • Fixed bug in MidiSynthesizer GetLoadedInstruments
Update to V 1.5 - Breaking Change
  • Added ChrSet where needed to allow use of different character encoding for text events in a midifile.
  • Added VirtualMachinArgs and PackagerProperty to the example project as required to create a package on Java9+ (Uncomment the 2 lines)
It will be obvious in the IDE where the changes are required, I suggest you used "UTF-8" for the characterset unless you know it needs something different.

Update to V 1.6 - Breaking Change (if using a transmitter listener)
  • Amended MidiData_Event in MidiTransmitter class to return a MidiMessage instead of MidiShortMessage See this post for modifications required
Update to V 1.7
  • Modified MidiySytemStatic GetSequence2 and GetSequence3 to return wrapped Sequence Objects


  • JavaxMidi.xml
    124.8 KB · Views: 502
  • jMidiLib1-7.zip
    77.7 KB · Views: 225
  • JavaxMidi-B4xLib.b4xlib
    41.5 KB · Views: 215
Last edited:


Licensed User
Longtime User
Update to V 1.7
  • Modified MidiySytemStatic GetSequence2 and GetSequence3 to return wrapped sequence Objects


New Member
hi stevel05.
In the beginning, I thank you for this great library and apologies for my bad english because that's not my native langues.
i have a question about using this library and i hope you help me to solve my problem. i want to creat an app about send and receive MIDI messages from my electronic piano(Yamaha DGX-670). but i dont know how can i do this with this library.
please show me how can i do it.

*. i write this project with JavaScript last year ago and i just want to write this with b4j.


Licensed User
Longtime User
please show me how can i do it.
I'm sorry but the question is far too vague. It would take many hours to write a complete answer.

Most of the information you will need are in the demo apps already provided, playing midi is in the original demo, receiving from a keyboard can be found here.

Break it down into small questions and I will help where I can.

Javax midi implementation is a little cumbersome, you can find information about it here.