Search in sources :

Example 6 with Instrument

use of javax.sound.midi.Instrument in project jdk8u_jdk by JetBrains.

the class SoftSynthesizer method loadInstruments.

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

Example 7 with Instrument

use of javax.sound.midi.Instrument in project jdk8u_jdk by JetBrains.

the class SoftSynthesizer method loadInstruments.

public boolean loadInstruments(Soundbank soundbank, Patch[] patchList) {
    List<ModelInstrument> instruments = new ArrayList<ModelInstrument>();
    for (Patch patch : patchList) {
        Instrument ins = soundbank.getInstrument(patch);
        if (ins == null || !(ins instanceof ModelInstrument)) {
            throw new IllegalArgumentException("Unsupported instrument: " + ins);
        }
        instruments.add((ModelInstrument) ins);
    }
    return loadInstruments(instruments);
}
Also used : ArrayList(java.util.ArrayList) Instrument(javax.sound.midi.Instrument) Patch(javax.sound.midi.Patch)

Example 8 with Instrument

use of javax.sound.midi.Instrument in project jdk8u_jdk by JetBrains.

the class ModelAbstractOscillator method getInstrument.

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

Example 9 with Instrument

use of javax.sound.midi.Instrument in project jdk8u_jdk by JetBrains.

the class SF2Soundbank method getInstrument.

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

Aggregations

Instrument (javax.sound.midi.Instrument)9 Patch (javax.sound.midi.Patch)7 Soundbank (javax.sound.midi.Soundbank)3 ArrayList (java.util.ArrayList)1 SoundbankResource (javax.sound.midi.SoundbankResource)1