2

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?

lennon310
  • 3,590
  • 19
  • 24
  • 27
ggattacker
  • 21
  • 1
  • 1
    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. – robert bristow-johnson Jul 09 '18 at 08: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. – TimWescott Jan 03 '20 at 00: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. – Knut Inge Aug 30 '20 at 06:12

3 Answers3

1

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).

lennon310
  • 3,590
  • 19
  • 24
  • 27
0

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).

hotpaw2
  • 35,346
  • 9
  • 47
  • 90
0

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

MBaz
  • 15,314
  • 9
  • 30
  • 44
Hilmar
  • 44,604
  • 1
  • 32
  • 63