timerhold-0

while 'toggle' is true,timer is counting.. if 'toggle' is false,timer spits out the time. Zeros are filterd out.
Author: robert schirmer and philoop
License: who cares
Github: phi/timer/timerhold.axo

Inlets

bool32.risingfalling start counting,output the time interval

Outlets

int32 time interval in k-rate ticks (0.333ms)

Declaration
int32_t trigstart;
int32_t trigstop;
int tc;
int t;
int o;
int ntrig;
int latch;
Init
trigstart = 0;
trigstop = 0;
tc = 0;
t = 0;
o = 0;
Control Rate
if ((inlet_toggle) && !trigstart) {
  tc = 0;
  trigstart = 1;
} else if (!(inlet_toggle)) {
  trigstart = 0;
  t = tc;
}

if (trigstart) {
  tc == tc++;
  t = 0;
}

o = (t == 0) ? 0 : 1;
if ((o > 0) && !ntrig) {
  latch = t;
  ntrig = 1;
}
if (!(o > 0))
  ntrig = 0;
outlet_t = latch;

Privacy

© 2024 Zrna Research