I'm having trouble setting the instrument in the javax.sound.midi package.
Synthesizer synthesizer = MidiSystem.getSynthesizer();
MidiChannel[] channels = synthesizer.getChannels();
channels[0].programChange(5);
System.out.println(channels[0].getProgram());
From the documentation on MidiChannel, calls to channels[0].programChange(int) should change instrument that the MidiChannel is set to and immediately reflected in channels[0].getProgram(). However my program prints "0", indicating nothing has changed.
Later on in the code, I'm using MidiChannel.getSequencer() to play midi sound successfully (although only with the default instrument.)
Am I going about trying to set the instrument in the wrong way?