I am trying to replace the default soundfont of a MIDI file with my own soundfont; however, the new soundfont plays on top of the old one rather than flat-out replacing the old one. My code:
Synthesizer synthesizer = MidiSystem.getSynthesizer();
synthesizer.open();
synthesizer.unloadAllInstruments(synthesizer.getDefaultSoundbank());
synthesizer.loadAllInstruments(MidiSystem.getSoundbank(new File("Airhorn.sf2")));
Sequencer sequencer = MidiSystem.getSequencer();
sequencer.open();
sequencer.getTransmitter().setReceiver(synthesizer.getReceiver());
InputStream inputStream = new BufferedInputStream(new FileInputStream(new File("Test.mid")));
sequencer.setSequence(inputStream);
sequencer.start();