I’ve inherited a Java project that used an old C++ dll to receive MIDI data from a piano connected to the computer.
Now that Java has built-in support for MIDI devices, I want to get rid of the legacy C++ dll and just use pure Java. Does Java support receiving data from a piano connected to the computer? I’ve searched Google for examples to no avail.
Yes, the JavaSound API can be used to read MIDI data from a MIDI device.
JFugue is a Java API for music programming that uses the JavaSound API, and can help simplify your interaction with JavaSound. In JFugue 5.x, sample code to capture 10 seconds of MIDI data from a MIDI device is as follows:
You can also start and stop listening to a device: