Ejemplo n.º 1
0
  private void processConnection(int ix) {
    ModelConnectionBlock conn = connections[ix];
    double[][] src = connections_src[ix];
    double[] dst = connections_dst[ix];
    if (dst == null || Double.isInfinite(dst[0])) return;

    double value = conn.getScale();
    if (softchannel.keybasedcontroller_active == null) {
      ModelSource[] srcs = conn.getSources();
      for (int i = 0; i < srcs.length; i++) {
        value *= transformValue(src[i][0], srcs[i]);
        if (value == 0) break;
      }
    } else {
      ModelSource[] srcs = conn.getSources();
      int[] src_kc = connections_src_kc[ix];
      for (int i = 0; i < srcs.length; i++) {
        value *= transformValue(processKeyBasedController(src[i][0], src_kc[i]), srcs[i]);
        if (value == 0) break;
      }
    }

    value = transformValue(value, conn.getDestination());
    dst[0] = dst[0] - connections_last[ix] + value;
    connections_last[ix] = value;
    // co_mixer_gain[0] = 0;
  }
Ejemplo n.º 2
0
  protected void noteOn(int noteNumber, int velocity) {

    sustain = false;
    sostenuto = false;
    portamento = false;

    soundoff = false;
    on = true;
    active = true;
    started = true;
    // volume = velocity;

    noteOn_noteNumber = noteNumber;
    noteOn_velocity = velocity;

    lastMuteValue = 0;
    lastSoloMuteValue = 0;

    setNote(noteNumber);

    if (performer.forcedKeynumber) co_noteon_keynumber[0] = 0;
    else co_noteon_keynumber[0] = tunedKey * (1f / 128f);
    if (performer.forcedVelocity) co_noteon_velocity[0] = 0;
    else co_noteon_velocity[0] = velocity * (1f / 128f);
    co_mixer_active[0] = 0;
    co_mixer_gain[0] = 0;
    co_mixer_pan[0] = 0;
    co_mixer_balance[0] = 0;
    co_mixer_reverb[0] = 0;
    co_mixer_chorus[0] = 0;
    co_osc_pitch[0] = 0;
    co_filter_freq[0] = 0;
    co_filter_q[0] = 0;
    co_filter_type[0] = 0;
    co_noteon_on[0] = 1;

    eg.reset();
    lfo.reset();
    filter_left.reset();
    filter_right.reset();

    objects.put("master", synthesizer.getMainMixer().co_master);
    objects.put("eg", eg);
    objects.put("lfo", lfo);
    objects.put("noteon", co_noteon);
    objects.put("osc", co_osc);
    objects.put("mixer", co_mixer);
    objects.put("filter", co_filter);

    connections = performer.connections;

    if (connections_last == null || connections_last.length < connections.length) {
      connections_last = new double[connections.length];
    }
    if (connections_src == null || connections_src.length < connections.length) {
      connections_src = new double[connections.length][][];
      connections_src_kc = new int[connections.length][];
    }
    if (connections_dst == null || connections_dst.length < connections.length) {
      connections_dst = new double[connections.length][];
    }
    for (int i = 0; i < connections.length; i++) {
      ModelConnectionBlock conn = connections[i];
      connections_last[i] = 0;
      if (conn.getSources() != null) {
        ModelSource[] srcs = conn.getSources();
        if (connections_src[i] == null || connections_src[i].length < srcs.length) {
          connections_src[i] = new double[srcs.length][];
          connections_src_kc[i] = new int[srcs.length];
        }
        double[][] src = connections_src[i];
        int[] src_kc = connections_src_kc[i];
        connections_src[i] = src;
        for (int j = 0; j < srcs.length; j++) {
          src_kc[j] = getValueKC(srcs[j].getIdentifier());
          src[j] = getValue(srcs[j].getIdentifier());
        }
      }

      if (conn.getDestination() != null)
        connections_dst[i] = getValue(conn.getDestination().getIdentifier());
      else connections_dst[i] = null;
    }

    for (int i = 0; i < connections.length; i++) processConnection(i);

    if (extendedConnectionBlocks != null) {
      for (ModelConnectionBlock connection : extendedConnectionBlocks) {
        double value = 0;

        if (softchannel.keybasedcontroller_active == null) {
          for (ModelSource src : connection.getSources()) {
            double x = getValue(src.getIdentifier())[0];
            ModelTransform t = src.getTransform();
            if (t == null) value += x;
            else value += t.transform(x);
          }
        } else {
          for (ModelSource src : connection.getSources()) {
            double x = getValue(src.getIdentifier())[0];
            x = processKeyBasedController(x, getValueKC(src.getIdentifier()));
            ModelTransform t = src.getTransform();
            if (t == null) value += x;
            else value += t.transform(x);
          }
        }

        ModelDestination dest = connection.getDestination();
        ModelTransform t = dest.getTransform();
        if (t != null) value = t.transform(value);
        getValue(dest.getIdentifier())[0] += value;
      }
    }

    eg.init(synthesizer);
    lfo.init(synthesizer);
  }