What you're doing does not look like useful code. What is "f" supposed to do?
In audio, linear interpolation means that you are converting a buffer of one length into a buffer of another length (or alternatively, one speed/samplerate to another). It should look more like:
Code:
for (i = 0; i < len_out; ++i)
{
// convert output position to input position
float pos_in = float(i) * float(len_in) / float(len_out);
// calculate blend value for linear interpolation
float alpha = pos_in - floorf(pos_in);
// find the two samples to interpolate
int p0 = int(pos_in);
int p1 = p0 + 1;
dest[i] = lerp(src[p0], src[p1], alpha);
}
This isn't really optimal code, and it probably isn't even what you want to be doing, but I'm just trying to give an idea of what linear interpolation for resampling is. This technique is really only for upsampling, not downsampling.
If downsampling, you want something like a box filter. Basically take all the samples for a window of time in the input buffer, and average them together to make your output sample that represents that block of time (the samples at the beginning and end of the window will have reduced weight, since the window will probably begin and end partway through the sample).