资源简介
VC程序实现了波形显示与FFT算法,实时显示波形,包含采集回放暂停

代码片段和文件信息
/********************************************************/
/* WARNING: */
/* This code cannot be used in any aplication */
/* without permition of the author */
/* for more information please read the license in the */
/* Numerical Recipies in C book or go to www.nr.com */
/* this is mearly an example of how to use it */
/********************************************************/
#include “StdAfx.h“
#include
#include “.\fourier.h“
#define SWAP(ab) tempr=(a);(a)=(b);(b)=tempr
CFourier::CFourier(void)
{
pi=4*atan((double)1);vector=NULL;
}
CFourier::~CFourier(void)
{if(vector!=NULL)
delete [] vector;
}
// FFT 1D
void CFourier::ComplexFFT(float data[] unsigned long number_of_samples unsigned int sample_rate int sign)
{
//variables for the fft
unsigned long nmmaxmjistepi;
double wtempwrwprwpiwithetatemprtempi;
//the complex array is real+complex so the array
//as a size n = 2* number of complex samples
//real part is the data[index] and
//the complex part is the data[index+1]
//new complex array of size n=2*sample_rate
if(vector!=NULL)
delete [] vector;
vector=new float [2*sample_rate];
//put the real array in a complex array
//the complex part is filled with 0‘s
//the remaining vector with no data is filled with 0‘s
for(n=0; n {
if(n vector[2*n]=data[n];
else
vector[2*n]=0;
vector[2*n+1]=0;
}
//binary inversion (note that the indexes
//start from 0 witch means that the
//real part of the complex is on the even-indexes
//and the complex part is on the odd-indexes)
n=sample_rate << 1;
j=0;
for (i=0;i if (j > i) {
SWAP(vector[j]vector[i]);
SWAP(vector[j+1]vector[i+1]);
if((j/2)<(n/4)){
SWAP(vector[(n-(i+2))]vector[(n-(j+2))]);
SWAP(vector[(n-(i+2))+1]vector[(n-(j+2))+1]);
}
}
m=n >> 1;
while (m >= 2 && j >= m) {
j -= m;
m >>= 1;
}
j += m;
}
//end of the bit-reversed order algorithm
//Danielson-Lanzcos routine
mmax=2;
//external loop
while (n > mmax)
{
istep=mmax << 1;
theta=sign*(2*pi/mmax);
wtemp=sin(0.5*theta);
wpr = -2.0*wtemp*wtemp;
wpi=sin(theta);
wr=1.0;
wi=0.0;
//internal loops
for (m=1;m for (i=m;i<=n;i+=istep) {
j=i+mmax;
tempr=wr*vector[j-1]-wi*vector[j];
tempi=wr*vector[j]+wi*vector[j-1];
vector[j-1]=vector[i-1]-tempr;
vector[j]=vector[i]-tempi;
vector[i-1] += tempr;
vector[i] += tempi;
}
wr=(wtemp=wr)*wpr-wi*wpi+wr;
wi=wi*wpr+wtemp*wpi+wi;
}
mmax=istep;
}
//end of the algorithm
//determine the fundamental frequency
//look for the maximum absolute value in the complex array
fundamental_frequency=0;
for(i=2; i<=sample_rate; i+=2)
{
if((pow(vector[i]2)+pow(vector[i+1]2))>(pow(vector[fundamental_frequency]2)+pow(vector[fund
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 3277 2008-10-07 20:42 FFT_RecordHWnd\Fourier.cpp
文件 401 2008-10-04 19:50 FFT_RecordHWnd\Fourier.h
文件 3651 2003-10-19 17:09 FFT_RecordHWnd\ReadMe.txt
文件 36956 2008-10-05 17:44 FFT_RecordHWnd\RecordHWnd.aps
文件 1623 2008-10-08 16:30 FFT_RecordHWnd\RecordHWnd.clw
文件 2119 2007-04-15 16:54 FFT_RecordHWnd\RecordHWnd.cpp
文件 4434 2008-10-03 22:18 FFT_RecordHWnd\RecordHWnd.dsp
文件 545 2007-04-15 16:06 FFT_RecordHWnd\RecordHWnd.dsw
文件 1368 2003-10-19 17:09 FFT_RecordHWnd\RecordHWnd.h
文件 132096 2008-10-08 16:30 FFT_RecordHWnd\RecordHWnd.ncb
文件 126976 2008-10-08 16:30 FFT_RecordHWnd\RecordHWnd.opt
文件 1366 2008-10-08 16:28 FFT_RecordHWnd\RecordHWnd.plg
文件 6556 2008-10-05 17:44 FFT_RecordHWnd\RecordHWnd.rc
文件 909 2008-05-30 10:36 FFT_RecordHWnd\RecordHWnd.sln
..A..H. 13312 2008-10-06 20:49 FFT_RecordHWnd\RecordHWnd.suo
文件 6869 2008-05-30 10:36 FFT_RecordHWnd\RecordHWnd.vcproj
文件 16011 2008-10-08 16:28 FFT_RecordHWnd\RecordHWndDlg.cpp
文件 2735 2008-10-08 16:26 FFT_RecordHWnd\RecordHWndDlg.h
文件 1078 2003-10-19 17:09 FFT_RecordHWnd\res\RecordHWnd.ico
文件 402 2003-10-19 17:09 FFT_RecordHWnd\res\RecordHWnd.rc2
文件 1193 2008-10-05 17:44 FFT_RecordHWnd\resource.h
文件 2876 2008-05-05 14:47 FFT_RecordHWnd\SpectrumGraph.h
文件 212 2003-10-19 17:09 FFT_RecordHWnd\StdAfx.cpp
文件 1077 2008-10-07 13:08 FFT_RecordHWnd\StdAfx.h
目录 0 2008-10-06 20:48 FFT_RecordHWnd\res
目录 0 2008-10-08 16:30 FFT_RecordHWnd
----------- --------- ---------- ----- ----
368042 26
- 上一篇:遗传算法两基因度与多基因度
- 下一篇:维特比译码verilog程序
相关资源
- VC仿Windows记事本源代码
- SpringMVC文件上传与的实现.rar
- Windows异步套接字网络编程
- VC 获得文件属性 获取文件的创建时
- 基于MVC模式的会员管理系统
- silicon lab公司的收音IC SI47XX全套开发工
- 读者写者问题(读者优先,写者优先
- MFC程序-碰撞的小球
- vc 柱形图 CBarChart
- dsp2812上128点FFTc程序以及其CMD文件
- 用vc 写的导线测量,针对刚学测绘的
- 用VC 编写的仿QQ聊天室程序源代码
- 用FFT对信号进行频谱分析
- 栅栏填充算法源码(VC)
- 简单的房屋租赁系统
- .net网站服装销售系统(MVC)
-
ob
jectARX给Auto CAD加工具条 - blowfish的vc2008工程.rar
- 画图程序MFC/VC/VC CRectTracker 串行化
- capon波束形成算法-VC实现
- 读取串口数据并画实时曲线的VC 程序
- VC 游戏编程—附源代码
- IpHlpApi.h&IpHlpApi.lib
- vc 6.0开发的流程图编辑器
- VC 天空盒(skyBox)实现(附源代码)
- c MFC 画多边形
- keil vcom windows 7 64bit 驱动
- vc URL编解码类
- vc编写中国象棋详细源码注释并附有视
- VC 围棋源代码
评论
共有 条评论