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


Java SF2Layer类代码示例

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


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

示例1: newInstrument

import com.sun.media.sound.SF2Layer; //导入依赖的package包/类
public SF2Instrument newInstrument(SF2Soundbank sf2, String name,
        Patch patch, SF2Layer... layers) {

    /*
     * Create SoundFont2 instrument.
     */
    SF2Instrument ins = new SF2Instrument(sf2);
    ins.setPatch(patch);
    ins.setName(name);
    sf2.addInstrument(ins);

    /*
     * Create region for instrument.
     */
    for (int i = 0; i < layers.length; i++) {
        SF2InstrumentRegion insregion = new SF2InstrumentRegion();
        insregion.setLayer(layers[i]);
        ins.getRegions().add(insregion);
    }

    return ins;
}
 
开发者ID:bluenote10,项目名称:gervill,代码行数:23,代码来源:GeneratedInstrument1.java

示例2: createTestSoundbank

import com.sun.media.sound.SF2Layer; //导入依赖的package包/类
public static SF2Soundbank createTestSoundbank() {
    // Create impulse instrument
    // used to measure timing of note-on playback
    SF2Soundbank soundbank = new SF2Soundbank();
    float[] data = new float[100];
    Arrays.fill(data, 0);
    data[0] = 1.0f;
    byte[] bdata = new byte[data.length * format.getFrameSize()];
    AudioFloatConverter.getConverter(format).toByteArray(data, bdata);

    SF2Sample sample = new SF2Sample(soundbank);
    sample.setName("Test Sample");
    sample.setData(bdata);
    sample.setSampleRate((long) format.getSampleRate());
    sample.setOriginalPitch(69);
    soundbank.addResource(sample);

    SF2Layer layer = new SF2Layer(soundbank);
    layer.setName("Test Layer");
    soundbank.addResource(layer);
    SF2LayerRegion region = new SF2LayerRegion();
    region.setSample(sample);
    layer.getRegions().add(region);

    SF2Instrument ins = new SF2Instrument(soundbank);
    ins.setName("Test Instrument");
    soundbank.addInstrument(ins);
    SF2InstrumentRegion insregion = new SF2InstrumentRegion();
    insregion.setLayer(layer);
    ins.getRegions().add(insregion);

    return soundbank;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:34,代码来源:TestPreciseTimestampRendering.java

示例3: addResource

import com.sun.media.sound.SF2Layer; //导入依赖的package包/类
public void addResource(SoundbankResource resource) {
    if (resource instanceof SF2Instrument)
        instruments.add((SF2Instrument)resource);
    if (resource instanceof SF2Layer)
        layers.add((SF2Layer)resource);
    if (resource instanceof SF2Sample)
        samples.add((SF2Sample)resource);
}
 
开发者ID:theokyr,项目名称:TuxGuitar-1.3.1-fork,代码行数:9,代码来源:SF2Soundbank.java

示例4: removeResource

import com.sun.media.sound.SF2Layer; //导入依赖的package包/类
public void removeResource(SoundbankResource resource) {
    if (resource instanceof SF2Instrument)
        instruments.remove((SF2Instrument)resource);
    if (resource instanceof SF2Layer)
        layers.remove((SF2Layer)resource);
    if (resource instanceof SF2Sample)
        samples.remove((SF2Sample)resource);
}
 
开发者ID:theokyr,项目名称:TuxGuitar-1.3.1-fork,代码行数:9,代码来源:SF2Soundbank.java

示例5: newLayer

import com.sun.media.sound.SF2Layer; //导入依赖的package包/类
public SF2Layer newLayer(SF2Soundbank sf2, String name, SF2Sample sample) {
    SF2LayerRegion region = new SF2LayerRegion();
    region.setSample(sample);

    SF2Layer layer = new SF2Layer(sf2);
    layer.setName(name);
    layer.getRegions().add(region);
    sf2.addResource(layer);

    return layer;
}
 
开发者ID:bluenote10,项目名称:gervill,代码行数:12,代码来源:GeneratedInstrument1.java

示例6: getLayer

import com.sun.media.sound.SF2Layer; //导入依赖的package包/类
public SF2Layer getLayer() {
    return layer;
}
 
开发者ID:axlecho,项目名称:tuxguitar,代码行数:4,代码来源:SF2InstrumentRegion.java

示例7: setLayer

import com.sun.media.sound.SF2Layer; //导入依赖的package包/类
public void setLayer(SF2Layer layer) {
    this.layer = layer;
}
 
开发者ID:axlecho,项目名称:tuxguitar,代码行数:4,代码来源:SF2InstrumentRegion.java

示例8: main

import com.sun.media.sound.SF2Layer; //导入依赖的package包/类
public static void main(String[] args) throws Exception
{
    // Create instance of the synthesizer with very low polyphony
    AudioSynthesizer synth = new SoftSynthesizer();
    AudioFormat format = new AudioFormat(44100, 16, 2, true, false);
    Map<String, Object> p = new HashMap<String, Object>();
    p.put("max polyphony", new Integer(5));
    AudioInputStream stream = synth.openStream(format, p);

    // Create instrument with too many regions (more than max polyphony)
    SF2Soundbank sf2 = new SF2Soundbank();

    SF2Sample sample = new SF2Sample(sf2);
    sample.setName("test sample");
    sample.setData(new byte[100]);
    sample.setSampleRate(44100);
    sample.setOriginalPitch(20);
    sf2.addResource(sample);

    SF2Layer layer = new SF2Layer(sf2);
    layer.setName("test layer");
    sf2.addResource(layer);

    for (int i = 0; i < 100; i++) {
        SF2LayerRegion region = new SF2LayerRegion();
        region.setSample(sample);
        layer.getRegions().add(region);
    }

    SF2Instrument ins = new SF2Instrument(sf2);
    ins.setPatch(new Patch(0,0));
    ins.setName("test instrument");
    sf2.addInstrument(ins);

    SF2InstrumentRegion insregion = new SF2InstrumentRegion();
    insregion.setLayer(layer);
    ins.getRegions().add(insregion);

    // Load the test soundbank into the synthesizer
    synth.unloadAllInstruments(synth.getDefaultSoundbank());
    synth.loadAllInstruments(sf2);

    // Send out one midi on message
    MidiChannel ch1 = synth.getChannels()[0];
    ch1.programChange(0);
    ch1.noteOn(64, 64);

    // Read 1 sec from stream
    stream.skip(format.getFrameSize() * ((int)(format.getFrameRate() * 2)));

    // Close the synthesizer after use
    synth.close();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:54,代码来源:NoteOverFlowTest2.java

示例9: getLayers

import com.sun.media.sound.SF2Layer; //导入依赖的package包/类
public SF2Layer[] getLayers() {
    return layers.toArray(new SF2Layer[layers.size()]);
}
 
开发者ID:theokyr,项目名称:TuxGuitar-1.3.1-fork,代码行数:4,代码来源:SF2Soundbank.java


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