zerodf#

class diffsptk.AllZeroDigitalFilter(filter_order: int, frame_period: int, ignore_gain: bool = False, zeroth_index: int = 0, mode: str = 'direct', device: device | None = None, dtype: dtype | None = None)[source]#

See this page for details.

Parameters:
filter_orderint >= 0

The order of the filter, \(M\).

frame_periodint >= 1

The frame period in samples, \(P\).

ignore_gainbool

If True, perform filtering without the gain.

zeroth_indexint >= 0

The index of the zeroth coefficient in the filter coefficients. If 0, the filter is assumed to be minimum-phase. If M, the filter is assumed to be maximum-phase.

mode[‘direct’, ‘efficient’]

The implementation mode for time-varying convolution. ‘direct’ applies convolution at the sample level, linearly interpolating the filter coefficients to match the length of the input signal. This approach is simple to understand but requires substantial memory. ‘efficient’ instead performs two separate convolutions - one with the original filter coefficients and one with the shifted coefficients - and interpolates between their outputs. This avoids the need to interpolate the filter coefficients themselves, resulting in lower memory usage. Both modes are mathematically equivalent, though ‘efficient’ may produce slight numerical differences owing to the different order of operations.

devicetorch.device or None

The device of this module.

dtypetorch.dtype or None

The data type of this module.

forward(x: Tensor, b: Tensor) Tensor[source]#

Apply an all-zero digital filter.

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

The excitation signal.

bTensor [shape=(…, T/P, M+1)]

The filter coefficients.

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

The output signal.

Examples

>>> import diffsptk
>>> zerodf = diffsptk.AllZeroDigitalFilter(0, 1)
>>> x = diffsptk.step(4)
>>> b = diffsptk.ramp(4)
>>> y = zerodf(x, b.view(-1, 1))
>>> y
tensor([0., 1., 2., 3., 4.])
diffsptk.functional.zerodf(x: Tensor, b: Tensor, frame_period: int = 80, ignore_gain: bool = False, zeroth_index: int = 0, mode: str = 'direct') Tensor[source]#

Apply an all-zero digital filter.

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

The excitation signal.

bTensor [shape=(…, T/P, M+1)]

The filter coefficients.

frame_periodint >= 1

The frame period in samples, \(P\).

ignore_gainbool

If True, perform filtering without the gain.

zeroth_indexint >= 0

The index of the zeroth coefficient in the filter coefficients.

mode[‘direct’, ‘efficient’]

The implementation mode for time-varying convolution.

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

The output signal.

See also

linear_intpl c2mpir