use of javax.sound.midi.Soundbank in project jdk8u_jdk by JetBrains.
the class UnloadAllInstruments 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);
assertTrue(synth.getLoadedInstruments().length == 0);
synth.loadAllInstruments(defsbk);
assertTrue(synth.getLoadedInstruments().length != 0);
synth.unloadAllInstruments(defsbk);
assertTrue(synth.getLoadedInstruments().length == 0);
}
synth.close();
}
use of javax.sound.midi.Soundbank in project jdk8u_jdk by JetBrains.
the class TestGetSoundbankFile method main.
public static void main(String[] args) throws Exception {
File file = new File(System.getProperty("test.src", "."), "ding.sf2");
Soundbank sf2 = new SF2SoundbankReader().getSoundbank(file);
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 TestGetSoundbankInputStream 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 {
Soundbank sf2 = new SF2SoundbankReader().getSoundbank(bis);
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 AudioFileSoundbankReader method getSoundbank.
public Soundbank getSoundbank(InputStream stream) throws InvalidMidiDataException, IOException {
stream.mark(512);
try {
AudioInputStream ais = AudioSystem.getAudioInputStream(stream);
Soundbank sbk = getSoundbank(ais);
if (sbk != null)
return sbk;
} catch (UnsupportedAudioFileException e) {
} catch (IOException e) {
}
stream.reset();
return null;
}
use of javax.sound.midi.Soundbank in project jdk8u_jdk by JetBrains.
the class AudioFileSoundbankReader method getSoundbank.
public Soundbank getSoundbank(URL url) throws InvalidMidiDataException, IOException {
try {
AudioInputStream ais = AudioSystem.getAudioInputStream(url);
Soundbank sbk = getSoundbank(ais);
ais.close();
return sbk;
} catch (UnsupportedAudioFileException e) {
return null;
} catch (IOException e) {
return null;
}
}
Aggregations