ad2

Attack/decay envelope, linear attack, exponential decay with modulation inputs and build in vca. "On" button turn envelope on. When "off" input is passed through with no gate.
Author: Jaffasplaffa
License: BSD
Github: jaffa/env/ad2.axo

Inlets

frac32buffer i

bool32.rising trigger

frac32.bipolar attack time modulation

frac32.bipolar decay time modulation

Outlets

frac32buffer o

Parameters

frac32.s.map a

frac32.s.map d

bool32.tgl on

Displays

bool32 on

Declaration
int32_t prev;
int32_t step;

int8_t stage;
int ntrig;
int32_t val;
int32_t Loopval;
Init
ntrig = 0;
val = 0;
Control Rate
disp_on = 0;

// display gate
if (param_on) {
  disp_on = inlet_t;
}
// vca
step = (Loopval - prev) >> 4;
int32_t i = prev;
prev = Loopval;

// env
if ((inlet_t > 0) && !ntrig) {
  ntrig = 1;
  stage = 1;
} else if (!(inlet_t > 0)) {
  ntrig = 0;
}
if (stage == 0) {
  val = ___SMMUL(val, param_d) << 1;
} else {
  int32_t t;
  MTOF(-param_a, t);
  val = val + (t >> 3);
  if (val < 0) {
    val = 0x7FFFFFFF;
    stage = 0;
  }
}
Loopval = val >> 4;
Audio Rate
// Env off
outlet_o = inlet_i;

// Env on
if (param_on) {

  outlet_o = ___SMMUL(inlet_i, i) << 5;
  i += step;
}

Privacy

© 2024 Zrna Research