Package javax.sound.midi

Examples of javax.sound.midi.Patch


* @author Karl Helgason
*/
public class ModelInstrumentComparator implements Comparator<Instrument> {

    public int compare(Instrument arg0, Instrument arg1) {
        Patch p0 = arg0.getPatch();
        Patch p1 = arg1.getPatch();
        int a = p0.getBank() * 128 + p0.getProgram();
        int b = p1.getBank() * 128 + p1.getProgram();
        if (p0 instanceof ModelPatch) {
            a += ((ModelPatch)p0).isPercussion() ? 2097152 : 0;
        }
        if (p1 instanceof ModelPatch) {
            b += ((ModelPatch)p1).isPercussion() ? 2097152 : 0;
View Full Code Here


        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)
View Full Code Here

    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();
View Full Code Here

    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.loadInstruments(sbk, new Patch[] {ins2.getPatch()});
      assertTrue(synth.getLoadedInstruments().length == 1);
    }
    synth.close();
View Full Code Here

    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();
View Full Code Here

    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);
View Full Code Here

    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);
View Full Code Here

    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())
View Full Code Here

        return null;
    }

    // Get General MIDI 2 Alias patch for this instrument.
    public Patch getPatchAlias() {
        Patch patch = getPatch();
        int program = patch.getProgram();
        int bank = patch.getBank();
        if (bank != 0)
            return patch;
        boolean percussion = false;
        if (getPatch() instanceof ModelPatch)
            percussion = ((ModelPatch)getPatch()).isPercussion();
        if (percussion)
            return new Patch(0x78 << 7, program);
        else
            return new Patch(0x79 << 7, program);
    }
View Full Code Here

              MidiSystem.getSynthesizer();
      synth.open();
      Instrument[] instruments =
              synth.getAvailableInstruments();
      for(Instrument i:instruments) {
        Patch p=i.getPatch();
        int bank=p.getBank();
        if (bank>maxBank) {
          maxBank=bank;
        }
        if (bank<minBank) {
          minBank=bank;
View Full Code Here

TOP

Related Classes of javax.sound.midi.Patch

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.