This is sincTab.c in view mode; [Download] [Up]
#include "../sms.h" #define SINC_TABLE_SIZE 4096 static double Sinc (double x, short N) { return (sin ((N/2) * x) / sin (x/2)); } /* function to prepare the main lobe of a frequency domain * BlackmanHarris92 window * */ int PrepSinc () { short N = 512, i, m; float fA[4] = {.35875, .48829, .14128, .01168}, fMax = 0; double fTheta = -4.0 * TWO_PI / N, fThetaIncr = (8.0 * TWO_PI / N) / (SINC_TABLE_SIZE); if((pFSincTab = (double *) calloc (SINC_TABLE_SIZE, sizeof(double))) == 0) return (0); for(i = 0; i < SINC_TABLE_SIZE; i++) { for (m = 0; m < 4; m++) pFSincTab[i] += -1 * (fA[m]/2) * (Sinc (fTheta - m * TWO_PI/N, N) + Sinc (fTheta + m * TWO_PI/N, N)); fTheta += fThetaIncr; } fMax = pFSincTab[(int) SINC_TABLE_SIZE / 2]; for (i = 0; i < SINC_TABLE_SIZE; i++) pFSincTab[i] = pFSincTab[i] / fMax; return (1); } /* * fTheta has to be from 0 to 8 */ double SincTab (double fTheta) { long index = (long) (.5 + SINC_TABLE_SIZE * fTheta / 8.0); return (pFSincTab[index]); }
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.