示例#1
0
  public void messageReceived(ParameterSelectMessage message) {
    int slotId = message.getSlot();
    if (!isValidSlot(slotId)) return;

    int vaId = message.getSection();
    int moduleId = message.getModule();
    int paramId = message.getParameter();

    // addParameter("pid", "data:pid");
    // addParameter("sc", "data:sc");

    NmSlot slot = synth.getSlot(slotId);
    NMPatch patch = slot.getPatch();

    String parameterClass = "parameter";
    VoiceArea va = null;
    if (vaId == Format.VALUE_SECTION_VOICE_AREA_POLY) va = patch.getPolyVoiceArea();
    else if (vaId == Format.VALUE_SECTION_VOICE_AREA_COMMON) va = patch.getCommonVoiceArea();
    else if (vaId == Format.VALUE_SECTION_MORPH) {
      parameterClass = "morph";
      va = patch.getPolyVoiceArea();
    }

    if (va == null) return;

    PModule module = va.getModule(moduleId);

    PParameter p;
    try {
      p = Helper.getParameter(module, parameterClass, paramId);
    } catch (InvalidDescriptorException e) {
      return;
    }
    p.requestFocus();
  }
示例#2
0
  public void messageReceived(MorphRangeChangeMessage message) {
    int slotId = message.getSlot();

    if (!isValidSlot(slotId)) return;

    int vaId = message.getSection();
    int moduleId = message.getModule();
    int paramId = message.getParameter();
    int span = message.getSpan();
    int direction = message.getDirection(); // +==0/-==1

    NmSlot slot = synth.getSlot(slotId);
    NMPatch patch = slot.getPatch();

    VoiceArea va = null;
    if (vaId == Format.VALUE_SECTION_VOICE_AREA_POLY) va = patch.getPolyVoiceArea();
    else if (vaId == Format.VALUE_SECTION_VOICE_AREA_COMMON) va = patch.getCommonVoiceArea();

    if (va == null) return;

    PModule module = va.getModule(moduleId);

    PParameter p;
    try {
      p = Helper.getParameter(module, "morph", paramId);
    } catch (InvalidDescriptorException e) {
      return;
    }
    p.setValue(direction == 1 ? -span : +span);
  }
示例#3
0
  public void messageReceived(NewPatchInSlotMessage message) {
    // user changed the patch in one of the slots
    // trigger-source: synth

    int slotId = message.getSlot();

    if (!isValidSlot(slotId)) return;

    int patchId = message.getPid();

    NmSlot slot = synth.getSlot(slotId);

    NMPatch patch = slot.getPatch();
    if (patch != null) patch.setSlot(null);
    slot.setPatch(null);
    // slot.setPatchId(patchId);

    // getPatch(slotId, patchId);

    try {
      slot.requestPatch();
    } catch (SynthException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
示例#4
0
  /**
   * This message is ignored. The GetPatchWorker causes this kind of messages and handles them
   * itself.
   */
  public void messageReceived(PatchMessage message) {
    // get patch name
    String patchName = message.getPatchNameIfPresent();
    if (patchName != null) {
      // patch name is part of message
      synth.getSlot(message.getSlot()).setPatchNameValue(patchName);
    }

    if (message.containsSection(Format.S_HEADER)) {
      int slotId = message.getSlot();

      NmSlot slot = synth.getSlot(slotId);
      NMPatch patch = slot.getPatch();
      if (patch == null) return;

      PatchBuilder builder =
          new PatchBuilder(patch, new ParserErrorHandler(), synth.getModuleDescriptions());

      BitstreamPatchParser bpp = new BitstreamPatchParser();
      bpp.setRecognizedSections(Format.S_HEADER);
      try {
        bpp.transcode(message.getPatchStream(), builder);
      } catch (ParseException e) {
        e.printStackTrace();
      }
    }
  }
示例#5
0
 public void messageReceived(SlotsSelectedMessage message) {
   for (int i = 0; i < synth.getSlotCount(); i++) {
     NmSlot slot = synth.getSlot(i);
     boolean enabled = message.isSlotSelected(i);
     slot.setEnabledValue(enabled);
     slot.updatePatchName();
   }
 }
示例#6
0
  public void messageReceived(MeterMessage message) {
    int slotId = message.getSlot();

    if (!isValidSlot(slotId)) return;
    NmSlot slot = synth.getSlot(slotId);
    NMPatch patch = slot.getPatch();
    if (patch == null) return;
    patch.getLightProcessor().processMeterMessage(message);
  }
示例#7
0
  public void newPatchInSlot(SlotEvent e) {
    NmSlot slot = (NmSlot) e.getSlot();
    NMPatch oldPatch = (NMPatch) e.getOldPatch();
    NMPatch newPatch = (NMPatch) e.getNewPatch();

    uninstallSynchronizer(slot.getSlotId());

    if (newPatch != null) {
      installSynchronizer(slot, newPatch);
    }
  }
示例#8
0
  /** TODO document for messageReceived(AckMessage) */
  public void messageReceived(AckMessage message) {
    int slotId = message.getSlot();

    // check if slot is available <=> synth is connected
    // -> this is not implied by the received message
    if (!isValidSlot(slotId)) return;

    // request patch name
    NmSlot slot = synth.getSlot(slotId);
    slot.updatePatchName();
  }
示例#9
0
  public void messageReceived(SetPatchTitleMessage message) {
    int slotId = message.getSlot();
    // int pid = message.get("pid");

    // check if slot is available <=> synth is connected
    // -> this is not implied by the received message
    if (!isValidSlot(slotId)) return;

    NmSlot slot = synth.getSlot(slotId);
    NMPatch patch = slot.getPatch();
    String title = message.getTitle();
    if (patch != null) patch.setName(title);
    slot.setPatchNameValue(title);
  }
示例#10
0
  public void messageReceived(KnobAssignmentMessage message) {
    int slotId = message.getSlot();

    if (!isValidSlot(slotId)) return;

    int prevKnob = message.get("prevknob");
    int vaId = message.get("section");
    int moduleId = message.get("module");
    int paramId = message.get("parameter");
    int knob = message.get("knob");

    NmSlot slot = synth.getSlot(slotId);
    NMPatch patch = slot.getPatch();

    if (prevKnob >= 0) {
      Knob k = patch.getKnobs().getByID(prevKnob);
      if (k != null) k.setParameter(null);
    }

    if (knob >= 0) {
      VoiceArea va = null;
      if (vaId == Format.VALUE_SECTION_VOICE_AREA_POLY) va = patch.getPolyVoiceArea();
      else if (vaId == Format.VALUE_SECTION_VOICE_AREA_COMMON) va = patch.getCommonVoiceArea();

      if (va == null) return;

      PModule module = va.getModule(moduleId);

      PParameter p;
      try {
        p = Helper.getParameter(module, "parameter", paramId);
      } catch (InvalidDescriptorException e) {
        return;
      }

      Knob k = patch.getKnobs().getByID(knob);
      if (k != null) k.setParameter(p);
    }
  }
示例#11
0
 private void installSynchronizer(NmSlot slot, NMPatch patch) {
   NmPatchSynchronizer sync = new NmPatchSynchronizer(slot.getSynthesizer(), patch, slot);
   synchronizerList[slot.getSlotIndex()] = sync;
   sync.install();
 }
示例#12
0
 private void uninstallSlot(NmSlot slot) {
   slot.removeSlotListener(this);
   slot.removePropertyChangeListener(this);
 }
示例#13
0
 private void installSlot(NmSlot slot) {
   slot.addSlotListener(this);
   slot.addPropertyChangeListener(Slot.ENABLED_PROPERTY, this);
 }