Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resampling Audio in MATLAB

I have a wav file that has been imported into MATLAB and is sample at 44.1 kHz. I am trying to resample this audio file to 22.05 kHz and then restore it back to 44.1 kHz. However, I am confused on how to use the resample function in MATLAB and if that is even the function I should be using to do this. Any help would be greatly appreciated. Thank you!

like image 237
Math244 Avatar asked Jan 12 '23 20:01

Math244


1 Answers

Yes, resample is your function. To downsample x from 44100 Hz to 22050 Hz:

y = resample(x,1,2);

(the "1" and "2" arguments define the resampling ratio: 22050/44100 = 1/2)

To upsample back to 44100 Hz:

x2 = resample(y,2,1);

Note that the resample function includes the necessary anti-aliasing (lowpass) filter.

As you probably know, the "recovered" signal x2 has lost the highest-frequency information that may have been present in x.

like image 81
Luis Mendo Avatar answered Jan 22 '23 20:01

Luis Mendo