hook

inlet value passed through after hitting control value
Author: Johannes Taelman
License: BSD
Github: ctrl/hook.axo

Inlets

bool32.rising unhook param

frac32.positive input

Outlets

frac32.positive output

bool32 hooked

Parameters

frac32.u.map value

Declaration
int32_t nhooked; // 0:hooked, 1:gt, 2:lt, 4:unhooked
int32_t param_cache;
int32_t tunhook;
Init
nhooked = 4;
tunhook = 0;
Control Rate
if (inlet_unhook && !tunhook) {
  tunhook = 1;
  nhooked = 4;
} else if (!inlet_unhook) {
  tunhook = 0;
}

if (nhooked) {
  outlet_out = param_value;
  if (param_value > inlet_in) {
    nhooked |= 1;
    if (nhooked == 7) {
      nhooked = 0;
      param_cache = param_value;
    }
  } else if (param_value < inlet_in) {
    nhooked |= 2;
    if (nhooked == 7) {
      nhooked = 0;
      param_cache = param_value;
    }
  } else {
    nhooked = 0;
    param_cache = param_value;
  }
} else {
  outlet_out = inlet_in;
  if (param_cache != param_value)
    nhooked = 4;
  else
    PExParameterChange(&parent->PExch[PARAM_INDEX_attr_legal_name_value],
                       inlet_in, 0xFFFD);
  param_cache = inlet_in;
}
outlet_hooked = !nhooked;

Privacy

© 2024 Zrna Research