# Thread: Interpolation in C - Help

1. ## Interpolation in C - Help

Hi Members,

I have received C source code function. The function carries out interpolation of a speech siganl. But what is the name of this type of interpolation??? There are a number of different types of interpolation and I need to know the actual type of interpolation it performs:

Code:
```float interpolate (float    freq,double   filter_curve_db [][2],int      number_of_points) {
double  result;
int     i;
double  freqLow, freqHigh;
double  curveLow, curveHigh;

if (freq <= filter_curve_db [0][0]) {
freqLow = filter_curve_db [0][0];
curveLow = filter_curve_db [0][1];
freqHigh = filter_curve_db [1][0];
curveHigh = filter_curve_db [1][1];

result = ((freq - freqLow) * curveHigh + (freqHigh - freq) * curveLow)/ (freqHigh - freqLow);

return (float) result;
}

if (freq >= filter_curve_db [number_of_points-1][0]) {
freqLow = filter_curve_db [number_of_points-2][0];
curveLow = filter_curve_db [number_of_points-2][1];
freqHigh = filter_curve_db [number_of_points-1][0];
curveHigh = filter_curve_db [number_of_points-1][1];

result = ((freq - freqLow) * curveHigh + (freqHigh - freq) * curveLow)/ (freqHigh - freqLow);

return (float) result;
}

i = 1;
freqHigh = filter_curve_db [i][0];
while (freqHigh < freq) {
i++;
freqHigh = filter_curve_db [i][0];
}
curveHigh = filter_curve_db [i][1];

freqLow = filter_curve_db [i-1][0];
curveLow = filter_curve_db [i-1][1];

result = ((freq - freqLow) * curveHigh + (freqHigh - freq) * curveLow)/ (freqHigh - freqLow);

return (float) result;
}```
Many Thanks if you can help.

2. Why don't you ask whoever you "received" the source code from?

Quzah.

3. ## ??

I cannot ask the person I received as this is code taken from an ITU P.862 standard. It is open source to researchers.

There are no comments within the code . What Im trying to do is convert the C to MATLAB for future use and implementations of the algorithms. I want to do my project through MATLAB but it based on the source code I received.

I think it is Linear Interpolation.

4. It looks like an extended form of linear interpolation.

Linear is simply this:

Value=v1+interp*(v2-v1);

Bilinear is this:

Value1=v1+interp1*(v2-v1);
Value2=v3+interp1*(v4-v3);
FinalValue=Value1+interp2*(Value4-Value3);