# Resample audio signal with a low factors

Currently, we need to handle a piece of an audio signal. We want to resample it with multiple factor rates (p/q) starting with $$1.0002$$ down to $$0.9998$$ with a decrement of $$0.000005$$. But Matlab functions cannot handle this because of the Integer Limit.

Are there any ways to solve this?

• big deal. MATLAB y = resample(x,p,q); works fine. so for whatever ratio $r=\tfrac{p}{q}$ that you want set $$p=\left\lfloor \tfrac{r}{0.000005} \right\rfloor =\left\lfloor 200000 \cdot r \right\rfloor$$ and $$q=\left\lfloor \tfrac{1}{0.000005} \right\rfloor = 200000$$ and you have your integers for p and q. Jul 9, 2018 at 8:40
• The general field of study you're looking for is "sample rate conversion". "Secret Rabbit Code" used to be a nice open-source implementation, but it's been so long since I've had to reference it that I have no clue if it's still a thing. Jan 3, 2020 at 0:07
• Robert there are limits to the factors allowed by resample. resample(1,70000,70001) Error using upfirdn>validateinput (line 129) The product of the downsample factor Q and the upsample factor P must be less than 2^31. Aug 30, 2020 at 6:12

If you're resampling can be done batch, interp1 using ‘spline’ as the type works well.

A good article that argues in favor of splines over sinc interpolation is:

Unser, Michael. "Splines: A perfect fit for signal and image processing." IEEE Signal processing magazine 16.6 (1999): 22-38 (PDF).

Please see my answer to this question : Various size arrays interpolation - resampling

The best method really depends on your application and your requirements. Matlab's resample() is perfectly fine, if you don't care about efficiency, have enough memory, no real time requirement, and reasonably short signals. If's unsuitable for real time sample rate adaption of two different master clocks.

Both sinc kenrnel and splines are different ways to create an interpolation filter, but it's not easy to adapt them to numerical requirements. If you have a requirement like "aliasing, THD and intermod need to be lower than -80dB below 20 kHz" it's better to directly design a low pass filter in a suitably upsampled domain. You an certainly do this by using a sinc kernel but you'll need a lot more filter taps than using a custom low pass filter

You can resample to any, including floating point approximations of irrational rates, using reconstruction by Sinc kernel interpolation (realistically, by using a windowed Sinc interpolator).