0x s f

Detects the number of samples between zero crossings and calculates the frequency in axoloti format.
Author: Sputnki
License: BSD
Github: sptnk/detect/0x s f.axo

Inlets

frac32buffer.bipolar in

Outlets

int32.positive number of samples between zero crossings

frac32.positive frequency in axoloti format

frac32buffer.positive trig

Declaration
float count = 0;
float output = 0;

bool sign_old = 0;
bool sign = 0;
int32_t in_prev = 0;
Control Rate
outlet_smp = output;
outlet_f = 134217728.0f / output;
Audio Rate
count += 1.0f;
sign = inlet_in > 0 ? 1 : 0;
outlet_trig = 0;

float intercept = ((float)inlet_in) / ((float)(in_prev - inlet_in));

if (sign != sign_old) {
  output = count + intercept;
  count = -intercept;
  outlet_trig = 1 << 27;
}

sign_old = sign;
in_prev = inlet_in;

Privacy

© 2024 Zrna Research