public static void main(String[] args) throws Exception {
   ModelSource src =
       new ModelSource(
           ModelSource.SOURCE_NOTEON_KEYNUMBER,
           ModelStandardTransform.DIRECTION_MAX2MIN,
           ModelStandardTransform.POLARITY_BIPOLAR,
           ModelStandardTransform.TRANSFORM_CONCAVE);
   if (src.getIdentifier() != ModelSource.SOURCE_NOTEON_KEYNUMBER)
     throw new RuntimeException(
         "src.getIdentifier() doesn't return ModelSource.SOURCE_NOTEON_KEYNUMBER!");
   if (!(src.getTransform() instanceof ModelStandardTransform))
     throw new RuntimeException(
         "src.getTransform() doesn't return object which is instance of ModelStandardTransform!");
   ModelStandardTransform trans = (ModelStandardTransform) src.getTransform();
   if (trans.getDirection() != ModelStandardTransform.DIRECTION_MAX2MIN)
     throw new RuntimeException(
         "trans.getDirection() doesn't return ModelStandardTransform.DIRECTION_MAX2MIN!");
   if (trans.getPolarity() != ModelStandardTransform.POLARITY_BIPOLAR)
     throw new RuntimeException(
         "trans.getPolarity() doesn't return ModelStandardTransform.POLARITY_BIPOLAR!");
   if (trans.getTransform() != ModelStandardTransform.TRANSFORM_CONCAVE)
     throw new RuntimeException(
         "trans.getTransform() doesn't return ModelStandardTransform.TRANSFORM_CONCAVE!");
 }
예제 #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);
  }
예제 #3
0
 private double transformValue(double value, ModelSource src) {
   if (src.getTransform() != null) return src.getTransform().transform(value);
   else return value;
 }