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)[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.
- 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
>>> x = diffsptk.ramp(4) >>> df2 = diffsptk.SecondOrderDigitalFilter(16000, 100, 200, 1000, 50, 5) >>> y = df2(x) >>> y tensor([0.0000, 1.0000, 2.0918, 3.4161, 5.1021])
See also