Sampling Rate conversion with arbitrary and variable ratios

Started by javiergal 1 year ago14 replieslatest reply 1 year ago772 views

Hi Folks, 

I would like to ask you about a non-very common topic... Arbitrary Ratio Sampling Rate conversion... With this, I want to refer to resampling of signals with a ratio ( output sampling rate divided by input sampling rate ) that can take any value. This is, ratios that can be integer or rational without any limitation… let’s say that any real number as for instance R = 1.1234568 could be needed…

Are you aware about any application where such resampling is used?

And in line with this… to broaden a bit more the topic… are you aware of applications or use cases that require a ratio that is modified in real time? Let’s say that the ratio changes in real time to track for instance a second signal related to the properties of the resampled signal… do you know any application where this is need is present? For this second case you would need a resampler as the one in the first question... 

I’m aware that these two cases are a bit awkward… but are you aware of such applications? Maybe MRI (Magnetic Resonance Imaging)?

Thanks a lot!

[ - ]
Reply by G4ELIMarch 15, 2023

I use arbitrary ratios in my SDR software, part of the decimation chain. This is not modified in real time, only when a radio is started or the sample rate (bandwidth) changed.

FWIW this is on Windows using a my own fractional resampler and highly optimised DotProduct routines for AVX / AVX2.

[ - ]
Reply by timbly5000March 15, 2023


I've not done this for a while but what I would try is a Lagrange polynomial interpolator. You will need a fractional accumulator updating at the input sample rate and when this generates a carry (or a 'roll-over') its time to compute an output sample - this gives you fine control of the output rate (akin to a DDS).

The output sample will be obtained by interpolating the last 4 input samples using the following expression:

/* Interpolate a point between y1 and y2 specified by x in the range 0 to 1 */

/* Tim Howe July 2004 */

double Lagrange4Point(double y0, double y1, double y2, double y3, double x)


    return y1 +

        (y2 - y1/2 - y0/3 - y3/6)*x +

        (-y1 + y0/2 + y2/2)*x*x +

        (y3/6 + y1/2 - y2/2 - y0/6)*x*x*x;


This will work better the more 'oversampled' the input samples are - i.e. the closer you go to the Nyquist limit the more distortion/error you will see. You could precede this operation with a fixed-rate up-sampler if necessary.


Tim (Plextek Ltd)

[ - ]
Reply by DansanMarch 15, 2023

I use unusual conversion ratios, and I think sub sample per second rates work, in the resampler in iZotope RX, but again, the ratio is static, not dynamic.

There are a lot of dynamic sub sample delay and vari-speed playback devices which re-align audio and vary playback speeds to keep things synchronized, or for musical purposes. Consider audio samplers, etc. Celemony Capstan. Variable speed playback and warping of audio in DAWs like Reaper, Ableton Live, etc. Without looking at the DSP code inside, it's hard to say if they're just using tricks and approximations, or are adjusting SRC filter kernels in real time to achieve what you're suggesting.

There's also drift correction in the Apple Mac OS Aggregate Audio Device driver. I'm not sure if it's fractionally adjusting an SRC to achieve that, or just dropping and adding samples. You might want to look into it.  I'll be surprised if there isn't a broadcast device for combining signals from different clock domains which doesn't do what you're suggesting.

So I guess my answer is no, but probably.

[ - ]
Reply by chalilMarch 15, 2023

one of the usecase which i came across multiple times is ASRC (Asynchronous Sampling rate conversion) in audio path. ie, when clocks of the producer and consumer are not based on the same crystal, the clocks will often drift which may cause buffer overflow / underflow. here in this cases, the samples are (re)sampled using ASRC to ensure adequate data for rendering. 

other cases could be in broadcast receivers, when time stamps are based on different clock references you would want to resample to avoid sample/frame drops/duplicates. 

in both of the above cases, the ratio is modified in real time based on either time buffer water marks or time-stamps. 

hope it helps. 


[ - ]
Reply by neiroberMarch 15, 2023


This problem comes up in timing recovery for digital receivers.  As already mentioned, you can use Lagrange polynomial interpolation, also referred to as piecewise polynomial interpolation.  This is discussed in Section 8.4 of Michael Rice's book, Digital Communications:  A Discrete-Time Approach, Pearson, 2009.

[ - ]
Reply by napiermMarch 15, 2023

Hey Neil!

Or the solution we used often which is a PLL driving a Farrow interpolator.

These two papers give a good overview of subject:

Floyd M. Gardner, "Interpolation in Digital Modems - Part I: Fundamentals", IEEE Transactions on Communications, Vol. 41, No. 3, March 1993

Lars Erup, Floyd M. Gardner, Robert A. Harris, "Interpolation in Digital Modems - Part II: Implementation and Performance", IEEE Transactions on Communications, Vol. 41, No. 6, June 1993


