cycle ad

cycling a/d env with modulation
Author: Mark Harris
License: GPL
Github: tb/env/cycle ad.axo

Inlets

bool32.rising trigger

frac32.bipolar attack time modulation

frac32.bipolar decay time modulation

Outlets

bool32.pulse end of cycle

frac32.positive envelope output

Parameters

frac32.s.map.klineartime.exp a

frac32.s.map.kdecaytime.exp d

Declaration
int8_t stage;
int nreset;
int32_t val;
Init
nreset = 0;
val = 0;
stage = 1;
Control Rate
if ((inlet_reset > 0) && !nreset) {
  nreset = 1;
  stage = 1;
  val = 0;
} else if (!(inlet_reset > 0)) {
  nreset = 0;
}
outlet_end = 0;
if (stage == 0) {
  val = ___SMMUL(val, param_d) << 1;
  if (val <= 0) {
    stage = 1;
    val = 0;
    outlet_end = 1;
  }
} else {
  int32_t t;
  MTOF(-param_a, t);
  val = val + (t >> 3);
  if (val < 0) {
    val = 0x7FFFFFFF;
    stage = 0;
  }
}
outlet_env = val >> 4;

Privacy

© 2024 Zrna Research