decRep

decay envelope, linear ramp, modulation input
Author: Johannes Taelman
License: BSD
Github: sss/env/decRep.axo

Inlets

bool32.rising trigger

frac32.bipolar decay time

Outlets

frac32.positive envelope output

Parameters

int32 repeat

frac32.s.map.klineartime.exp d

Declaration
int32_t val1;
int32_t val2;
int ntrig;
Init
val1 = 0;
val2 = 0;
ntrig = 0;
Control Rate
if ((inlet_trig > 0) && !ntrig) {
  val1 = 1 << 27;
  val2 = 1 << 27;
  ntrig = 1;
} else {
  if (!(inlet_trig > 0))
    ntrig = 0;
  int32_t t;
  int32_t dt = param_d + inlet_d;
  MTOF(-dt, t);
  val1 -= t >> 8;
  int32_t in = -inlet_d - param_d;
  int32_t c;
  MTOFEXTENDED(in, c);
  c = 0x7FFFFFFF - (c >> 2);
  val2 = ___SMMUL(val2, c) << 1;
  if (val1 < 0)
    val1 = 0;
}
outlet_env = (((val1 * param_repeat & ((1 << 27) - 1)) +
               (val2 * param_repeat & ((1 << 27) - 1))) &
              ((1 << 28) - 1)) >>
             1;

Privacy

© 2024 Zrna Research