Hey all,
I’m trying to load a soundbank in my applet so that the potential end user won’t have to download it for reasonable music. However, my code doesn’t seem to be working. No exceptions are thrown, the program execution is normal, and the bit of code for loading the soundbank is run, but the midi continues to stutter and sound like crap when played through the jre. I think i’m using the api correctly, but this is my first foray into playing sounds with java, and I haven’t been able to find much in the way of info on loading a soundbank. Any help would be much appreciated. Here’s the code:
public static void loadSoundbank(String path, Applet contextApplet) {
URL theURL;
Soundbank sb;
Synthesizer theSynthesizer;
try {
theURL = new URL(contextApplet.getCodeBase(), path);
sb = MidiSystem.getSoundbank(theURL);
try {
theSynthesizer = MidiSystem.getSynthesizer();
try {
theSynthesizer.open();
theSynthesizer.loadAllInstruments(sb);
}
catch (Exception e) {
System.out.println("Invalid MIDI data in AUDIO.loadSoundBank()");
}
}
catch (Exception e) {
System.out.println("MIDI unavailable at AUDIO.loadSoundBank()");
}
}
catch (Exception e) {
System.out.println("Malformed URL at AUDIO.loadSoundBank()");
}
}
Thanks in advance!