df2#
- class diffsptk.SecondOrderDigitalFilter(sample_rate: int, pole_frequency: float | None = None, pole_bandwidth: float | None = None, zero_frequency: float | None = None, zero_bandwidth: float | None = None, ir_length: int | None = None, device: device | None = None, dtype: dtype | None = None)[source]#
See this page for details.
- Parameters:
- sample_rateint >= 1
The sample rate in Hz.
- pole_frequencyfloat > 0 or None
The pole frequency in Hz.
- pole_bandwidthfloat > 0 or None
The pole bandwidth in Hz.
- zero_frequencyfloat > 0 or None
The zero frequency in Hz.
- zero_bandwidthfloat > 0 or None
The zero bandwidth in Hz.
- ir_lengthint >= 1 or None
The length of the truncated impulse response. If given, the filter is approximated by an FIR filter.
- 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 a second order digital filter to the input waveform.
- Parameters:
- xTensor [shape=(…, T)]
The input waveform.
- Returns:
- outTensor [shape=(…, T)]
The filtered waveform.
Examples
>>> import diffsptk >>> df2 = diffsptk.SecondOrderDigitalFilter(16000, 1000, 200) >>> x = diffsptk.impulse(4) >>> y = df2(x) >>> y tensor([1.0000, 1.7766, 2.2319, 2.3227, 2.0633])
See also