📄 goertzel test.cpp
字号:
/**********************************************
* Filename : Goertzel Test.CPP *
* Function : Test Goertzel algorithm *
**********************************************/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <direct.h>
#include <process.h>
void Goertzel(int le,float *x,int ls,int m,float fs,float f,float *result);
void main( void )
{
FILE *Stream;
char lpszFileName[]="\\test.dat";
char *Direct;
float inputData[1800];
float result[9];
int i,j;
Direct=(char *)calloc(_MAX_PATH,sizeof(char));
/* Get the current working directory: */
if(_getcwd( Direct, _MAX_PATH ) == NULL )
perror( "_getcwd error" );
else
strcat(Direct,lpszFileName);
if((Stream=fopen(Direct,"r"))==NULL)
{
printf("Can not open the file!\n");
free(Direct);
exit(0);
}
else
{
i=0;
/* read the input data */
while(fscanf(Stream,"%f",&inputData[i])!= EOF)
{
i++;
}
}
fclose(Stream);
free(Direct);
/* implement Goertzel */
Goertzel(1800,inputData,200,9,8000,1209,result);
/* output the results */
if((Stream=fopen("test2.dat","w"))==NULL)
{
printf("Can not open the file!\n");
exit(0);
}
else
{
for(j=0;j<9;j++)
{
fprintf(Stream,"%f ",result[j]);
}
}
fclose(Stream);
system("type test2.dat");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -