resample_spline_ex_interp.c

Example of using Farrow filter based on spline interpolation 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_spline_interp_s.txt`

.

The interpolated signal at the output of Farrow filter is saved in`dat/resample_spline_interp_y.txt`

.

The pickup and interpolated signals saved in `dat/resample_spline_interp_s.txt`

and `dat/resample_spline_interp_y.txt`

, are shown in the following figure.

#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_spline(s, N, P, Q, 0, &y, &n);

t = (double*)malloc(n*sizeof(double));

dspl_linspace(0, N-1, N, DSPL_SYMMETRIC, t);

dspl_linspace(0, N-1, n, DSPL_SYMMETRIC, t);

dspl_writetxt(t, y, n, "dat/resample_spline_interp_y.txt");

free(y);

free(t);

/* clear dspl handle */

FreeLibrary(hDSPL);

return 0;

}

Generated on Sat Mar 11 2017 12:37:51 for DSPL - Digital signal processing library by 1.8.13