zero crossing rate calculator
Zero Crossing Rate Calculator guide
Zero crossing rate is a quick descriptor of how often a waveform alternates polarity. Paste signed time-domain samples in chronological order and give their sample rate. The calculator compares neighboring samples and reports the count, the fraction of adjacent pairs that cross and the equivalent rate over the observed interval.
Play the instrument ↑- Default result
- 4 sign changes
Calculation and units
Treat every negative value as one sign class and every zero or positive value as the other. Compare each adjacent pair once. There are N minus one intervals between N samples, so divide the count by that number for the normalized rate. Multiply by the sample rate for crossings per second. No wraparound comparison joins the last sample to the first.
Worked examples
Select a named case in the Worked example control to load these values. You can then edit any input to compare the result.
Alternating polarity
Time-domain samples = 1 -1 1 -1 1 · Sample rate (Hz) = 48000.
4 sign changes. 1 crossings per adjacent pair, equivalent to 48000 crossings/s across 4 intervals. Exact zeros count as nonnegative.
Every adjacent pair changes sign, giving the maximum count for these five samples. The rate in crossings per second scales with the sample rate.
Positive plateau
Time-domain samples = 1 1 2 2 · Sample rate (Hz) = 44100.
0 sign changes. 0 crossings per adjacent pair, equivalent to 0 crossings/s across 3 intervals. Exact zeros count as nonnegative.
Amplitude can change without crossing the sign boundary. A constant-positive run has no crossings even if its adjacent differences are substantial.
Zero between negative samples
Time-domain samples = -1 0 -1 · Sample rate (Hz) = 1000.
2 sign changes. 1 crossings per adjacent pair, equivalent to 1000 crossings/s across 2 intervals. Exact zeros count as nonnegative.
Zero belongs to the nonnegative side here. The excursion from negative through zero and back therefore counts twice under this convention.
Ramp through zero
Time-domain samples = -2 -1 0 1 2 · Sample rate (Hz) = 8000.
1 sign changes. 0.25 crossings per adjacent pair, equivalent to 2000 crossings/s across 4 intervals. Exact zeros count as nonnegative.
Count the transition from minus one to zero once. The following transition from zero to a positive value stays on the same side.
Lower sample rate
Time-domain samples = 1 -1 1 -1 1 · Sample rate (Hz) = 8000.
4 sign changes. 1 crossings per adjacent pair, equivalent to 8000 crossings/s across 4 intervals. Exact zeros count as nonnegative.
The count per adjacent pair stays fixed. Playing the same record at a slower sample rate stretches its duration and lowers crossings per second.
Short negative pair
Time-domain samples = -1 -2 · Sample rate (Hz) = 48000.
0 sign changes. 0 crossings per adjacent pair, equivalent to 0 crossings/s across 1 intervals. Exact zeros count as nonnegative.
Two samples provide exactly one observation interval. A very short record can yield a valid rate yet give little information about long-term behavior.
Interpreting the result
Look at the input values around a questionable crossing. A tiny sign fluctuation around zero counts exactly as a large swing does. Removing a consistent DC offset may change which samples lie on each side. If the desired measurement is immunity to small noise, define a threshold or hysteresis rule in the acquisition process and document it separately.
Measurement and model limits
The rate over a short block is an empirical count. It does not locate the exact crossing time between samples, and it does not distinguish a sustained pitch from broadband noise. For a sufficiently sampled clean sinusoid the count often approaches two crossings per cycle over a long interval, but that relationship has no universal validity for music.
Answers before you play
Common questions
How are consecutive zeros handled?
A run of zeros stays on the nonnegative side. Only an adjacent transition between that run and a negative value changes the count.
Should I enter absolute sample values?
Keep the sign from the original waveform. Taking absolute values discards the polarity information needed for this calculation.
Can I compare two sample rates?
The normalized fraction describes the sample grid. Use crossings per second when comparing duration, and consider bandwidth and resampling differences between the recordings.
Why are two samples required?
The measurement concerns a transition between neighbors. A single sample contains no time interval on which to observe or normalize a sign change.