Hey guys,
I have been trying to write a basic program that will send and receive MIDI. I have successfully managed to send a MIDI message, but am unable to come up with the code that will receive a MIDI signal from an external source and simply display the information in a textfield.
I have spent nearly a week looking for anything to help me, but unfortunately all the source I have found is for reading in from files.
This is my code so far:

if (midiIOIn == thisThread) {
                try {
                    Transmitter getTrans = MidiSystem.getTransmitter();
                                        
                    
                   MidiEvent recMSG = null;

                    MidiMessage getMSG1 = recMSG.getMessage();
                    int recStatus = getMSG1.getStatus();
                    byte[] recMSG1 = getMSG1.getMessage();

                    String statusString = Integer.toString(recStatus);
                    String messageString = recMSG1.toString();

                    gui.midiInTextField.setText(statusString + messageString);
                    gui.midiStatusTextField.setText("Data Received");
               }
               catch (MidiUnavailableException ex1) {
                   gui.midiStatusTextField.setText("FAIL");
               }
           }

I understand that there are some issues with it, but if anyone can help me I would be greatful.

Regards,
winn_man

You're creating a null MidiEvent object and trying to retrieve a message from it. That's not going to do anything because nowhere do I see where recMSG is instantiated.

Read through this tutorial, it might help
http://java.sun.com/docs/books/tutorial/sound/MIDI-messages.html

I'm well aware of the null, that is what I'm asking help for, and I have read those pages a number of times, but can't get any information relevant to what I am trying to do.
Thanks for the help though.

This article has been dead for over six months. Start a new discussion instead.