I had some promising attempts using/installing the python-rtmidi module.
You can either read the buffer via callbacks or by polling.
The module is in python, so you have to write scripts. To use it more convenient it is also possible to create / develop nodes in animation nodes that provide a graphical usage.
Here is an extract of a sample code from python-rtmidi that prints the midi messages to the blender system console:
from rtmidi.midiutil import open_midiinput
port = sys.argv if len(sys.argv) > 1 else None
midiin, port_name = open_midiinput(port)
except (EOFError, KeyboardInterrupt):
print(“Entering main loop. Press Control-C to exit.”)
timer = time.time()
msg = midiin.get_message()
message, deltatime = msg
timer += deltatime
print("[%s] @%0.6f %r" % (port_name, timer, message))
Keep in mind that there also is a “rtmidi” module it might also work, but I used “python-rtmidi”.
Hope you can use it.