Tell me more ×
Audio-Video Production Stack Exchange is a question and answer site for engineers, producers, editors, and enthusiasts spanning the fields of audio, video, and media creation. It's 100% free, no registration required.

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();
}
share|improve this question
3  
This is best left at StackOverflow. – Brad Apr 21 '11 at 15:34
I agree, this sounds like a programming question. – Andy Shinn May 7 '11 at 4:51
This question belongs on StackOverflow. We'll close this one but leave it here so if someone does have an answer they can follow the link to the SO question and answer it there. – BenV May 9 '11 at 14:57

closed as off topic by BenV May 9 '11 at 14:58

Questions on Audio-Video Production Stack Exchange are expected to relate to audio or video recording and production within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.

Browse other questions tagged or ask your own question.