AHDSRa

very smooth audio-rate AHDSR envelope based on a 6dB LP filter that responds to velocity-triggers (multiply gate with velocity using float-multiplier)
Author: Remco van der Most
License: BSD
Github: sss/env/AHDSRa.axo

Inlets

frac32 input

Outlets

frac32buffer out

Parameters

frac32.s.map.kpitch a

frac32.s.map.kpitch d

frac32.u.map h

frac32.u.map.gain s

frac32.s.map r

Declaration
int32_t val;
int32_t v30 = 1 << 30;
int32_t v29 = 1 << 28;
int32_t hold;
bool trg;
int32_t vel;
Init
val = 0;
Control Rate
int32_t H;
MTOFEXTENDED(-param_h - param_a, H)
Audio Rate
hold = __USAT(hold - (H >> 7), 31);
vel -= vel >> 14;
if ((inlet_trg > 0) && !trg) {
  trg = 1;
  hold = v30;
  vel = __USAT((inlet_trg >> 1) + vel, 27);
  // vel=inlet_trg;
} else if (inlet_trg == 0) {
  trg = 0;
}
int32_t a;
MTOF(-param_a, a);
a = a >> 7;
int32_t d;
MTOF(-param_d, d);
d = d >> 7;
int32_t r;
MTOF(-param_r, r);
r = r >> 7;
int32_t tmp =
    (hold > 0 ? vel
              : ___SMMUL(vel << 2, ___SMMUL(inlet_trg << 3, param_s) << 2));
val = ___SMMLA((tmp - val) << 1, tmp > val ? a : inlet_trg > 0 ? d : r, val);
outlet_out = val;

Privacy

© 2024 Zrna Research