zcr: Zero-crossing rate

View source: R/seewave.r

zcrR Documentation

Zero-crossing rate

Description

This functions computes the zero-crossing rate of a time function, i. e. the average number the sign of a time wave changes.

Usage

zcr(wave, f, channel = 1, wl = 512, ovlp = 0, plot = TRUE, type = "o", xlab =
"Time (s)", ylab = "Zero crossing rate", ...)

Arguments

wave

an R object.

f

sampling frequency of wave (in Hz). Does not need to be specified if embedded in wave.

channel

channel of the R object, by default left channel (1).

wl

length of the window for the analysis (even number of points, by default = 512). If NULL the zero-crossing rate is computed of the complete signal.

ovlp

overlap between two successive analysis windows (in %) if wl is not NULL.

plot

a logical, if TRUE plots a the zero-crossing rate results along time.

type

if plot is TRUE, type of plot that should be drawn. See plot for details (by default "l" for lines).

xlab

if plot is TRUE, label of the x axis.

ylab

if plot is TRUE, label of the y axis.

...

other plot graphical parameters.

Details

The zero-crossing rate is computed according to:

zcr = \frac{1}{2 \times N} \sum_{t=0}^{N-1} |sgn[x(t+1)] -sgn[x(t)]|

with:
N the length of the signal x
and where:

sgn[x(t)] = 1

if

x(t) \geq 0

and

sgn[x(t)] = -1

if

x(t) < 0

Value

The are two possibilities:

  1. a numeric vector of length 1 if wl is NULL,

  2. a numeric two-column matrix is returned with the first columnn being time (s) and the second colum being the zero-crossing rate (no scale) if wl is not NULL.

Note

The are two possibilities:

  1. if wl is NULL then the zero-crossing rate is computed for the complete signal.

  2. if wl is not NULL the the zero-crossing rate is computed for for a window sliding along the time wave.

The ZCR is supposed to help in detection of voiced/unvoiced sound sections.

Author(s)

Jerome Sueur

References

https://en.wikipedia.org/wiki/Zero-crossing_rate

See Also

zc

Examples

data(tico)
## a single value for the complete signal, no plot
zcr(tico, wl=NULL)
## a series of values computed for a sliding window of 512 samples, plot
zcr(tico)

seewave documentation built on Oct. 19, 2023, 5:07 p.m.

Related to zcr in seewave...