I know this is a really old question, but as a novice programmer, it was very difficult for me to figure out how to do this, so I decided to share the next welcome program in a world in which Java play one mid-note to help someone to begin.
import javax.sound.midi.*; public class MidiTest{ public static void main(String[] args) { try{ Synthesizer midiSynth = MidiSystem.getSynthesizer(); midiSynth.open();
The above code was created mainly by cutting, pasting and messing with the code found in several online tutorials. Here are the most useful guides I've found:
http://www.ibm.com/developerworks/library/it/it-0801art38/ This is a great tutorial and probably has everything you are looking for; however, this can be a little overwhelming at the beginning.
http://patater.com/gbaguy/javamidi.htm Features of non-working code written by a 15-year-old. It was amazing - the most useful thing I found.
Good luck to you. Greetings.
user2955146
source share