sdr.Interpolator.__call__(x: ArrayLike, mode: 'rate' | 'full' = 'rate') NDArray

Interpolates and filters the input signal \(x[n]\) with the polyphase FIR filter.

Parameters:
x: ArrayLike

The input signal \(x[n]\) with sample rate \(f_s\) and length \(L\).

mode: 'rate' | 'full' = 'rate'

The non-streaming convolution mode.

  • "rate": The output signal \(y[n]\) has length \(L r\) proportional to the interpolation rate \(r\). Output sample 0 aligns with input sample 0.

  • "full": The full convolution is performed. The output signal \(y[n]\) has length \((L + N) r\), where \(N\) is the order of the multirate filter. Output sample delay aligns with input sample 0.

In streaming mode, the "full" convolution is performed. However, for each \(L\) input samples only \(L r\) output samples are produced per call. A final call to flush() is required to flush the filter state.

Returns:

The filtered signal \(y[n]\) with sample rate \(f_s r\). The output length is dictated by the mode argument.

Examples

Create an input signal to interpolate.

In [1]: x = np.cos(np.pi / 4 * np.arange(20))

Interpolate the signal using the "same" mode.

In [2]: fir = sdr.Interpolator(4); fir
Out[2]: sdr.Interpolator(4, 'kaiser', streaming=False)

In [3]: y = fir(x)

In [4]: plt.figure(figsize=(8, 4)); \
   ...: sdr.plot.time_domain(x, marker="o", label="$x[n]$"); \
   ...: sdr.plot.time_domain(y, sample_rate=fir.rate, marker=".", label="$y[n]$");
   ...: 
../../_images/sdr_Interpolator_call_1.png

Interpolate the signal using the "full" mode.

In [5]: y = fir(x, mode="full")

In [6]: plt.figure(figsize=(8, 4)); \
   ...: sdr.plot.time_domain(x, marker="o", label="$x[n]$"); \
   ...: sdr.plot.time_domain(y, sample_rate=fir.rate, offset=-fir.delay/fir.rate, marker=".", label="$y[n]$");
   ...: 
../../_images/sdr_Interpolator_call_2.png

Interpolate the signal iteratively using the streaming mode.

In [7]: fir = sdr.Interpolator(4, streaming=True); fir
Out[7]: sdr.Interpolator(4, 'kaiser', streaming=True)

In [8]: y1 = fir(x[:10]); \
   ...: y2 = fir(x[10:]); \
   ...: y3 = fir(np.zeros(fir.polyphase_taps.shape[1])); \
   ...: y = np.concatenate((y1, y2, y3))
   ...: 

In [9]: plt.figure(figsize=(8, 4)); \
   ...: sdr.plot.time_domain(x, marker="o", label="$x[n]$"); \
   ...: sdr.plot.time_domain(y, sample_rate=fir.rate, offset=-fir.delay/fir.rate, marker=".", label="$y[n]$");
   ...: 
../../_images/sdr_Interpolator_call_3.png