THE ZERO CROSSING count the sign changes — frequency from almost nothing
The cheapest frequency estimate there is: count how often the signal crosses zero. A sinusoid crosses zero twice per cycle, so the crossing rate is twice the frequency — no transform, no multiply, just watching the sign flip. It is how a guitar tuner gets a first pitch, how a cheap tachometer reads RPM, how a comparator turns a wave into a clock. It is crude (noise adds false crossings, and it only sees the dominant tone) but it is nearly free, and it turns a smooth analog wave into countable digital events.
THE TECHNIQUE crossings = 2·frequency·duration — sign flips counted
The demo counts the zero crossings of a cosine over two full periods — four crossings, i.e. two per cycle: live demo
HISTORY & CREDIT zero-crossing rate · pitch/RPM detection
“Finding frequency needs a Fourier transform.” — for one clean tone, counting sign flips gives it for almost no work. cited
the count · a sinusoid crosses zero twice per cycle — rate = 2f. the readout · crossings over a known window → frequency, with a comparator and a counter. the caveat · noise adds spurious crossings; it hears only the dominant tone — crude but nearly free.
A frequency read from the flips of a sign — the smooth wave made countable. resource
RECOMMEND FOR I-13 the crossings, on the compiler
On the canonical compiler, a cosine over two periods (32 samples) crosses zero exactly four times — two per cycle:
$ i13 run cr_zerocrossing.i13 # count sign changes
RUN OK · 2003 step(s) · peak stack 17 · call depth 33
crossings = 4 -- over 2 periods (2 per cycle)
four = 1 -- frequency = crossings / (2 * duration)
Recommend as a NULL — a cheap estimator, i.e. resource. Zero-crossing counting recovers the same fundamental frequency a transform would (for a clean tone), with almost no arithmetic — the resource axis (B40), trading accuracy and robustness for near-zero cost. NULL — the frugal end of frequency estimation, and the counterpoint to the DFT’s full spectrum.