Thread: Interpolation in C - Help

  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    5

    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. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Why don't you ask whoever you "received" the source code from?


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Oct 2005
    Posts
    5

    ??

    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. #4
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    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);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Lagrange interpolation
    By swal87 in forum C Programming
    Replies: 1
    Last Post: 02-23-2008, 12:04 PM
  2. bilinear interpolation
    By cboard_member in forum Game Programming
    Replies: 5
    Last Post: 03-28-2007, 10:51 PM
  3. Replies: 0
    Last Post: 06-14-2006, 03:45 AM
  4. Super fast bilinear interpolation
    By VirtualAce in forum Game Programming
    Replies: 2
    Last Post: 06-18-2002, 09:35 PM
  5. Cubic interpolation
    By VirtualAce in forum Game Programming
    Replies: 4
    Last Post: 11-02-2001, 05:35 PM