Search in sources :

Example 1 with Soundbank

use of javax.sound.midi.Soundbank in project jdk8u_jdk by JetBrains.

the class TestDisableLoadDefaultSoundbank 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) {
        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();
}
Also used : Soundbank(javax.sound.midi.Soundbank) HashMap(java.util.HashMap)

Example 2 with Soundbank

use of javax.sound.midi.Soundbank in project jdk8u_jdk by JetBrains.

the class GetAvailableInstruments2 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(defsbk.getInstruments().length == synth.getAvailableInstruments().length);
    }
    synth.close();
}
Also used : Soundbank(javax.sound.midi.Soundbank)

Example 3 with Soundbank

use of javax.sound.midi.Soundbank in project jdk8u_jdk by JetBrains.

the class LoadAllInstruments 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.loadAllInstruments(sbk);
        assertTrue(synth.getLoadedInstruments().length == 2);
    }
    synth.close();
}
Also used : Soundbank(javax.sound.midi.Soundbank) Patch(javax.sound.midi.Patch)

Example 4 with Soundbank

use of javax.sound.midi.Soundbank in project jdk8u_jdk by JetBrains.

the class LoadInstruments 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.loadInstruments(sbk, new Patch[] { ins2.getPatch() });
        assertTrue(synth.getLoadedInstruments().length == 1);
    }
    synth.close();
}
Also used : Soundbank(javax.sound.midi.Soundbank) Patch(javax.sound.midi.Patch)

Example 5 with Soundbank

use of javax.sound.midi.Soundbank in project jdk8u_jdk by JetBrains.

the class GetLoadedInstruments 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);
        synth.loadAllInstruments(defsbk);
        assertTrue(synth.getLoadedInstruments().length != 0);
    }
    synth.close();
}
Also used : Soundbank(javax.sound.midi.Soundbank)

Aggregations

Soundbank (javax.sound.midi.Soundbank)24 Patch (javax.sound.midi.Patch)12 File (java.io.File)5 SF2SoundbankReader (com.sun.media.sound.SF2SoundbankReader)4 BufferedInputStream (java.io.BufferedInputStream)3 FileInputStream (java.io.FileInputStream)3 IOException (java.io.IOException)3 InputStream (java.io.InputStream)3 Instrument (javax.sound.midi.Instrument)3 AudioInputStream (javax.sound.sampled.AudioInputStream)3 ArrayList (java.util.ArrayList)2 MidiUnavailableException (javax.sound.midi.MidiUnavailableException)2 UnsupportedAudioFileException (javax.sound.sampled.UnsupportedAudioFileException)2 EmergencySoundbank (com.sun.media.sound.EmergencySoundbank)1 ModelInstrument (com.sun.media.sound.ModelInstrument)1 ModelPatch (com.sun.media.sound.ModelPatch)1 BufferedReader (java.io.BufferedReader)1 FileNotFoundException (java.io.FileNotFoundException)1 FileOutputStream (java.io.FileOutputStream)1 InputStreamReader (java.io.InputStreamReader)1