I made a keyboard application a while ago that gets a midi soundbank as a resource from a jar, and uses it to get the instrument names contained in the soundbank. This seems to work fine on machines using windows 7 with suns java 6 and in linux using suns java 6. However, this does not seem to work on machines using windows xp using the same version of java. What seems to be happening is that the instrument array has not been loaded when the getInstrumentName() method is called. The instrument array gets populated in the constructor of the DefaultControl class (second code sample). Could someone please help me to understand why would this be the case, and why would it seem to be machine dependent? This was copied from a posting on stack overflow but there were no answers so I figured I would try it here.
I get the current instrument name like this:
data.setControls(new DefaultControls());
data.setKeyboard(new KeyboardPanel(data.getPressed()));
data.getKeyboard().setInstrumentName(data.getControls().getInstrumentName());
I get and load the soundbank like this:
this.synth=MidiSystem.getSynthesizer();
synth.open();
synth.loadAllInstruments(
MidiSystem.getSoundbank(
getClass().getResourceAsStream("soundbank.gm")));
this.instrument=synth.getAvailableInstruments();
this.channels=synth.getChannels();
This is the method that is called to load the name is this:
public String getInstrumentName(){
return instrument[selected_instrument].getName();
}