polyslave ahd

works only inside a polyphonic sub-patch. routes note and velocity to a specific voice, and gives feedback to the 'mother-object' about the current playback state of that voice. inlet 'envstate' provides 'polyhandler slave' with information about the state of a release-envelope if there is one. otherwise ,'polyhandler slave' will work without
Author: robert schirmer
License: BSD
Github: rbrt/poly/polyslave ahd.axo

Inlets

bool32.rising stop

frac32.positive attack

frac32.positive release

Outlets

bool32 gate

bool32 state

bool32.pulse retrig

frac32.positive env

int32.positive note

int32.positive velo

Attributes

objref polymaster

combo retrigger

spinner ascale

spinner rscale

spinner dclick

Declaration
int32_t val;
uint8_t pren;
uint8_t prev;
uint8_t velon;
uint8_t index;
uint8_t note;
uint8_t velo;
bool gate;
bool stop;
bool trigon;
bool trigoff;
Init
index = parent->polyIndex;
pren = 0;
prev = 0;
val = 0;
Control Rate
outlet_retrig = 0;
trigon = 0;
trigoff = 0;

note = attr_polymaster.Snote[index] - 1;
velo = attr_polymaster.Svelo[index];
if ((note != pren) || (velo != prev) || (stop && velo)) {
  if (note != pren)
    val = 0;
  stop = 0;
  pren = note;
  prev = velo;
  if (prev) {
    trigon = 1;
    velon = prev;
    if (val)
      outlet_retrig = 1;
  } else
    trigoff = 1;
}

if (outlet_retrig && attr_retrigger)
  val = 0;
if (trigon && !gate)
  gate = 1;
if (trigoff && gate)
  gate = 0;
if (inlet_stop && !stop) {
  gate = 0;
  stop = 1;
  attr_polymaster.Svelo[index] = 0;
  attr_polymaster.Rhold[index] = 0;
}

if (gate > 0) {
  int32_t t;
  MTOF(-inlet_attack, t);
  val += (inlet_attack) ? t >> attr_ascale : 1 << (27 - attr_dclick);
} else {
  int32_t t;
  MTOF(-inlet_release, t);
  val -= t >> attr_rscale;
}
val = __USAT(val, 27);

if (val)
  attr_polymaster.Rrelease[index] = pren + 1;
else
  attr_polymaster.Rrelease[index] = 0;

outlet_gate = gate;
outlet_note = pren;
outlet_velo = velon;
outlet_env = val;
outlet_state = bool(val);

Privacy

© 2024 Zrna Research