frac32buffer.bipolar in
int32 number of samples at s-rate sample rate
frac32buffer.positive trig
uint32_t count = 0;
uint32_t output = 0;
bool sign_old = 0;
bool sign = 0;
outlet_smp = output;
count++;
sign = inlet_in > 0 ? 1 : 0;
outlet_trig = 0;
if (sign != sign_old) {
output = count;
count = 0;
outlet_trig = 1 << 27;
}
sign_old = sign;