/*______________________________________________________________________ RFFT2TBL.C Twiddle Factor Generator for ADSP-21020 Radix-2 FFT Author: 18-FEB-91, Steven Cox, Analog Devices DSP Div. (617) 461-3672 Modified: 3-APR-91, Ronnin Yee, Analog Devices DSP Div. (617) 461-3672 12-JUN-91, Ronnin Yee, Analog Devices DSP Div. (617) 461-3672 ______________________________________________________________________*/ #include #include main() { int i, n, iter; double freq, c, s; double pi; FILE *s_file; FILE *c_file; char filename1[25]; char filename2[25]; /* initialize pi */ pi = 4.0*atan(1.0); printf("%c%c%c%c",27,91,50,74); /*clear screen*/ printf("%c%c%c",27,91,72); /*curser home*/ printf("________________Radix-2 Real FFT Table Generator____________\n"); printf("Generates sine and cosine tables for use with the ADSP-21020\n"); printf("radix-2 real FFT program, RFFT2.ASM.\n"); printf("12-JUN-91, Ronnin Yee, Analog Devices\n"); printf("_____________________________________________________________\n"); printf("Enter the number of points -> "); scanf(" %d",&n); n=n/2; iter=n/2-1; printf("\n Enter the cosine twiddle table filename: "); scanf(" %s",filename1); c_file=fopen(filename1,"w"); printf(" Enter the sine twiddle table filename: "); scanf(" %s",filename2); s_file=fopen(filename2,"w"); freq=2.0*pi/(double)n; for (i=0; i <= iter; i++) { s=sin((double)i * freq); c=cos((double)i * freq); fprintf(s_file,"%22.14e\n",s); fprintf(c_file,"%22.14e\n",c); printf("%d : %22.14e : %22.14e\r",i,s,c); } fclose(s_file); fclose(c_file); /* Make 0.5*cos(pi*n/N) and 0.5*sin(pi*n/N) tables */ printf("\n\n Enter the half cosine coeff table filename: "); scanf(" %s",filename1); c_file=fopen(filename1,"w"); printf(" Enter the half sine coeff table filename: "); scanf(" %s",filename2); s_file=fopen(filename2,"w"); freq=pi/(double)n; for (i=0; i <= iter; i++) { s=0.5*sin((double)i * freq); c=0.5*cos((double)i * freq); fprintf(s_file,"%22.14e\n",s); fprintf(c_file,"%22.14e\n",c); printf("%d : %22.14e : %22.14e\r",i,s,c); } fclose(s_file); fclose(c_file); printf("\nFinished\n"); }