ADtimecrv

Attack/decay envelope, with envelope-output crossfading between attack/decay values.
Author: Remco van der Most
License: BSD
Github: sss/env/ADtimecrv.axo

Inlets

bool32.rising trigger

Outlets

frac32.positive envelope output

Parameters

frac32.s.map.klineartime.exp a1

frac32.s.map.klineartime.exp a2

frac32.s.map.kdecaytime.exp d1

frac32.s.map.kdecaytime.exp d2

Declaration
int8_t stage;
int ntrig;
int32_t val;
int32_t val2;
int32_t attack;
int32_t decay;
Init
ntrig = 0;
val = 0;
Control Rate
if ((inlet_trig > 0) && !ntrig) {
  ntrig = 1;
  stage = 1;
} else if (!(inlet_trig > 0)) {
  ntrig = 0;
}
if (stage == 0) {
  val = ___SMMUL(val, param_d1 + decay + (1 << 17)) << 1;
} else {
  int32_t t;
  MTOF(-attack, t);
  val = val + (t >> 3);
  if (val < 0) {
    val = 0x7FFFFFFF;
    stage = 0;
  }
}
outlet_env = val >> 4;
Audio Rate
val2 = (1 << 27) - (val >> 4);
attack = ___SMMUL(val2 << 3, param_a1 << 2) + ___SMMUL(val >> 1, param_a2 << 2);
decay = ___SMMUL(val2 << 3, (param_d2 - param_d1) << 2);

Privacy

© 2024 Zrna Research