I am trying to resample a signal (sound sample) from one sampling rate, to a higher sampling rate. Unfortunately it needs some kind of filter, as some 'aliasing' appears to occur, and I'm not familiar with filters. Here is what I came up with:
int i, j, a, b, z;
a = 44100;
b = 8363;
// upsample by a
for(i = z = 0; i < samplen; i++)
for(j = 0; j < a; j++)
cbuf[z++] = sampdata[i];
// some filter goes here???
// downsample by b
for(j = i = 0; i < z; i += b)
buf[j++] = cbuf[i];
The new sample is very similar to the original, but it has some kind of noise. Can you please tell me what filter I need to add, and preferably some code related to that filter?
Original sound: http://www.mediafire.com/?9gnga1in52d6t4x Resampled sound: http://www.mediafire.com/?x34h7ggk8n9k8z1
cbuf[z]
tosampdata[i]
, set it tosampdata[i] + (j/(double)a)(sampdata[i+1] - sampdata[i])
. I don't know enough about sound processing to know if that's even near sufficient, but it'll keep you busy until someone comes along who knows their stuff :-) You may also need to anti-alias the downsample. – Bilbrey