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


Java Instrument类代码示例

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


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

示例1: getInstrument

import javax.sound.midi.Instrument; //导入依赖的package包/类
public Instrument getInstrument(Patch patch) {
    int program = patch.getProgram();
    int bank = patch.getBank();
    boolean percussion = false;
    if (patch instanceof ModelPatch)
        percussion = ((ModelPatch)patch).isPercussion();
    for (Instrument instrument : instruments) {
        Patch patch2 = instrument.getPatch();
        int program2 = patch2.getProgram();
        int bank2 = patch2.getBank();
        if (program == program2 && bank == bank2) {
            boolean percussion2 = false;
            if (patch2 instanceof ModelPatch)
                percussion2 = ((ModelPatch) patch2).isPercussion();
            if (percussion == percussion2)
                return instrument;
        }
    }
    return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:SF2Soundbank.java

示例2: getInstrument

import javax.sound.midi.Instrument; //导入依赖的package包/类
public Instrument getInstrument(Patch patch) {
    int program = patch.getProgram();
    int bank = patch.getBank();
    boolean percussion = false;
    if (patch instanceof ModelPatch)
        percussion = ((ModelPatch)patch).isPercussion();
    for (Instrument instrument : instruments) {
        Patch patch2 = instrument.getPatch();
        int program2 = patch2.getProgram();
        int bank2 = patch2.getBank();
        if (program == program2 && bank == bank2) {
            boolean percussion2 = false;
            if (patch2 instanceof ModelPatch)
                percussion2 = ((ModelPatch)patch2).isPercussion();
            if (percussion == percussion2)
                return instrument;
        }
    }
    return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:SimpleSoundbank.java

示例3: getInstrument

import javax.sound.midi.Instrument; //导入依赖的package包/类
public Instrument getInstrument(Patch patch) {
    int program = patch.getProgram();
    int bank = patch.getBank();
    boolean percussion = false;
    if (patch instanceof ModelPatch)
        percussion = ((ModelPatch) patch).isPercussion();
    for (Instrument instrument : instruments) {
        Patch patch2 = instrument.getPatch();
        int program2 = patch2.getProgram();
        int bank2 = patch2.getBank();
        if (program == program2 && bank == bank2) {
            boolean percussion2 = false;
            if (patch2 instanceof ModelPatch)
                percussion2 = ((ModelPatch) patch2).isPercussion();
            if (percussion == percussion2)
                return instrument;
        }
    }
    return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:DLSSoundbank.java

示例4: loadInstruments

import javax.sound.midi.Instrument; //导入依赖的package包/类
private boolean loadInstruments(List<ModelInstrument> instruments) {
    if (!isOpen())
        return false;
    if (!loadSamples(instruments))
        return false;

    synchronized (control_mutex) {
        if (channels != null)
            for (SoftChannel c : channels)
            {
                c.current_instrument = null;
                c.current_director = null;
            }
        for (Instrument instrument : instruments) {
            String pat = patchToString(instrument.getPatch());
            SoftInstrument softins
                    = new SoftInstrument((ModelInstrument) instrument);
            inslist.put(pat, softins);
            loadedlist.put(pat, (ModelInstrument) instrument);
        }
    }

    return true;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:SoftSynthesizer.java

示例5: unloadInstrument

import javax.sound.midi.Instrument; //导入依赖的package包/类
public void unloadInstrument(Instrument instrument) {
    if (instrument == null || (!(instrument instanceof ModelInstrument))) {
        throw new IllegalArgumentException("Unsupported instrument: " +
                instrument);
    }
    if (!isOpen())
        return;

    String pat = patchToString(instrument.getPatch());
    synchronized (control_mutex) {
        for (SoftChannel c: channels)
            c.current_instrument = null;
        inslist.remove(pat);
        loadedlist.remove(pat);
        for (int i = 0; i < channels.length; i++) {
            channels[i].allSoundOff();
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:SoftSynthesizer.java

示例6: remapInstrument

import javax.sound.midi.Instrument; //导入依赖的package包/类
public boolean remapInstrument(Instrument from, Instrument to) {

        if (from == null)
            throw new NullPointerException();
        if (to == null)
            throw new NullPointerException();
        if (!(from instanceof ModelInstrument)) {
            throw new IllegalArgumentException("Unsupported instrument: " +
                    from.toString());
        }
        if (!(to instanceof ModelInstrument)) {
            throw new IllegalArgumentException("Unsupported instrument: " +
                    to.toString());
        }
        if (!isOpen())
            return false;

        synchronized (control_mutex) {
            if (!loadedlist.containsValue(to))
                throw new IllegalArgumentException("Instrument to is not loaded.");
            unloadInstrument(from);
            ModelMappedInstrument mfrom = new ModelMappedInstrument(
                    (ModelInstrument)to, from.getPatch());
            return loadInstrument(mfrom);
        }
    }
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:27,代码来源:SoftSynthesizer.java

示例7: main

import javax.sound.midi.Instrument; //导入依赖的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:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:24,代码来源:RemapInstrument.java

示例8: getInstrument

import javax.sound.midi.Instrument; //导入依赖的package包/类
@Override
public Instrument getInstrument(Patch patch) {
    Instrument ins = getInstrument();
    Patch p = ins.getPatch();
    if (p.getBank() != patch.getBank())
        return null;
    if (p.getProgram() != patch.getProgram())
        return null;
    if (p instanceof ModelPatch && patch instanceof ModelPatch) {
        if (((ModelPatch)p).isPercussion()
                != ((ModelPatch)patch).isPercussion()) {
            return null;
        }
    }
    return ins;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:ModelAbstractOscillator.java

示例9: getInstrument

import javax.sound.midi.Instrument; //导入依赖的package包/类
@Override
public Instrument getInstrument(Patch patch) {
    int program = patch.getProgram();
    int bank = patch.getBank();
    boolean percussion = false;
    if (patch instanceof ModelPatch)
        percussion = ((ModelPatch)patch).isPercussion();
    for (Instrument instrument : instruments) {
        Patch patch2 = instrument.getPatch();
        int program2 = patch2.getProgram();
        int bank2 = patch2.getBank();
        if (program == program2 && bank == bank2) {
            boolean percussion2 = false;
            if (patch2 instanceof ModelPatch)
                percussion2 = ((ModelPatch) patch2).isPercussion();
            if (percussion == percussion2)
                return instrument;
        }
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:SF2Soundbank.java

示例10: getInstrument

import javax.sound.midi.Instrument; //导入依赖的package包/类
@Override
public Instrument getInstrument(Patch patch) {
    int program = patch.getProgram();
    int bank = patch.getBank();
    boolean percussion = false;
    if (patch instanceof ModelPatch)
        percussion = ((ModelPatch)patch).isPercussion();
    for (Instrument instrument : instruments) {
        Patch patch2 = instrument.getPatch();
        int program2 = patch2.getProgram();
        int bank2 = patch2.getBank();
        if (program == program2 && bank == bank2) {
            boolean percussion2 = false;
            if (patch2 instanceof ModelPatch)
                percussion2 = ((ModelPatch)patch2).isPercussion();
            if (percussion == percussion2)
                return instrument;
        }
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:SimpleSoundbank.java

示例11: getInstrument

import javax.sound.midi.Instrument; //导入依赖的package包/类
@Override
public Instrument getInstrument(Patch patch) {
    int program = patch.getProgram();
    int bank = patch.getBank();
    boolean percussion = false;
    if (patch instanceof ModelPatch)
        percussion = ((ModelPatch) patch).isPercussion();
    for (Instrument instrument : instruments) {
        Patch patch2 = instrument.getPatch();
        int program2 = patch2.getProgram();
        int bank2 = patch2.getBank();
        if (program == program2 && bank == bank2) {
            boolean percussion2 = false;
            if (patch2 instanceof ModelPatch)
                percussion2 = ((ModelPatch) patch2).isPercussion();
            if (percussion == percussion2)
                return instrument;
        }
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:DLSSoundbank.java

示例12: unloadInstrument

import javax.sound.midi.Instrument; //导入依赖的package包/类
@Override
public void unloadInstrument(Instrument instrument) {
    if (instrument == null || (!(instrument instanceof ModelInstrument))) {
        throw new IllegalArgumentException("Unsupported instrument: " +
                instrument);
    }
    if (!isOpen())
        return;

    String pat = patchToString(instrument.getPatch());
    synchronized (control_mutex) {
        for (SoftChannel c: channels)
            c.current_instrument = null;
        inslist.remove(pat);
        loadedlist.remove(pat);
        for (int i = 0; i < channels.length; i++) {
            channels[i].allSoundOff();
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:SoftSynthesizer.java

示例13: checkInstrumentNames

import javax.sound.midi.Instrument; //导入依赖的package包/类
public static boolean checkInstrumentNames(Synthesizer theSynthesizer)
{
    boolean containsControlCharacters = false;

    Instrument[] theLoadedInstruments = theSynthesizer.getLoadedInstruments();

    System.out.println("Checking soundbank...");
    for(int theInstrumentIndex = 0; theInstrumentIndex < theLoadedInstruments.length; theInstrumentIndex++) {
        String name = theLoadedInstruments[theInstrumentIndex].getName();
        if (containsControlChar(name)) {
            containsControlCharacters = true;
            System.out.print("Instrument[" + theInstrumentIndex + "] contains unexpected control characters: ");
            printName(name);
        }
    }
    return !containsControlCharacters;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:ExtraCharInSoundbank.java

示例14: getAvailableInstruments

import javax.sound.midi.Instrument; //导入依赖的package包/类
public Instrument[] getAvailableInstruments() {
    if (!isOpen()) {
        Soundbank defsbk = getDefaultSoundbank();
        if (defsbk == null)
            return new Instrument[0];
        return defsbk.getInstruments();
    }

    synchronized (control_mutex) {
        ModelInstrument[] inslist_array =
                new ModelInstrument[availlist.values().size()];
        availlist.values().toArray(inslist_array);
        Arrays.sort(inslist_array, new ModelInstrumentComparator());
        return inslist_array;
    }
}
 
开发者ID:theokyr,项目名称:TuxGuitar-1.3.1-fork,代码行数:17,代码来源:SoftSynthesizer.java

示例15: remapInstrument

import javax.sound.midi.Instrument; //导入依赖的package包/类
public boolean remapInstrument(Instrument from, Instrument to) {

        if (from == null)
            throw new NullPointerException();
        if (to == null)
            throw new NullPointerException();
        if (!(from instanceof ModelInstrument)) {
            throw new IllegalArgumentException("Unsupported instrument: " +
                    from.toString());
        }
        if (!(to instanceof ModelInstrument)) {
            throw new IllegalArgumentException("Unsupported instrument: " +
                    to.toString());
        }
        if (!isOpen())
            return false;

        synchronized (control_mutex) {
            if (!loadedlist.containsValue(to) && !availlist.containsValue(to))
                throw new IllegalArgumentException("Instrument to is not loaded.");
            unloadInstrument(from);
            ModelMappedInstrument mfrom = new ModelMappedInstrument(
                    (ModelInstrument)to, from.getPatch());
            return loadInstrument(mfrom);
        }
    }
 
开发者ID:theokyr,项目名称:TuxGuitar-1.3.1-fork,代码行数:27,代码来源:SoftSynthesizer.java


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