Sunday, November 17, 2019

audio - How Can I Resample a Signal with an Arbitrary Factor (For Example - 128000Hz to 16000.1Hz) in MATLAB?


I need to simulate the sampling of a continuous (fsCtu = 128000Hz), acoustic signal with two microphones that have a slight offset in sampling rate (fsMic1 = 16000, fsMic2 = 16000.1) in Matlab. What is the best way to do this?


Things I tried:




  • The Matlab "resample" command only works for resampling to 16000, not to 16000.1

  • "interp1" doesn't seem to be an option because I think I need to use bandlimited interpolation for a correct simulation. (Is this assumption correct?)

  • I tried to write my signal to a wav file and resample it via a system call using this software, then load the processed file with wavread. I'm not sure if this is a good solution. A quick test revealed that this method doesn't give the same result as the "resample" command for resampling to 16000Hz, which I find strange.


Any ideas or suggestions?



Answer



There are a couple of ways that you can do it. The first is with resample, but it is a multi-step process. First, you have to figure out which interpolation and decimation factors will get you the sample rate you want.


[n, k] = rat(16000.1 / 128000);

That gets you an interpolation factor of 20000 and a decimation factor of 159999. You factor those to break them up into smaller chunks.



nFactors = factor(n)
kFactors = factor(k)

It turns out that n factors to $2^5 * 5^4$ and k factors to $3 * 7 * 19 * 401$. All of those are doable, though the decimation by 401 will not have great filtering properties. Anyway, if you resample in stages you can get the final sample rate you want.


The other way to do it is polynomial interpolation. Essentially you model your signal as a polynomial through curve fitting techniques, and then you can simply feed in the time values that you want and out will pop the signal values. This technique can be very effective, but modelling the signal well is a bit of an art. In particular you don't want to overfit.


No comments:

Post a Comment

digital communications - Understanding the Matched Filter

I have a question about matched filtering. Does the matched filter maximise the SNR at the moment of decision only? As far as I understand, ...