www.pudn.com > howtofft_src.zip > ChildView.cpp
// ChildView.cpp : implementation of the CChildView class
//
#include "stdafx.h"
#include "FFTExample.h"
#include "ChildView.h"
#include "Fourier.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CChildView
CChildView::CChildView()
{
}
CChildView::~CChildView()
{
}
BEGIN_MESSAGE_MAP(CChildView, CWnd)
ON_WM_PAINT()
END_MESSAGE_MAP()
// CChildView message handlers
BOOL CChildView::PreCreateWindow(CREATESTRUCT& cs)
{
if (!CWnd::PreCreateWindow(cs))
return FALSE;
cs.dwExStyle |= WS_EX_CLIENTEDGE;
cs.style &= ~WS_BORDER;
cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS,
::LoadCursor(NULL, IDC_ARROW), reinterpret_cast(COLOR_WINDOW+1), NULL);
return TRUE;
}
void CChildView::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
//Creates a CFourier object
//The CFourier class has the FFT function and a couple of usefull variables
CFourier fft;
//sample rate of the signal (must be 2^n)
long sample_rate=8192;
//number of samples you want to send for processing in the fft (any)
//for example 100 samples
long captured_samples=500;
//frequency of the signal (has to be smaller than sample_rate/2)
//for example 46
int frequency=250;
float data[5000];
//example of a sin signal(you can try to add some more signals to see the
//fourier change
for(int i=0; i