This program calculates the characteristics of Farrow filter to compensate the fractional delay from 0 to 1. It uses Farrow filter on the basis of Lagrange polynomial interpolation.
It calculates the filter reaction to one delta-impulse and plots the filter magnitude and the group delay.
Operation results of the program are saved in files.
Files saving samples of filter impulse response characteristic
dat/resample_lagrange_filter_fd_time_0.0.txt
dat/resample_lagrange_filter_fd_time_0.1.txt
dat/resample_lagrange_filter_fd_time_0.2.txt
. . . . . . . . . . . . . . .
dat/resample_lagrange_filter_fd_time_0.9.txt Impulse response characteristics plotted according to the calculated data are shown in the figure:
Filter magnitude datafiles:
dat/resample_lagrange_filter_fd_mag_0.0.txt
dat/resample_lagrange_filter_fd_mag_0.1.txt
dat/resample_lagrange_filter_fd_mag_0.2.txt
. . . . . . . . . . . . . .
dat/resample_lagrange_filter_fd_mag_0.9.txt Filter groupdelay datafiles:
dat/resample_lagrange_filter_fd_mag_0.0.txt
dat/resample_lagrange_filter_fd_mag_0.1.txt
dat/resample_lagrange_filter_fd_mag_0.2.txt
. . . . . . . . . . . . . .
dat/resample_lagrange_filter_fd_mag_0.9.txt Filter magntudes and group delays plotted according to the saved data are shown in the figure:
#include <stdio.h> #include <stdlib.h> #include <windows.h> #define P 1 #define Q 1 #define K 512 #define N 4 #define FN_LEN 256 int main() { HINSTANCE hDSPL; double s[N] = {0.0, 1.0, 0.0, 0.0}; double *t=NULL; double *h=NULL; double w[K]; double H[K]; double GD[K]; int nh; double frac_delay; char fn[FN_LEN]; hDSPL = dspl_load(); if(!hDSPL) { printf("dspl.dll loading ERROR!\n"); return 0; } t = (double*) malloc(nh*sizeof(double)); for(frac_delay = 0.0; frac_delay<1.0; frac_delay+=0.1) { memset(fn, 0, FN_LEN); sprintf(fn, "dat/resample_lagrange_filter_fd_time_%.1f.txt", frac_delay); memset(fn, 0, FN_LEN); sprintf(fn, "dat/resample_lagrange_filter_fd_mag_%.1f.txt", frac_delay); memset(fn, 0, FN_LEN); sprintf(fn, "dat/resample_lagrange_filter_fd_gd_%.1f.txt", frac_delay); } FreeLibrary(hDSPL); free(h); free(t); return 0; }
|