resample_lagrange_ex_interp.c

Example of using Farrow filter for digital signal interpolation.The pickup signal \( s(n), \) \( n = 0 \ldots 7, \) contains 8 samples as it is shown in the figure below.

This program recalculates the pickup signal \( s(n) \) into the signal \( y(k), \) \( k = 0 \ldots 70, \) which is interpolated concerning \( s(n) \) into \( P = 10 \) times.

The pickup signal is saved in dat/resample_lagrange_interp_s.txt.
The interpolated signal at the output of Farrow filter is saved in dat/resample_lagrange_interp_y.txt.

The pickup and interpolated signals saved in dat/resample_lagrange_interp_s.txt and dat/resample_lagrange_interp_y.txt are shown in the following figure.

resample_lagrange_ex_interp.png
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include "dspl.h"
#define P 10
#define Q 1
#define N 8
int main()
{
HINSTANCE hDSPL; /* dspl handle */
double s[N] = {1.0, 2.0, 2.0, 1.0, -0.5, -1.0, -2.0, -0.5};
double *y = NULL;
double *t = NULL;
int n;
/* Load dspl.dll */
hDSPL = dspl_load();
if(!hDSPL)
{
printf("dspl.dll loading ERROR!\n");
return 0;
}
dspl_resample_lagrange(s, N, P, Q, 0, &y, &n);
t = (double*)malloc(n*sizeof(double));
dspl_linspace(0, N-1, N, DSPL_SYMMETRIC, t);
dspl_writetxt(t, s, N, "dat/resample_lagrange_interp_s.txt");
dspl_linspace(0, N-1, n, DSPL_SYMMETRIC, t);
dspl_writetxt(t, y, n, "dat/resample_lagrange_interp_y.txt");
free(y);
free(t);
/* clear dspl handle */
FreeLibrary(hDSPL);
return 0;
}

Select spelling error with your mouse and press Система Orphus