ADcrv

Attack/decay envelope, curved envelopes. anti-clockwise: exponential clockwise: inverse exponential Mode: changes the response of the curveD parameter-> instead of setting the decay-curve directly, it uses curveA as base-value and curveD gives an inversed curve-offset to the attack and decay gated sets the attack-response to gated instead of triggered. In trigger-response it only goes to the decay-stage when it reaches it's maximum. Also, when if a new trigger comes in, it won't be reset.
Author: Remco van der Most
License: BSD
Github: sss/env/ADcrv.axo

Inlets

bool32.rising trigger

Outlets

frac32.positive envelope output

Parameters

frac32.s.map.klineartime.exp a

frac32.s.map.klineartime.exp d

frac32.s.map curveA

frac32.s.map curveD

bool32.tgl mode

bool32.tgl gated

Declaration
int8_t stage;
int ntrig;
int32_t val;
Init
ntrig = 0;
val = 0;
Control Rate
int32_t crv1;
int32_t crv2;
if (param_mode == 0) {
  crv1 = param_curveA;
  crv2 = param_curveD;
} else {
  crv1 = param_curveA + param_curveD;
  crv2 = param_curveA - param_curveD;
}
if ((inlet_trig > 0) && !ntrig) {

  ntrig = 1;
  stage = 1;
} else if (!(inlet_trig > 0)) {
  ntrig = 0;
  if (param_gated > 0) {
    stage = 0;
  }
}
int32_t t;
if (stage == 0) {
  MTOF(-(param_d << 1) + ___SMMUL(val - (1 << 30), -crv2 << 2), t);
  val = __USAT(val - (t >> 3), 31);
} else {

  MTOF(-(param_a << 1) + ___SMMUL(val - (1 << 30), -crv1 << 2), t);
  val = val + (t >> 3);
  if (val < 0) {
    val = 0x7FFFFFFF;
    stage = 0;
  }
}
outlet_env = val >> 4;

Privacy

© 2024 Zrna Research