zcross#

class diffsptk.ZeroCrossingAnalysis(frame_length, norm=False, softness=0.001)[source]#

See this page for details.

Parameters:
frame_lengthint >= 1

Frame length, \(L\).

normbool

If True, divide zero-crossing rate by frame length.

softnessfloat > 0

A smoothing parameter. The smaller value makes the output closer to the true zero-crossing rate, but the gradient vanishes.

forward(x)[source]#

Compute zero-crossing rate.

Parameters:
xTensor [shape=(…, T)]

Waveform.

Returns:
outTensor [shape=(…, T/L)]

Zero-crossing rate.

Examples

>>> x = diffsptk.nrand(5)
>>> x
tensor([-0.2388,  0.3587, -0.6606, -0.6929,  0.5239,  0.4501])
>>> zcross = diffsptk.ZeroCrossingAnalysis(3)
>>> z = zcross(x)
>>> z
tensor([2., 1.])
diffsptk.functional.zcross(x, frame_length, norm=False, softness=0.001)[source]#

Compute zero-crossing rate.

Parameters:
xTensor [shape=(…, T)]

Waveform.

frame_lengthint >= 1

Frame length, \(L\).

normbool

If True, divide zero-crossing rate by frame length.

softnessfloat > 0

A smoothing parameter. The smaller value makes the output closer to the true zero-crossing rate, but the gradient vanishes.

Returns:
outTensor [shape=(…, T/L)]

Zero-crossing rate.