Qu

find_zero_crossings

Builtin index · Signal processing

result = find_zero_crossings(x, [edge="both"])

Input: x, edge · Output: result

What it is

x: a length-N real vector or Signal; edge (optional string) as above. find_trigger at level zero. The default is both directions, unlike find_trigger's own default: the zero-crossing rate is a count of every sign change, so len(find_zero_crossings(x)) has to be that count to be worth anything, and a "rising" default would silently halve it.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = find_zero_crossings(x, [edge="both"])
x vector or Signalx: a length-N real vector or Signal.
edge string, optional (default "both")edge (optional string) as above.
result vector
Returns a vector of 0-indexed integer sample indices.

Examples

No documentation example calls this form yet. The Signal processing chapter is where one belongs.

How it works

find_zero_crossings(x, [edge="both"]) -- find_trigger at level zero. The default is BOTH directions, which is the conventional reading of "zero crossing" and not merely the permissive choice: the zero-crossing RATE (this document's own §6 zcr, and the standard speech/audio feature) counts every sign change, so len(find_zero_crossings(x)) has to be that count to be worth anything. Defaulting to "rising" -- which would have matched find_trigger's own default -- would halve it silently, and a halved rate is exactly the believable-looking wrong number that is hard to catch. edge= still restricts it when a single direction is what was wanted.

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.