scahd

really slow ahd module that can cycle and has a holdtime in cyclemode, the divd control speeds up the decay, so that you can get really slow attacks with moderatly fast decays.
Author: Simon Iten
License: GPL
Github: lokki/env/scahd.axo

Inlets

bool32 gate

Outlets

frac32.positive out

Parameters

int32.hradio divd

bool32.tgl cycle

frac32.u.map a

frac32.u.map d

frac32.u.map h

Declaration
int val;
bool has_peaked;
int holdcount;
Init
val = 0;
has_peaked = 0;
holdcount = 0;
Control Rate
if (inlet_gate) {
  if (val < 1 << 27 && !has_peaked) {
    val = val + (1 + (((1 << 27) - param_a) >> 14));
    if (val >= 1 << 27) {
      val = (1 << 27) - 1;
      if (param_cycle)
        has_peaked = true;
    }
  }

  if (val > 0 && has_peaked && param_cycle) {
    if (holdcount < (param_h >> 11))
      holdcount++;
    else {
      val = val = val - (1 + (((1 << 27) - param_d) >> (14 - param_divd)));
      if (val < 0)
        val = 0;
      if (!val) {
        has_peaked = false;
        holdcount = 0;
      }
    }
  }
}
if (!inlet_gate && val > 0) {
  val = val - (1 + (((1 << 27) - param_d) >> (14 - param_divd)));
  if (val < 0)
    val = 0;
  has_peaked = false;
}

outlet_out = val;

Privacy

© 2024 Zrna Research