C. W. Farrow, "A Continuously Variable Digital Delay Element.", ISCAS'88, pp. 2641-2645, 1988

So basically you have a phase accumulator.  For the simplest case say the incremental phase is a constant so the NCO is running at a fixed frequency.  Each time the accumulator rolls over this generates an enable to pull another value from the interpolator.  The value of the accumulator at rollover is the "mu" or fraction over [0,1) to guide the interpolator.

Any arbitrary interpolation or decimation can be done this way with the following caveat:  The frequency response of the interpolator must be greater than the signal of interest *and* any other unwanted signals at the input.  The complexity of the interpolator depends on the application.

The cleanest interpolator I've seen over [0, Fs/4) is the polyphase derivative method shown in Fred Harris' book and in the accompanying Matlab files.

Hope some of this helps,

Mark Napier

[ - ]
Reply by neiroberMarch 15, 2023

Hi Mark,

We are talking about the same thing.  The Farrow interpolator is a hardware implementation of a piecewise polynomial interpolator.



[ - ]
Reply by AnaPamaMarch 15, 2023

Sampling rate conversion with arbitrary numbers is used to help data fit within the restrictions of a data bus (like JESD lane rates vs data converter sampling rates) but that isn't variable during use of the devices.  It's part of configuring the link.  

Realtime changes are not often possible.  One can always reconfigure the link to update that ratio but you would lose data unless a FIFO was available to store samples during the configuration change.  I suppose if you had stuffed sample repeats to increase the lane rate you could substitute real data for the repeats and that would be a different ratio, but that's not a lot of flexibility (R = 1.12 to 2.24 vs R = 1.12 to 1.15).

[ - ]
Reply by dudelsoundMarch 15, 2023

This is used all the time where audio and radio come together - e.g.:

- Bluetooth: The output DAC of a Bluetooth audio sink is often clocked by a local fixed clock, but the bluetooth audio comes in in jittery blocks at a slightly different but unknown rate.

- Wireless microphone with digital audio network output (DANTE, MILAN, AVB, ...). The audio signal in the receiver is clocked in sync with the transmitters clock, but the audio network has its own clock - they might both be 48kHz on paper, but they always vary by a few PPM.

In both cases, the ratio of sampling frequencies needs to be tracked and the SRC adjusted in real time

[ - ]
Reply by DougBMarch 15, 2023

Arbitrary rate resampling is required anytime you do symbol timing recovery in a receiver.  You can use a polyphase filter for this application and get resampling and matched filtering all-in-one.  You can use a digital PLL to control the sample rate to keep it locked to the symbol timing and so the resampling rate is constantly changing.

[ - ]
Reply by SlartibartfastMarch 15, 2023

This is the example I was going to give as well. The symbol clock rate may change due to oscillator drift in the modulator or Doppler, or there've even been implementations in the past where the symbol clock was adjusted in real-time based on rate demand and it is then just tracked and adjusted in the receiver, without changing the initial sampling rate.

And, yes, a good polyphase filter can do resample interpolation and pulse shaping at the same time.   I always wondered why more people didn't do it that way (as opposed to a Farrow interpolator or similar).

[ - ]
Reply by philipoakleyMarch 15, 2023

You give a 7 digit real value (1.xx...xx) but don't give any further criteria or requirements that would allow a trade off of techniques as to, say, how long the data sequence will be, how far individual output samples could be from the expected value, the expected maths for the interpolated(?) values, etc. 

A simple sample and hold will be quite sufficient for some cases (a nice baseline) but terrible for other/your case(s). If sample and hold isn't sufficient, maybe a linear extrapolation (zero delay) or liner interpolation (one+ sample delay).

It's always the small things that catch you out.

I have seen 'variable interpolation' used in SAR imaging, but it is horses for courses.

[ - ]
Reply by mblokMarch 15, 2023


Generally, variable rate resampling depends on the ability of resampling ratio tracking.
The application might be in digital demodulation, especially in mobile communications when Doppler can change the symbol rate. Another application might be audio signal restoration from recordings with varying playback speeds.

As others have mentioned, the solutions vary depending on the required quality which is related to oversampling of the signal we're going to resample. For high oversampling hold or a simple interpolation formula will offer satisfactory solutions. 
For more demanding applications the variable fractional delay filters implemented using the Farrow structure would be a better solution. Nevertheless, depending on the VFD filter design method the overall frequency response of such an interpolator might be problematic if the oversampling is low.

Some insight into problems of variable ratio sample rate conversion using VFD filters can be found here:

Blok, M. & Drózda, P. (2014). Variable ratio sample rate conversion based on fractional delay filter. Archives of Acoustics39(2), 231-242.

MArek Blok

[ - ]
Reply by engineer68March 15, 2023

Post deleted by author