Loading a soundbank in an applet

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!

I know loading soundbanks is broken in Java 1.4.2. If there are no soundbanks available on program initialisation, the Midi library attempts to use the platforms hardware midi interface. Unfortunately the timing is not properly implemented, which gives the stuttering playback. Once the hardware playback is selected, it is not possible to get the API to recognise a soundbank. I don’t know whether this was fixed for Java 1.5