-
Notifications
You must be signed in to change notification settings - Fork 1
/
FFTThread.cpp
executable file
·58 lines (47 loc) · 1.65 KB
/
FFTThread.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "stdafx.h"
#include "fftw3.h"
#include "afxmt.h"
#include "Defines.h"
#include "ExternVariables.h"
UINT FFTThreadProc( LPVOID hWnd )
{
int pn = FFTNUM; //point numbers for FFT
//before start the thread, set the event for the prior thread to start correctly
SetEvent(FFTBuffEmpty);
////setup FFT plan
//fftwf_r2r_kind fftkind = FFTW_R2HC;
//fftwf_plan p = fftwf_plan_many_r2r(1, &pn, ALineNum*IterationNum,
// FFTBuff, NULL, 1, FFTNUM,
// FFTResult, NULL, 1, FFTNUM,
// &fftkind, FFTW_MEASURE);
//setup FFT plan for complex data.
fftwf_plan p = fftwf_plan_many_dft( 1, &pn, ALineNum*IterationNum,
(fftwf_complex *)FFTBuff, NULL,
1, SPECTRUMWIDTH,
(fftwf_complex *)FFTResult, NULL,
1, FFTNUM,
FFTW_FORWARD, FFTW_MEASURE);
while (bFFT)
{
WaitForSingleObject(FFTBuffNew, INFINITE) ;
//MessageBox((HWND)hWnd,"FFTBuffNew timeout", "SDOCT", MB_OK);
fftwf_execute(p);
//FFT is done
SetEvent(FFTBuffEmpty);
//if Display Intensity thread is running and IntensityCurveData is needed for display Intensity Curve along ALine
if (bDisplayIntensity)
{
WaitForSingleObject(IntensityBuffEmpty, INFINITE);
//MessageBox((HWND)hWnd,"IntensityBuffEmpty timeout", "SDOCT", MB_OK);
for ( int i = 0; i< ALineNum * IterationNum;i++){
memcpy(IntensityBuff+i* FFTNUM,FFTResult+i* FFTNUM*2, FFTNUM*4);
}
//memcpy(IntensityBuff, FFTResult, RawDataSize*8);
//Intensity data buff (IntensityBuff) is full and new.
SetEvent(IntensityBuffNew);
}
}
fftwf_destroy_plan(p);
theApp.m_hFFTThread=NULL;
return 0;
}