@Override
 public void decrementInstrument() {
   if (selected_instrument > low) --selected_instrument;
   for (CustomPatchElement cpatch : patches.get(selected_instrument).getPatch()) {
     patch = instrument[cpatch.getInstrument()].getPatch();
     cpatch.getChannel().programChange(patch.getBank(), patch.getProgram());
   }
 }
Beispiel #2
0
 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;
 }
  public CustomControls(MidiChannel[] channels, Instrument[] instrument, Patch patch) {
    this.channels = channels;
    this.instrument = instrument;
    this.patch = patch;
    this.patches = new HashMap<Integer, CustomPatch>();

    HashSet<CustomPatchElement> tmp = new HashSet<CustomPatchElement>();
    tmp.add(new CustomPatchElement(channels[0], 1, 127));
    tmp.add(new CustomPatchElement(channels[1], 20, 102));
    tmp.add(new CustomPatchElement(channels[2], 70, 75));

    patches.put(0, new CustomPatch("mine", tmp));

    for (CustomPatchElement c : patches.get(0).getPatch()) {
      patch = instrument[c.getInstrument()].getPatch();
      c.getChannel().programChange(patch.getBank(), patch.getProgram());
    }

    this.selected_instrument = 0;
  }