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.

1580318838133.png




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
Update to V 1.8
  • Fixed bug in MidiSystemGetMidiFileFormat3
  • Bug Fixes
 

Attachments

  • JavaxMidi.xml
    124.8 KB · Views: 597
  • jMidiLib1-8.zip
    78 KB · Views: 102
  • JavaxMidi-B4xLib.b4xlib
    41.8 KB · Views: 108
Last edited:

ludogomez

Member
Licensed User
Longtime User
Hello,

I want to install your library but I have this message :
"Missing jar file for this library: JavaxMidi-B4xlib.xml"

can you help me ?

thanks
Regards
 

stevel05

Expert
Licensed User
Longtime User
I've juste delete xml file
Yes, for B4xlibs, if an XML file is provided it is for documentation only and can be opened with one of the documentation readers available on the forum. It should not be copied into the Library folder.
 

drponciano

Member
Licensed User
Longtime User
Hello all:
I'm trying to buld an easy program to capture events from a MID keyboard or controller. Jus need to get MIDI messages key and velocity. Some how I have not been able to find a simple example of that. I would appreciate any help.
 

stevel05

Expert
Licensed User
Longtime User
Unfortunately nothing about Javax midi is simple, I will try to take a look. May not be today though.
 

stevel05

Expert
Licensed User
Longtime User
Here is a quick example to capture Midi data from an external Midi Keyboard. Requires JavaxMidi-B4xLib.b4xlib V1.2 + updated in first post.

Edit: Updated with the modifications linked in post #17
 

Attachments

  • MidiCapture.zip
    2.3 KB · Views: 186
Last edited:

stevel05

Expert
Licensed User
Longtime User
Thanks Luca, looks like I uploaded an old version. Try it now. Just download the jMidiLibTest.zip
 

stevel05

Expert
Licensed User
Longtime User
The missing values were beats per bar, which is set to 4 for simplicity. In reality it would need to be calculated on the fly in case the value changed during the file, but that would be overkill for a demo :)
 

stevel05

Expert
Licensed User
Longtime User
I just listened to one of my best compositions
I usually use some very nice Earth Wind and Fire midi files for testing, the problem with that is that testing takes forever :)
 

stevel05

Expert
Licensed User
Longtime User
Update to V 1.4
  • Added TransposeTrack2 to MidiUtils which allows ignoring transpose on certain midi channels.
  • Fixed bug in MidiSynthesizer GetLoadedInstruments
 

stevel05

Expert
Licensed User
Longtime User
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)
 

stevel05

Expert
Licensed User
Longtime User
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
 

stevel05

Expert
Licensed User
Longtime User
My apologies for the recent breaking changes, although this library has been available for a while, it is a huge library. I have not tried all of the available methods so it is inevitable that some logic was not quite right in it's initial creation. I thought it better to include as much as possible at the start. Now it is being used by a few more people, it is getting a better test than I could do on my own.

Please continue to post questions and bugs so it can continue to improve.
 

Johan Schoeman

Expert
Licensed User
Longtime User
Wow...! This is really a great project! Works out of the box. Found this midi on the web and listening to it at present:
Piano Concerto n5 op73 1mov ''Emperor'' (Beethoven)
 

stevel05

Expert
Licensed User
Longtime User
Wow...! This is really a great project! Works out of the box. Found this midi on the web and listening to it at present:
Piano Concerto n5 op73 1mov ''Emperor'' (Beethoven)
Thanks Johan, the demo project is just a small example of the power of the midi system, there is a lot more it can do it you are willing to get your hands dirty. Like most java audio/media related libraries, it is not the most intuitive, but if you understand the Midi 1 specification, it makes it easier to work with. And every time someone reports an issue, it gets better.
 
Top