Search in sources :

Example 6 with Soundbank

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();
}
Also used : Soundbank(javax.sound.midi.Soundbank)

Example 7 with Soundbank

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);
}
Also used : Soundbank(javax.sound.midi.Soundbank) SF2SoundbankReader(com.sun.media.sound.SF2SoundbankReader) File(java.io.File) Patch(javax.sound.midi.Patch)

Example 8 with Soundbank

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();
    }
}
Also used : Soundbank(javax.sound.midi.Soundbank) BufferedInputStream(java.io.BufferedInputStream) SF2SoundbankReader(com.sun.media.sound.SF2SoundbankReader) File(java.io.File) Patch(javax.sound.midi.Patch) FileInputStream(java.io.FileInputStream)

Example 9 with Soundbank

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;
}
Also used : AudioInputStream(javax.sound.sampled.AudioInputStream) UnsupportedAudioFileException(javax.sound.sampled.UnsupportedAudioFileException) Soundbank(javax.sound.midi.Soundbank) IOException(java.io.IOException)

Example 10 with Soundbank

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;
    }
}
Also used : AudioInputStream(javax.sound.sampled.AudioInputStream) UnsupportedAudioFileException(javax.sound.sampled.UnsupportedAudioFileException) Soundbank(javax.sound.midi.Soundbank) IOException(java.io.IOException)

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