I want to play a single, random note in Java. I use the following:
Random rand = new Random();
try {
Synthesizer synth = MidiSystem.getSynthesizer();
synth.open();
int note = rand.nextInt(128);
channels[0].noteOn(note, 80);
} catch (MidiUnavailableException e) {
e.printStackTrace();
}
but nothing ever happens. Can anyone tell me why?
EDIT: I forgot to include MidiChannel[] channels = synth.getChannels();