Example 1: FFT()
include
c:\dsp_1for2\dsp_1for2.inc
;prototypes, datatypes and structures definitions
includelib
c:\dsp_1for2\dsp_1for2.lib
;import library
N equ
256
.data?
SignalIn SIGNAL N
dup(?) ;Input signal, array of N points
SpectrumOut COMPLEX N
dup(?);Output spectrum, array of N complex points
DspStruct1 DSPSTRUCT <>
;uninitialized DSPSTRUCT structure
.
.
.code
.
.
;The following is in the window procedure:
;----------------------------------------
.if uMsg==WM_CREATE ;initialization
invoke
NewDSP,N,addr dspstruct1,1 ;allocate 1
computation block
;here: fill the input signal (SignalIn) with test values
.
.
.elseif uMsg==WM_COMMAND
;menu
mov eax,wParam ;as any other program
.if ax==IDM_COMPUTE_SPECTRUM
;user chooses to compute
signal spectrun
invoke FFT,addr SignalIn,addr
SpectrumOut,DSPSTRUCTs ptr DspStruct1
;Note that we passed the 1st
4 members of the DSPSTRUCT structure by casting
it to a DSPSTRUCTs structure using "DSPSTRUCTs ptr"
.
.
.endif
;menu
.elseif uMsg==WM_DESTROY
;clean up
invoke
DeleteDSP,addr dspstruct1
.
.
.endif ;uMsg
.
.
end