Java 类javax.sound.midi.Instrument 实例源码

项目:OpenJSharp    文件:SF2Soundbank.java   
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;
}
项目:OpenJSharp    文件:SimpleSoundbank.java   
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;
}
项目:OpenJSharp    文件:DLSSoundbank.java   
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;
}
项目:OpenJSharp    文件:SoftSynthesizer.java   
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;
}
项目:OpenJSharp    文件:SoftSynthesizer.java   
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();
        }
    }
}
项目:OpenJSharp    文件:SoftSynthesizer.java   
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);
        }
    }
项目:jdk8u-jdk    文件:SF2Soundbank.java   
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;
}
项目:jdk8u-jdk    文件:SimpleSoundbank.java   
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;
}
项目:jdk8u-jdk    文件:DLSSoundbank.java   
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;
}
项目:jdk8u-jdk    文件:SoftSynthesizer.java   
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;
}
项目:jdk8u-jdk    文件:SoftSynthesizer.java   
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();
        }
    }
}
项目:jdk8u-jdk    文件:SoftSynthesizer.java   
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);
        }
    }
项目:jdk8u-jdk    文件:RemapInstrument.java   
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();

}
项目:openjdk-jdk10    文件:ModelAbstractOscillator.java   
@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;
}
项目:openjdk-jdk10    文件:SF2Soundbank.java   
@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;
}
项目:openjdk-jdk10    文件:SimpleSoundbank.java   
@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;
}
项目:openjdk-jdk10    文件:DLSSoundbank.java   
@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;
}
项目:openjdk-jdk10    文件:SoftSynthesizer.java   
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;
}
项目:openjdk-jdk10    文件:SoftSynthesizer.java   
@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();
        }
    }
}
项目:openjdk-jdk10    文件:RemapInstrument.java   
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();

}
项目:openjdk-jdk10    文件:ExtraCharInSoundbank.java   
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;
}
项目:openjdk9    文件:SF2Soundbank.java   
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;
}
项目:openjdk9    文件:SimpleSoundbank.java   
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;
}
项目:openjdk9    文件:SoftSynthesizer.java   
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;
}
项目:openjdk9    文件:SoftSynthesizer.java   
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();
        }
    }
}
项目:openjdk9    文件:SoftSynthesizer.java   
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);
        }
    }
项目:openjdk9    文件:RemapInstrument.java   
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();

}
项目:jdk8u_jdk    文件:SF2Soundbank.java   
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;
}
项目:jdk8u_jdk    文件:SimpleSoundbank.java   
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;
}
项目:jdk8u_jdk    文件:DLSSoundbank.java   
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;
}
项目:jdk8u_jdk    文件:SoftSynthesizer.java   
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;
}
项目:jdk8u_jdk    文件:SoftSynthesizer.java   
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();
        }
    }
}
项目:jdk8u_jdk    文件:SoftSynthesizer.java   
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);
        }
    }
项目:jdk8u_jdk    文件:RemapInstrument.java   
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();

}
项目:lookaside_java-1.8.0-openjdk    文件:SF2Soundbank.java   
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;
}
项目:TuxGuitar-1.3.1-fork    文件:SoftSynthesizer.java   
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;
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:SimpleSoundbank.java   
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;
}
项目:TuxGuitar-1.3.1-fork    文件:SoftSynthesizer.java   
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);
        }
    }
项目:lookaside_java-1.8.0-openjdk    文件:DLSSoundbank.java   
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;
}
项目:lookaside_java-1.8.0-openjdk    文件:SoftSynthesizer.java   
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;
}