当前位置: 首页>>代码示例>>Java>>正文


Java Soundbank类代码示例

本文整理汇总了Java中javax.sound.midi.Soundbank的典型用法代码示例。如果您正苦于以下问题:Java Soundbank类的具体用法?Java Soundbank怎么用?Java Soundbank使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Soundbank类属于javax.sound.midi包,在下文中一共展示了Soundbank类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSoundbank

import javax.sound.midi.Soundbank; //导入依赖的package包/类
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;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:AudioFileSoundbankReader.java

示例2: main

import javax.sound.midi.Soundbank; //导入依赖的package包/类
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();

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:RemapInstrument.java

示例3: main

import javax.sound.midi.Soundbank; //导入依赖的package包/类
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();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:TestGetSoundbankInputStream.java

示例4: main

import javax.sound.midi.Soundbank; //导入依赖的package包/类
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.");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:ExtraCharInSoundbank.java

示例5: main

import javax.sound.midi.Soundbank; //导入依赖的package包/类
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();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:TestGetSoundbankInputStream2.java

示例6: main

import javax.sound.midi.Soundbank; //导入依赖的package包/类
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();
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:19,代码来源:TestGetSoundbankInputStream2.java

示例7: main

import javax.sound.midi.Soundbank; //导入依赖的package包/类
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();
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:18,代码来源:TestGetSoundbankInputStream.java

示例8: main

import javax.sound.midi.Soundbank; //导入依赖的package包/类
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();

}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:17,代码来源:UnloadAllInstruments.java

示例9: main

import javax.sound.midi.Soundbank; //导入依赖的package包/类
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();

}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:23,代码来源:UnloadInstrument.java

示例10: main

import javax.sound.midi.Soundbank; //导入依赖的package包/类
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();

}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:23,代码来源:UnloadInstruments.java

示例11: main

import javax.sound.midi.Soundbank; //导入依赖的package包/类
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();

}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:21,代码来源:LoadAllInstruments.java

示例12: main

import javax.sound.midi.Soundbank; //导入依赖的package包/类
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();

}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:21,代码来源:LoadInstrument.java

示例13: main

import javax.sound.midi.Soundbank; //导入依赖的package包/类
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();

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:TestDisableLoadDefaultSoundbank.java

示例14: getSoundbank

import javax.sound.midi.Soundbank; //导入依赖的package包/类
public Soundbank getSoundbank(URL url)
        throws InvalidMidiDataException, IOException {
    try {
        return new SF2Soundbank(url);
    } catch (RIFFInvalidFormatException e) {
        return null;
    } catch(IOException ioe) {
        return null;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:11,代码来源:SF2SoundbankReader.java

示例15: getAvailableInstruments

import javax.sound.midi.Soundbank; //导入依赖的package包/类
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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:SoftSynthesizer.java


注:本文中的javax.sound.midi.Soundbank类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。