tags:

views:

296

answers:

2

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.

+2  A: 

Here is an example of pure java that Listens to a MIDI port and dump the received event to the console. You should be able to run with that. :)

Asaph
+1  A: 

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, sample code to capture 10 seconds of MIDI data from a MIDI device is as follows:

DeviceThatWillTransmitMidi device = new DeviceThatWillTransmitMidi(); 
device.listenForMillis(10000); 
Sequence music = device.getSequenceFromListening();
David