class sdr.FractionalDelay(sdr.FIR)

Implements a fractional delay FIR filter.

Examples

Design \(\Delta n = 0.21719\) delay filters with various lengths. Examine the width and flatness of the frequency response passband.

In [1]: plt.figure();

In [2]: for length in [4, 8, 16, 32, 64, 128]:
   ...:     fir = sdr.FractionalDelay(length, 0.21719)
   ...:     sdr.plot.magnitude_response(fir, label=f"$L = {length}$")
   ...: 

In [3]: plt.legend(loc="lower left");
../../_images/sdr_FractionalDelay_1.svg

Design filters with length \(L = 8\) and various fractional delays. Examine the effects on the magnitude response outside the passband as a function of the fractional delay. Note the symmetry about \(\Delta n = 0.5\) and that the out-of-band magnitude response is worst at \(\Delta n = 0.5\).

In [4]: plt.figure();

In [5]: for delay in np.arange(0.1, 1, 0.1):
   ...:     fir = sdr.FractionalDelay(8, delay)
   ...:     sdr.plot.magnitude_response(fir, label=f"$\Delta n = {delay:0.1f}$")
   ...: 

In [6]: plt.ylim(-10, 1); \
   ...: plt.legend(loc="lower left");
   ...: 
../../_images/sdr_FractionalDelay_2.svg

Examine the effects on the group delay outside the passband as a function of the fractional delay. Note the symmetry about \(\Delta n = 0.5\). The out-of-band group delay is worst around \(\Delta n \approx 0.5\), however the group delay is perfectly flat at exactly \(\Delta n = 0.5\).

In [7]: plt.figure();

In [8]: for delay in np.arange(0.1, 1, 0.1):
   ...:     fir = sdr.FractionalDelay(8, delay)
   ...:     sdr.plot.group_delay(fir, label=f"$\Delta n = {delay:0.1f}$")
   ...: 

In [9]: plt.legend(loc="lower left");
../../_images/sdr_FractionalDelay_3.svg

Constructors

FractionalDelay(length: int, delay: float)

Creates a fractional delay FIR filter.

Special methods

__call__(x: ArrayLike, ...) → NDArray

Filters the input signal \(x[n]\) with the FIR filter.

__len__() → int

Returns the filter length \(N + 1\).

Streaming mode only

reset()

Resets the filter state. Only useful when using streaming mode.

flush() → NDArray

Flushes the filter state by passing zeros through the filter. Only useful when using streaming mode.

property streaming : bool

Indicates whether the filter is in streaming mode.

property state : NDArray

The filter state consisting of the previous \(N\) inputs.

Methods

impulse_response(n: int | None = None) → NDArray

Returns the impulse response \(h[n]\) of the FIR filter.

step_response(n: int | None = None) → NDArray

Returns the step response \(s[n]\) of the FIR filter.

frequency_response(...) → tuple[NDArray[float64], NDArray[complex128]]
frequency_response(freqs: float, ...) → complex
frequency_response(freqs, ...) → NDArray[complex128]

Returns the frequency response \(H(\omega)\) of the FIR filter.

group_delay(...) → tuple[TypeAliasForwardRef('~numpy.typing.NDArray'), TypeAliasForwardRef('~numpy.typing.NDArray')]

Returns the group delay \(\tau_g(\omega)\) of the FIR filter.

phase_delay(...) → tuple[TypeAliasForwardRef('~numpy.typing.NDArray'), TypeAliasForwardRef('~numpy.typing.NDArray')]

Returns the phase delay \(\tau_{\phi}(\omega)\) of the FIR filter.

noise_bandwidth(sample_rate: float = 1.0) → float

Returns the noise bandwidth \(B_n\) of the FIR filter.

Properties

property taps : NDArray

The feedforward taps \(h[n]\) with length \(N + 1\).

property order : int

The order of the FIR filter \(N\).

property delay : int

The delay of the FIR filter \(d = \lfloor \frac{N + 1}{2} \rfloor\) in samples.