Java 类javax.sound.midi.Soundbank 实例源码

项目:OpenJSharp    文件:AudioFileSoundbankReader.java   
public Soundbank getSoundbank(File file)
        throws InvalidMidiDataException, IOException {
    try {
        AudioInputStream ais = AudioSystem.getAudioInputStream(file);
        ais.close();
        ModelByteBufferWavetable osc = new ModelByteBufferWavetable(
                new ModelByteBuffer(file, 0, file.length()), -4800);
        ModelPerformer performer = new ModelPerformer();
        performer.getOscillators().add(osc);
        SimpleSoundbank sbk = new SimpleSoundbank();
        SimpleInstrument ins = new SimpleInstrument();
        ins.add(performer);
        sbk.addInstrument(ins);
        return sbk;
    } catch (UnsupportedAudioFileException e1) {
        return null;
    } catch (IOException e) {
        return null;
    }
}
项目:jdk8u-jdk    文件:AudioFileSoundbankReader.java   
public Soundbank getSoundbank(File file)
        throws InvalidMidiDataException, IOException {
    try {
        AudioInputStream ais = AudioSystem.getAudioInputStream(file);
        ais.close();
        ModelByteBufferWavetable osc = new ModelByteBufferWavetable(
                new ModelByteBuffer(file, 0, file.length()), -4800);
        ModelPerformer performer = new ModelPerformer();
        performer.getOscillators().add(osc);
        SimpleSoundbank sbk = new SimpleSoundbank();
        SimpleInstrument ins = new SimpleInstrument();
        ins.add(performer);
        sbk.addInstrument(ins);
        return sbk;
    } catch (UnsupportedAudioFileException e1) {
        return null;
    } catch (IOException e) {
        return null;
    }
}
项目:openjdk-jdk10    文件:RemapInstrument.java   
public static void main(String[] args) throws Exception {
    AudioSynthesizer synth = new SoftSynthesizer();
    synth.openStream(null, null);
    Soundbank defsbk = synth.getDefaultSoundbank();
    if(defsbk != null)
    {
        Instrument ins3 = defsbk.getInstrument(new Patch(0,3));
        Instrument ins10 = defsbk.getInstrument(new Patch(0,10));
        assertTrue(synth.remapInstrument(ins3, ins10));
        Instrument[] loaded = synth.getLoadedInstruments();
        for (int i = 0; i < loaded.length; i++) {
            if(loaded[i].getPatch().getBank() == ins3.getPatch().getBank())
            if(loaded[i].getPatch().getProgram() == ins3.getPatch().getProgram())
            {
                assertEquals(loaded[i].getName(), ins10.getName());
                break;
            }
        }

    }
    synth.close();

}
项目:openjdk-jdk10    文件:TestGetSoundbankInputStream.java   
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();
    }
}
项目:openjdk-jdk10    文件:ExtraCharInSoundbank.java   
public static void main(String[] args) throws Exception {
    // the internal synthesizer needs a soundcard to work properly
    if (!isSoundcardInstalled()) {
        return;
    }
    Synthesizer theSynth = MidiSystem.getSynthesizer();
    System.out.println("Got synth: "+theSynth);
    theSynth.open();
    try {
        Soundbank theSoundbank = theSynth.getDefaultSoundbank();
        System.out.println("Got soundbank: "+theSoundbank);
        theSynth.loadAllInstruments(theSoundbank);
        try {
                if (!checkInstrumentNames(theSynth)) {
                        throw new Exception("Test failed");
                }
        } finally {
                theSynth.unloadAllInstruments(theSoundbank);
        }
    } finally {
        theSynth.close();
    }
    System.out.println("Test passed.");
}
项目:openjdk-jdk10    文件:TestGetSoundbankInputStream2.java   
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();
    }
}
项目:jdk8u-jdk    文件:TestGetSoundbankInputStream2.java   
public static void main(String[] args) throws Exception {
    File file = new File(System.getProperty("test.src", "."), "ding.dls");
    FileInputStream fis = new FileInputStream(file);
    BufferedInputStream bis = new BufferedInputStream(fis);
    try
    {
        InputStream badis = new BadInputStream(bis);
        Soundbank dls = new DLSSoundbankReader().getSoundbank(badis);
        assertTrue(dls.getInstruments().length == 1);
        Patch patch = dls.getInstruments()[0].getPatch();
        assertTrue(patch.getProgram() == 0);
        assertTrue(patch.getBank() == 0);
    }
    finally
    {
        bis.close();
    }
}
项目:jdk8u-jdk    文件:TestGetSoundbankInputStream.java   
public static void main(String[] args) throws Exception {
    File file = new File(System.getProperty("test.src", "."), "ding.dls");
    FileInputStream fis = new FileInputStream(file);
    BufferedInputStream bis = new BufferedInputStream(fis);
    try
    {
        Soundbank dls = new DLSSoundbankReader().getSoundbank(bis);
        assertTrue(dls.getInstruments().length == 1);
        Patch patch = dls.getInstruments()[0].getPatch();
        assertTrue(patch.getProgram() == 0);
        assertTrue(patch.getBank() == 0);
    }
    finally
    {
        bis.close();
    }
}
项目:jdk8u-jdk    文件:UnloadAllInstruments.java   
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();

}
项目:jdk8u-jdk    文件:UnloadInstrument.java   
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();

}
项目:jdk8u-jdk    文件:UnloadInstruments.java   
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();

}
项目:jdk8u-jdk    文件:LoadAllInstruments.java   
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.loadAllInstruments(sbk);
        assertTrue(synth.getLoadedInstruments().length == 2);
    }
    synth.close();

}
项目:jdk8u-jdk    文件:RemapInstrument.java   
public static void main(String[] args) throws Exception {
    AudioSynthesizer synth = new SoftSynthesizer();
    synth.openStream(null, null);
    Soundbank defsbk = synth.getDefaultSoundbank();
    if(defsbk != null)
    {
        Instrument ins3 = defsbk.getInstrument(new Patch(0,3));
        Instrument ins10 = defsbk.getInstrument(new Patch(0,10));
        assertTrue(synth.remapInstrument(ins3, ins10));
        Instrument[] loaded = synth.getLoadedInstruments();
        for (int i = 0; i < loaded.length; i++) {
            if(loaded[i].getPatch().getBank() == ins3.getPatch().getBank())
            if(loaded[i].getPatch().getProgram() == ins3.getPatch().getProgram())
            {
                assertEquals(loaded[i].getName(), ins10.getName());
                break;
            }
        }

    }
    synth.close();

}
项目:jdk8u-jdk    文件:LoadInstrument.java   
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.close();

}
项目:jdk8u-jdk    文件:TestGetSoundbankInputStream2.java   
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();
    }
}
项目:jdk8u-jdk    文件:TestGetSoundbankInputStream.java   
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();
    }
}
项目:openjdk-jdk10    文件:LoadAllInstruments.java   
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.loadAllInstruments(sbk);
        assertTrue(synth.getLoadedInstruments().length == 2);
    }
    synth.close();

}
项目:openjdk-jdk10    文件:LoadInstrument.java   
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.close();

}
项目:openjdk-jdk10    文件:TestGetSoundbankInputStream.java   
public static void main(String[] args) throws Exception {
    File file = new File(System.getProperty("test.src", "."), "ding.dls");
    FileInputStream fis = new FileInputStream(file);
    BufferedInputStream bis = new BufferedInputStream(fis);
    try
    {
        Soundbank dls = new DLSSoundbankReader().getSoundbank(bis);
        assertTrue(dls.getInstruments().length == 1);
        Patch patch = dls.getInstruments()[0].getPatch();
        assertTrue(patch.getProgram() == 0);
        assertTrue(patch.getBank() == 0);
    }
    finally
    {
        bis.close();
    }
}
项目:openjdk-jdk10    文件:TestDisableLoadDefaultSoundbank.java   
public static void main(String[] args) throws Exception {
    AudioSynthesizer synth = new SoftSynthesizer();
    synth.openStream(null, null);
    Soundbank defsbk = synth.getDefaultSoundbank();
    if (defsbk != null) {
        assertTrue(defsbk.getInstruments().length == synth
                .getLoadedInstruments().length);
    }
    synth.close();
    Map<String, Object> p = new HashMap<String, Object>();
    p.put("load default soundbank", false);
    synth.openStream(null, p);
    if (defsbk != null) {
        assertTrue(synth.getLoadedInstruments().length == 0);
    }
    synth.close();

}
项目:openjdk-jdk10    文件:UnloadInstruments.java   
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();

}
项目:OpenJSharp    文件:AudioFileSoundbankReader.java   
public Soundbank getSoundbank(AudioInputStream ais)
        throws InvalidMidiDataException, IOException {
    try {
        byte[] buffer;
        if (ais.getFrameLength() == -1) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            byte[] buff = new byte[1024
                    - (1024 % ais.getFormat().getFrameSize())];
            int ret;
            while ((ret = ais.read(buff)) != -1) {
                baos.write(buff, 0, ret);
            }
            ais.close();
            buffer = baos.toByteArray();
        } else {
            buffer = new byte[(int) (ais.getFrameLength()
                                * ais.getFormat().getFrameSize())];
            new DataInputStream(ais).readFully(buffer);
        }
        ModelByteBufferWavetable osc = new ModelByteBufferWavetable(
                new ModelByteBuffer(buffer), ais.getFormat(), -4800);
        ModelPerformer performer = new ModelPerformer();
        performer.getOscillators().add(osc);

        SimpleSoundbank sbk = new SimpleSoundbank();
        SimpleInstrument ins = new SimpleInstrument();
        ins.add(performer);
        sbk.addInstrument(ins);
        return sbk;
    } catch (Exception e) {
        return null;
    }
}
项目:OpenJSharp    文件:SF2SoundbankReader.java   
public Soundbank getSoundbank(URL url)
        throws InvalidMidiDataException, IOException {
    try {
        return new SF2Soundbank(url);
    } catch (RIFFInvalidFormatException e) {
        return null;
    } catch(IOException ioe) {
        return null;
    }
}
项目:OpenJSharp    文件:SF2SoundbankReader.java   
public Soundbank getSoundbank(InputStream stream)
        throws InvalidMidiDataException, IOException {
    try {
        stream.mark(512);
        return new SF2Soundbank(stream);
    } catch (RIFFInvalidFormatException e) {
        stream.reset();
        return null;
    }
}
项目:OpenJSharp    文件:SF2SoundbankReader.java   
public Soundbank getSoundbank(File file)
        throws InvalidMidiDataException, IOException {
    try {
        return new SF2Soundbank(file);
    } catch (RIFFInvalidFormatException e) {
        return null;
    }
}
项目:OpenJSharp    文件:SoftSynthesizer.java   
public Instrument[] getAvailableInstruments() {
    Soundbank defsbk = getDefaultSoundbank();
    if (defsbk == null)
        return new Instrument[0];
    Instrument[] inslist_array = defsbk.getInstruments();
    Arrays.sort(inslist_array, new ModelInstrumentComparator());
    return inslist_array;
}
项目:OpenJSharp    文件:SoftSynthesizer.java   
public boolean loadAllInstruments(Soundbank soundbank) {
    List<ModelInstrument> instruments = new ArrayList<ModelInstrument>();
    for (Instrument ins: soundbank.getInstruments()) {
        if (ins == null || !(ins instanceof ModelInstrument)) {
            throw new IllegalArgumentException(
                    "Unsupported instrument: " + ins);
        }
        instruments.add((ModelInstrument)ins);
    }
    return loadInstruments(instruments);
}
项目:OpenJSharp    文件:SoftSynthesizer.java   
public void unloadAllInstruments(Soundbank soundbank) {
    if (soundbank == null || !isSoundbankSupported(soundbank))
        throw new IllegalArgumentException("Unsupported soundbank: " + soundbank);

    if (!isOpen())
        return;

    for (Instrument ins: soundbank.getInstruments()) {
        if (ins instanceof ModelInstrument) {
            unloadInstrument(ins);
        }
    }
}
项目:OpenJSharp    文件:SoftSynthesizer.java   
public boolean loadInstruments(Soundbank soundbank, Patch[] patchList) {
    List<ModelInstrument> instruments = new ArrayList<ModelInstrument>();
    for (Patch patch: patchList) {
        Instrument ins = soundbank.getInstrument(patch);
        if (ins == null || !(ins instanceof ModelInstrument)) {
            throw new IllegalArgumentException(
                    "Unsupported instrument: " + ins);
        }
        instruments.add((ModelInstrument)ins);
    }
    return loadInstruments(instruments);
}
项目:openjdk-jdk10    文件:TestGetSoundbankUrl.java   
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);
}
项目:OpenJSharp    文件:DLSSoundbankReader.java   
public Soundbank getSoundbank(URL url)
        throws InvalidMidiDataException, IOException {
    try {
        return new DLSSoundbank(url);
    } catch (RIFFInvalidFormatException e) {
        return null;
    } catch(IOException ioe) {
        return null;
    }
}
项目:OpenJSharp    文件:DLSSoundbankReader.java   
public Soundbank getSoundbank(InputStream stream)
        throws InvalidMidiDataException, IOException {
    try {
        stream.mark(512);
        return new DLSSoundbank(stream);
    } catch (RIFFInvalidFormatException e) {
        stream.reset();
        return null;
    }
}
项目:OpenJSharp    文件:DLSSoundbankReader.java   
public Soundbank getSoundbank(File file)
        throws InvalidMidiDataException, IOException {
    try {
        return new DLSSoundbank(file);
    } catch (RIFFInvalidFormatException e) {
        return null;
    }
}
项目:jdk8u-jdk    文件:AudioFileSoundbankReader.java   
public Soundbank getSoundbank(AudioInputStream ais)
        throws InvalidMidiDataException, IOException {
    try {
        byte[] buffer;
        if (ais.getFrameLength() == -1) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            byte[] buff = new byte[1024
                    - (1024 % ais.getFormat().getFrameSize())];
            int ret;
            while ((ret = ais.read(buff)) != -1) {
                baos.write(buff, 0, ret);
            }
            ais.close();
            buffer = baos.toByteArray();
        } else {
            buffer = new byte[(int) (ais.getFrameLength()
                                * ais.getFormat().getFrameSize())];
            new DataInputStream(ais).readFully(buffer);
        }
        ModelByteBufferWavetable osc = new ModelByteBufferWavetable(
                new ModelByteBuffer(buffer), ais.getFormat(), -4800);
        ModelPerformer performer = new ModelPerformer();
        performer.getOscillators().add(osc);

        SimpleSoundbank sbk = new SimpleSoundbank();
        SimpleInstrument ins = new SimpleInstrument();
        ins.add(performer);
        sbk.addInstrument(ins);
        return sbk;
    } catch (Exception e) {
        return null;
    }
}
项目:jdk8u-jdk    文件:SF2SoundbankReader.java   
public Soundbank getSoundbank(URL url)
        throws InvalidMidiDataException, IOException {
    try {
        return new SF2Soundbank(url);
    } catch (RIFFInvalidFormatException e) {
        return null;
    } catch(IOException ioe) {
        return null;
    }
}
项目:jdk8u-jdk    文件:SF2SoundbankReader.java   
public Soundbank getSoundbank(InputStream stream)
        throws InvalidMidiDataException, IOException {
    try {
        stream.mark(512);
        return new SF2Soundbank(stream);
    } catch (RIFFInvalidFormatException e) {
        stream.reset();
        return null;
    }
}
项目:jdk8u-jdk    文件:SF2SoundbankReader.java   
public Soundbank getSoundbank(File file)
        throws InvalidMidiDataException, IOException {
    try {
        return new SF2Soundbank(file);
    } catch (RIFFInvalidFormatException e) {
        return null;
    }
}
项目:jdk8u-jdk    文件:SoftSynthesizer.java   
public Instrument[] getAvailableInstruments() {
    Soundbank defsbk = getDefaultSoundbank();
    if (defsbk == null)
        return new Instrument[0];
    Instrument[] inslist_array = defsbk.getInstruments();
    Arrays.sort(inslist_array, new ModelInstrumentComparator());
    return inslist_array;
}
项目:jdk8u-jdk    文件:SoftSynthesizer.java   
public boolean loadAllInstruments(Soundbank soundbank) {
    List<ModelInstrument> instruments = new ArrayList<ModelInstrument>();
    for (Instrument ins: soundbank.getInstruments()) {
        if (ins == null || !(ins instanceof ModelInstrument)) {
            throw new IllegalArgumentException(
                    "Unsupported instrument: " + ins);
        }
        instruments.add((ModelInstrument)ins);
    }
    return loadInstruments(instruments);
}
项目:jdk8u-jdk    文件:SoftSynthesizer.java   
public void unloadAllInstruments(Soundbank soundbank) {
    if (soundbank == null || !isSoundbankSupported(soundbank))
        throw new IllegalArgumentException("Unsupported soundbank: " + soundbank);

    if (!isOpen())
        return;

    for (Instrument ins: soundbank.getInstruments()) {
        if (ins instanceof ModelInstrument) {
            unloadInstrument(ins);
        }
    }
}