| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1766 人关注过本帖
标题:这次需要真正的高手进来了 谢谢
取消只看楼主 加入收藏
刘暮哲
Rank: 2
来 自:江苏
等 级:论坛游民
帖 子:75
专家分:83
注 册:2009-9-25
结帖率:69.23%
收藏
已结贴  问题点数:10 回复次数:0 
这次需要真正的高手进来了 谢谢
#include<stdio.h>
#include<math.h>
#define N 160
#define m 88   /*滤波器的阶数*/
#define pi 3.1415926
float fir(float *x,float *h,int lenx,int lenh);
void main()
{   
     FILE *fp,yp;     /*fp为指向输入的指针,yp是指向输出的指针*/
     int i,j,a;
     int fc=8000;/*设计的滤波器参数*/
     int fpp=4000;
     float wp=0.5*pi;  /*归一化角频率*/
     int fs=5000;
     float ws=0.625*pi;
     float wc=(wp+ws)/2/pi;
     
     /*设计滤波器*/
     float hd[m];
     float wb[m];
     float h[m];

     float buffer1[N+m-1]={0};
     float buffer2[N+m-1],buffer3[N];
     
     
     a=(m-1)/2;
     
     for(i=0;i<m;i++)
     {     hd[i]=sin(wc*(i-a))/(pi*(i-a));
         wb[i]=0.42-0.5*cos((2*pi)/(m-2))+0.08*cos((4*pi*i)/(m-2));    /*black窗*/
         h[i]=hd[i]*wb[i];   /*滤波器时域形式*/
     }
     

     fp=fopen("d:\我的文档\桌面\work\assignment090929.pcm","r");
     if(fp==NULL)
         printf("the file can not open!\n");
      
     else
         printf("ok\n");
     while(!feof(fp))    /*读入文件并滤波*/
     {
       fread(&buffer1[m-1],sizeof(float),N,fp);
       buffer2=fir(buffer1,h,247,m);
       for(i=0;i<N;i++)
       buffer3[i]=buffer[m+i];
       for(i=0;i<m-1;i++)
            buffer1[i]=buffer1[N+m-2-i];  /*把后面m-1位调到前面*/
       /*输出写到文件*/
       yp=fopen("lz.pcm","w");
       if(yp==NULL)
       {  printf("file write error!\n");
          return;
       }
       fwrite(bufffer3,sizeof(float),N,yp);

      
       }
     fclose(fp);  /*关闭文件*/


}
float fir(float *x,float *h,int lenx,int lenh)
{
        int i,j;
        float yn[247]={0};
        for(i=0;i<lenh;i++)
        {    for(j=0;j<=i;j++)
                yn[i]=x[j]*h[i-j];
        }
        for(i=lenh;i<lenx;i++)
        {
            for(j=0;j<lenh;j++)
                yn[i]=x[i-j]*h[j];
        }

   
    return yn;
}



出现的错误是:
--------------------Configuration: liu - Win32 Debug--------------------
--------------------Configuration: liu - Win32 Debug--------------------
Compiling...
lz.c
D:\VC-work\L\liu\lz.c(13) : warning C4305: 'initializing' : truncation from 'const double ' to 'float '
D:\VC-work\L\liu\lz.c(15) : warning C4305: 'initializing' : truncation from 'const double ' to 'float '
D:\VC-work\L\liu\lz.c(16) : warning C4244: 'initializing' : conversion from 'double ' to 'float ', possible loss of data
D:\VC-work\L\liu\lz.c(30) : warning C4244: '=' : conversion from 'double ' to 'float ', possible loss of data
D:\VC-work\L\liu\lz.c(31) : warning C4244: '=' : conversion from 'double ' to 'float ', possible loss of data
D:\VC-work\L\liu\lz.c(36) : warning C4129: '? : unrecognized character escape sequence
D:\VC-work\L\liu\lz.c(36) : warning C4129: '? : unrecognized character escape sequence
D:\VC-work\L\liu\lz.c(36) : warning C4129: 'w' : unrecognized character escape sequence
D:\VC-work\L\liu\lz.c(45) : error C2115: '=' : incompatible types
D:\VC-work\L\liu\lz.c(45) : error C2106: '=' : left operand must be l-value
D:\VC-work\L\liu\lz.c(52) : error C2115: '=' : incompatible types
D:\VC-work\L\liu\lz.c(52) : error C2088: '==' : illegal for struct
D:\VC-work\L\liu\lz.c(56) : error C2065: 'bufffer3' : undeclared identifier
D:\VC-work\L\liu\lz.c(56) : warning C4022: 'fwrite' : pointer mismatch for actual parameter 1
D:\VC-work\L\liu\lz.c(56) : error C2115: 'function' : incompatible types
D:\VC-work\L\liu\lz.c(56) : warning C4024: 'fwrite' : different types for formal and actual parameter 4
D:\VC-work\L\liu\lz.c(79) : error C2115: 'return' : incompatible types
D:\VC-work\L\liu\lz.c(79) : warning C4172: returning address of local variable or temporary
执行 cl.exe 时出错.

是高手的进来看看  哈哈

lz.obj - 1 error(s), 0 warning(s)
搜索更多相关主题的帖子: 滤波器 
2009-10-24 21:25
快速回复:这次需要真正的高手进来了 谢谢
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.032506 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved