- class sdr.FarrowResampler
Implements a piecewise polynomial Farrow arbitrary resampler.
References
Michael Rice, Digital Communications: A Discrete Time Approach, Section 8.4.2.
Qasim Chaudhari, Fractional Delay Filters Using the Farrow Structure.
Examples
Create a sine wave with angular frequency \(\omega = 2 \pi / 5.179\). Interpolate the signal by \(r = \pi\) using Farrow piecewise polynomial Farrow resamplers.
In [1]: x = np.cos(2 * np.pi / 5.179 * np.arange(11)) In [2]: rate = np.pi
Create a linear Farrow piecewise polynomial interpolator.
In [3]: farrow1 = sdr.FarrowResampler(1) In [4]: y1 = farrow1(x, rate) In [5]: plt.figure(); \ ...: sdr.plot.time_domain(x, sample_rate=1, marker="o", label="Input"); \ ...: sdr.plot.time_domain(y1, sample_rate=rate, marker=".", label="Output"); \ ...: plt.title("Linear Farrow Resampler"); ...:
Create a quadratic Farrow piecewise polynomial interpolator.
In [6]: farrow2 = sdr.FarrowResampler(2) In [7]: y2 = farrow2(x, rate) In [8]: plt.figure(); \ ...: sdr.plot.time_domain(x, sample_rate=1, marker="o", label="Input"); \ ...: sdr.plot.time_domain(y2, sample_rate=rate, marker=".", label="Output"); \ ...: plt.title("Quadratic Farrow Resampler"); ...:
Create a cubic Farrow piecewise polynomial interpolator.
In [9]: farrow3 = sdr.FarrowResampler(3) In [10]: y3 = farrow3(x, rate) In [11]: plt.figure(); \ ....: sdr.plot.time_domain(x, sample_rate=1, marker="o", label="Input"); \ ....: sdr.plot.time_domain(y3, sample_rate=rate, marker=".", label="Output"); \ ....: plt.title("Cubic Farrow Resampler"); ....:
Create a quartic Farrow piecewise polynomial interpolator.
In [12]: farrow4 = sdr.FarrowResampler(4) In [13]: y4 = farrow4(x, rate) In [14]: plt.figure(); \ ....: sdr.plot.time_domain(x, sample_rate=1, marker="o", label="Input"); \ ....: sdr.plot.time_domain(y4, sample_rate=rate, marker=".", label="Output"); \ ....: plt.title("Quartic Farrow Resampler"); ....:
Compare the outputs of the Farrow resamplers with varying polynomial order.
In [15]: plt.figure(); \ ....: sdr.plot.time_domain(x, sample_rate=1, marker="o", label="Input"); \ ....: sdr.plot.time_domain(y1, sample_rate=rate, marker=".", label="Linear"); \ ....: sdr.plot.time_domain(y2, sample_rate=rate, marker=".", label="Quadratic"); \ ....: sdr.plot.time_domain(y3, sample_rate=rate, marker=".", label="Cubic"); \ ....: sdr.plot.time_domain(y4, sample_rate=rate, marker=".", label="Quartic"); \ ....: plt.xlim(1.5, 3.5); \ ....: plt.ylim(-1.0, -0.2); \ ....: plt.title("Comparison of Farrow Resamplers"); ....:
Run a Farrow resampler with quartic polynomial order in streaming mode.
In [16]: x = np.cos(2 * np.pi / 5.179 * np.arange(40)) In [17]: farrow4 = sdr.FarrowResampler(4, streaming=True) In [18]: y1 = farrow4(x[0:10], rate); \ ....: y2 = farrow4(x[10:20], rate); \ ....: y3 = farrow4(x[20:30], rate); \ ....: y4 = farrow4(x[30:40], rate); \ ....: y5 = farrow4.flush(rate); \ ....: y = np.concatenate((y1, y2, y3, y4, y5)) ....: In [19]: plt.figure(); \ ....: sdr.plot.time_domain(x, sample_rate=1, marker="o", label="Input"); \ ....: sdr.plot.time_domain(y, sample_rate=rate, offset=-farrow4.delay, marker=".", label="Quartic concatenated"); \ ....: plt.title("Quartic Farrow Resampler Concatenated Outputs"); ....:
See the Farrow arbitrary resampler example.
Constructors¶
-
FarrowResampler(order: int =
3
, streaming: bool =False
) Creates a new Farrow arbitrary resampler.
Special methods¶
- __call__(x: ArrayLike, rate: float) NDArray
Resamples the input signal \(x[n]\) by the given arbitrary rate \(r\).
Streaming mode only¶
- flush(rate: float) NDArray
Flushes the filter state by passing zeros through the filter. Only useful when using streaming mode.
- property state : NDArray
The filter state consisting of the previous \(N\) inputs.
Properties¶
- property taps : NDArray
The Farrow filter taps.