I just added midi sound as sfx and theme song in my game, and here is piece of sample code how to play midi format in java :

try {
    // From file
    Sequence sequence = MidiSystem.getSequence(new File("midiaudiofile"));

    // From URL
    sequence = MidiSystem.getSequence(new URL("http://hostname/midiaudiofile"));

    // Create a sequencer for the sequence
    Sequencer sequencer = MidiSystem.getSequencer();
    sequencer.open();
    sequencer.setSequence(sequence);

    // Start playing
    sequencer.start();
} catch (MalformedURLException e) {
} catch (IOException e) {
} catch (MidiUnavailableException e) {
} catch (InvalidMidiDataException e) {
}

Pretty easy isn’t? Short post, but I hope useful for those needed.

Advertisements