Beispiel #1
0
 /** @deprecated */
 public HOscillator createCopy() {
   HOscillator copy = new HOscillator();
   copy.min1 = min1;
   copy.min2 = min2;
   copy.min3 = min3;
   copy.max1 = max1;
   copy.max2 = max2;
   copy.max3 = max3;
   copy.rel1 = rel1;
   copy.rel2 = rel2;
   copy.rel3 = rel3;
   copy.origw = origw;
   copy.origh = origh;
   copy.origd = origd;
   copy.step = step;
   copy.speed = speed;
   copy.freq = freq;
   copy.property = property;
   copy.waveform = waveform;
   return copy;
 }
Beispiel #2
0
  public float nextRaw() {
    float deg = (step * freq) % 360;
    float rawVal;
    switch (waveform) {
      case HConstants.SINE:
        rawVal = HMath.sineWave(deg);
        break;
      case HConstants.TRIANGLE:
        rawVal = HMath.triangleWave(deg);
        break;
      case HConstants.SAW:
        rawVal = HMath.sawWave(deg);
        break;
      case HConstants.SQUARE:
        rawVal = HMath.squareWave(deg);
        break;
      default:
        rawVal = 0;
        break;
    }

    map1 = HMath.map(rawVal, -1, 1, min1, max1);
    map2 = HMath.map(rawVal, -1, 1, min2, max2);
    map3 = HMath.map(rawVal, -1, 1, min3, max3);

    // deal with amplifier waves
    if (amplifiers.size() > 0) {
      for (int i = amplifiers.size() - 1; i >= 0; i--) {
        HOscillator amplifier = amplifiers.get(i);
        amplifier.synchStep(startStep, tick);
        amplifier.nextRaw();

        map1 += amplifier.map1();
        map2 += amplifier.map2();
        map3 += amplifier.map3();
      }
    }

    // deal with reducer waves
    if (reducers.size() > 0) {
      for (int i = reducers.size() - 1; i >= 0; i--) {
        HOscillator reducer = reducers.get(i);
        reducer.synchStep(startStep, tick);
        reducer.nextRaw();

        map1 -= reducer.map1();
        map2 -= reducer.map2();
        map3 -= reducer.map3();
      }
    }

    // handle clipping
    if (clip) {
      if (map1 > _clip_max) {
        map1 = _clip_max;
      }
      if (map2 > _clip_max) {
        map2 = _clip_max;
      }
      if (map3 > _clip_max) {
        map3 = _clip_max;
      }

      if (map1 < clip_min) {
        map1 = clip_min;
      }
      if (map2 < clip_min) {
        map2 = clip_min;
      }
      if (map3 < clip_min) {
        map3 = clip_min;
      }
    }

    map1 += offset;
    map2 += offset;
    map3 += offset;

    curr1 = map1 + rel1;
    curr2 = map2 + rel2;
    curr3 = map3 + rel3;

    step += speed;
    tick++;

    return rawVal;
  }