C语言谱减法实现.docVIP

  • 28
  • 0
  • 约8.37万字
  • 约 10页
  • 2017-07-29 发布于河南
  • 举报
C语言谱减法实现

#include stdio.h #include stdlib.h #include math.h #define WL 256 // ′°3¤ #define P 10 // ?¤2a?μêy #undef pi #define pi 3.1415926535897932384626434 #define PI 3.1415926 #define winsize 256 #define tempsize winsize/2 #define buffsize winsize*10 typedef struct{ double real; double img; }complex; unsigned int f=0; unsigned int c=0; complex noise[winsize]; double buff_r[buffsize]; double buff_w[buffsize]; double temp[tempsize]; complex x[winsize]; complex y[winsize]; int hr=0; complex W[winsize]; complex W1[winsize]; double x_abs[winsize]; double y_abs[winsize]; double noise_abs[winsize]; void fft(complex *x,int size_x,complex *W); /*?ì?ù?μà?ò?±???*/ void ifft(complex *x,int size_x,complex *W1); double angle(complex a); // void add(complex ,complex ,complex *); /*?′êy?ó·¨*/ void mul(complex ,complex ,complex *); /*?′êy3?·¨*/ void sub(complex ,complex ,complex *); /*?′êy??·¨*/ void change(complex *x,int size_x); /*êy×é×a??*/ double abs1(complex a); void hamming(complex hw[]); /*int ReadWaveFile( char *fn,int *fs,short **dat ); int ReadWaveFile( char *fn, // I: ???t?? int *fs, // O: ???t′óD? short **dat // O: ó?ò?êy?Y ) { FILE *fp; int dsize; if ((fp = fopen(fn, rb+)) == NULL) { fprintf(stderr, %s: No such file \n, fn); return(-1); } fseek(fp, 0L, SEEK_END); dsize = ftell(fp)/2; fseek(fp, 0L, SEEK_SET); if ((*dat = (short *)malloc(sizeof(short)*dsize)) == NULL) { fprintf(stderr, Memory Error \n); return(-1); } if (fread(*dat, sizeof(short), dsize, fp) != (unsigned int)dsize) { free(*dat); return(-1); } fclose(fp); *fs = dsize; return(0); }*/ void hamming(complex hw[]) { double x; int i; for(i=0;iWL;i++) { double cos(x); x=2*pi*i/(WL-1); hw[i].real=hw[i].real*(0.54-0.46*cos(x));//*32768; } } void fft(complex *x,int size_x,complex *W){ int i=0,j=0,k=0,l=0,jk=0; complex up,down,product; change

文档评论(0)

1亿VIP精品文档

相关文档