hook xtor

xtorable. Inlet value passed through after hitting control value. Write the name of an xtor manager to add preset capabilities to this control.
Author: Oscar Abraham
License: BSD
Github: oscar/ctrl/hook xtor.axo

Inlets

frac32.positive input

bool32.rising unhook param

Outlets

bool32 hooked

frac32.positive output

Parameters

frac32.u.map value

Attributes

objref x

Declaration
int32_t nhooked; // 0:hooked, 1:gt, 2:lt, 4:unhooked
int32_t param_cache;
int32_t tunhook;

bool registered = false;
Init
nhooked = 4;
tunhook = 0;
Control Rate
if (!registered) {
  attr_x.registerParam(PARAM_INDEX_attr_legal_name_value,
                       "attr_legal_name_value");
  registered = true;
}

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