dfs#

diffsptk.IIR#

alias of InfiniteImpulseResponseDigitalFilter

class diffsptk.InfiniteImpulseResponseDigitalFilter(b: list[T] | tuple[T, ...] | ndarray | None = None, a: list[T] | tuple[T, ...] | ndarray | None = None, ir_length: int | None = None, learnable: bool = False, device: device | None = None, dtype: dtype | None = None)[source]#

See this page for details.

Parameters:
bList [shape=(M+1,)] or None

The numerator coefficients.

aList [shape=(N+1,)] or None

The denominator coefficients.

ir_lengthint >= 1 or None

The length of the truncated impulse response. If given, the filter is approximated by an FIR filter.

learnablebool

If True, the filter coefficients are learnable.

devicetorch.device or None

The device of this module.

dtypetorch.dtype or None

The data type of this module.

forward(x: Tensor) Tensor[source]#

Apply an IIR digital filter to the input waveform.

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

The input waveform.

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

The filtered waveform.

Examples

>>> x = diffsptk.ramp(4)
>>> dfs = diffsptk.IIR(b=[1, -0.97])
>>> y = dfs(x)
>>> y
tensor([0.0000, 1.0000, 1.0300, 1.0600, 1.0900])
diffsptk.functional.dfs(x: Tensor, b: Tensor | None = None, a: Tensor | None = None, ir_length: int | None = None) Tensor[source]#

Apply an IIR digital filter to the input waveform.

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

The input waveform.

bTensor [shape=(M+1,)] or None

The numerator coefficients.

aTensor [shape=(N+1,)] or None

The denominator coefficients.

ir_lengthint >= 1 or None

The length of the truncated impulse response. If given, the filter is approximated by an FIR filter.

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

The filtered waveform.

See also

df2