use of javax.sound.midi.Soundbank in project jdk8u_jdk by JetBrains.
the class TestGetSoundbankInputStream2 method main.
public static void main(String[] args) throws Exception {
File file = new File(System.getProperty("test.src", "."), "ding.sf2");
FileInputStream fis = new FileInputStream(file);
BufferedInputStream bis = new BufferedInputStream(fis);
try {
InputStream badis = new BadInputStream(bis);
Soundbank sf2 = new SF2SoundbankReader().getSoundbank(badis);
assertTrue(sf2.getInstruments().length == 1);
Patch patch = sf2.getInstruments()[0].getPatch();
assertTrue(patch.getProgram() == 0);
assertTrue(patch.getBank() == 0);
} finally {
bis.close();
}
}
use of javax.sound.midi.Soundbank in project jdk8u_jdk by JetBrains.
the class TestGetSoundbankUrl method main.
public static void main(String[] args) throws Exception {
File file = new File(System.getProperty("test.src", "."), "ding.sf2");
URL url = file.toURI().toURL();
Soundbank sf2 = new SF2SoundbankReader().getSoundbank(url);
assertTrue(sf2.getInstruments().length == 1);
Patch patch = sf2.getInstruments()[0].getPatch();
assertTrue(patch.getProgram() == 0);
assertTrue(patch.getBank() == 0);
}
use of javax.sound.midi.Soundbank in project jdk8u_jdk by JetBrains.
the class UnloadInstrument method main.
public static void main(String[] args) throws Exception {
AudioSynthesizer synth = new SoftSynthesizer();
synth.openStream(null, null);
Soundbank defsbk = synth.getDefaultSoundbank();
if (defsbk != null) {
synth.unloadAllInstruments(defsbk);
SimpleSoundbank sbk = new SimpleSoundbank();
SimpleInstrument ins = new SimpleInstrument();
ins.setPatch(new Patch(0, 1));
sbk.addInstrument(ins);
SimpleInstrument ins2 = new SimpleInstrument();
ins2.setPatch(new Patch(0, 2));
sbk.addInstrument(ins2);
synth.loadInstrument(ins2);
assertTrue(synth.getLoadedInstruments().length == 1);
synth.unloadInstrument(ins2);
assertTrue(synth.getLoadedInstruments().length == 0);
}
synth.close();
}
use of javax.sound.midi.Soundbank in project jdk8u_jdk by JetBrains.
the class UnloadInstruments method main.
public static void main(String[] args) throws Exception {
AudioSynthesizer synth = new SoftSynthesizer();
synth.openStream(null, null);
Soundbank defsbk = synth.getDefaultSoundbank();
if (defsbk != null) {
synth.unloadAllInstruments(defsbk);
SimpleSoundbank sbk = new SimpleSoundbank();
SimpleInstrument ins = new SimpleInstrument();
ins.setPatch(new Patch(0, 1));
sbk.addInstrument(ins);
SimpleInstrument ins2 = new SimpleInstrument();
ins2.setPatch(new Patch(0, 2));
sbk.addInstrument(ins2);
synth.loadInstrument(ins2);
assertTrue(synth.getLoadedInstruments().length == 1);
synth.unloadInstruments(sbk, new Patch[] { ins2.getPatch() });
assertTrue(synth.getLoadedInstruments().length == 0);
}
synth.close();
}
Aggregations