DSPRelated.com
Forums

FFT program already done: How to use it?

Started by gpezzella November 11, 2010
Hello

I have found here:
http://logix4u.net/DSP/Fast_Fourier_Transform/Visual_Basic_program_for_Fast_Fourier_Transform.html

a good program written in VB6 that implement FFT algoritm.

It stored the result in array named "outputarray".

Questions 1:
If I generate sin wave of 10Hz I should have frequence spectrum peak at
10Hz. Why if I debug adding this code:

Debug.Print outputarray(cnt) & "[" & cnt & "]"      <...about at line 188>

I found peak at cnt=5????

Question2:
For know which frequency components are present in a signal, plot real part
is correct?
Thanks
"gpezzella" <gpezzella@n_o_s_p_a_m.yahoo.com> writes:

> Hello > > I have found here: > http://logix4u.net/DSP/Fast_Fourier_Transform/Visual_Basic_program_for_Fast_Fourier_Transform.html > > a good program written in VB6 that implement FFT algoritm.
Why don't you use FFTW? There is a windows DLL version here: http://www.fftw.org/install/windows.html
> It stored the result in array named "outputarray". > > Questions 1: > If I generate sin wave of 10Hz I should have frequence spectrum peak at > 10Hz. Why if I debug adding this code: > > Debug.Print outputarray(cnt) & "[" & cnt & "]" <...about at line 188> > > I found peak at cnt=5????
Because FFT output indices do not (necessarily) correspond directly to frequency. Assuming zero-based indexing, output n of an N-point FFT of data sampled at Fs Hz is at a frequency of n * Fs / N Hz.
> Question2: > For know which frequency components are present in a signal, plot real part > is correct?
That question is unintelligible to me, a native English speaker. I think you're asking if it's correct to plot just the real part of the output, in which case the answer would be "No." For your purpose you should plot the magnitude, sqrt(x^2 + y^2), where x is the real part and y is the imaginary part. -- Randy Yates % "She tells me that she likes me very much, Digital Signal Labs % but when I try to touch, she makes it mailto://yates@ieee.org % all too clear." http://www.digitalsignallabs.com % 'Yours Truly, 2095', *Time*, ELO

Randy Yates wrote:


> Why don't you use FFTW?
A straigntforward FFT from a textbook takes ~20 lines of code. Although FFTW runs about 10 times faster, there is often no need to overcomplicate. Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com
Vladimir Vassilevsky <nospam@nowhere.com> writes:

> Randy Yates wrote: > > >> Why don't you use FFTW? > > A straigntforward FFT from a textbook takes ~20 lines of code. > Although FFTW runs about 10 times faster, there is often no need to > overcomplicate.
Even that is going to be more time to code and test than simply plopping down a couple of API calls... -- Randy Yates % "Bird, on the wing, Digital Signal Labs % goes floating by mailto://yates@ieee.org % but there's a teardrop in his eye..." http://www.digitalsignallabs.com % 'One Summer Dream', *Face The Music*, ELO

Randy Yates wrote:

> Vladimir Vassilevsky <nospam@nowhere.com> writes: > > >>Randy Yates wrote: >> >> >> >>>Why don't you use FFTW? >> >>A straigntforward FFT from a textbook takes ~20 lines of code. >>Although FFTW runs about 10 times faster, there is often no need to >>overcomplicate. > > > Even that is going to be more time to code and test than simply plopping > down a couple of API calls...
If you spent a couple of days coding FFT it at one time, you figured it out for the rest of your life. Learning API calls is for stupidents and matlabi. VLV
Vladimir Vassilevsky <nospam@nowhere.com> writes:

> Randy Yates wrote: > >> Vladimir Vassilevsky <nospam@nowhere.com> writes: >> >> >>>Randy Yates wrote: >>> >>> >>> >>>>Why don't you use FFTW? >>> >>>A straigntforward FFT from a textbook takes ~20 lines of code. >>>Although FFTW runs about 10 times faster, there is often no need to >>>overcomplicate. >> >> >> Even that is going to be more time to code and test than simply plopping >> down a couple of API calls... > > If you spent a couple of days coding FFT it at one time, you figured > it out for the rest of your life. Learning API calls is for stupidents > and matlabi.
Your logic works for API approach too. Plus it's less NRE time. I agree: writing an FFT from scratch at least once is a good textbook exercise. I do not agree that it's always a good idea to use that routine in your applications. -- Randy Yates % "How's life on earth? Digital Signal Labs % ... What is it worth?" mailto://yates@ieee.org % 'Mission (A World Record)', http://www.digitalsignallabs.com % *A New World Record*, ELO
Dear Randy

what you have invented for sony ericcson?

Bye
"gpezzella" <gpezzella@n_o_s_p_a_m.yahoo.com> writes:

> Dear Randy > > what you have invented for sony ericcson?
What is your motivation in asking the question? -- Randy Yates % "Midnight, on the water... Digital Signal Labs % I saw... the ocean's daughter." mailto://yates@ieee.org % 'Can't Get It Out Of My Head' http://www.digitalsignallabs.com % *El Dorado*, Electric Light Orchestra
Hello

only curiosity

If I have understand good you have replaced midi chip 

bye

>"gpezzella" <gpezzella@n_o_s_p_a_m.yahoo.com> writes: > >> Dear Randy >> >> what you have invented for sony ericcson? > >What is your motivation in asking the question? >-- >Randy Yates % "Midnight, on the water... >Digital Signal Labs % I saw... the ocean's daughter." >mailto://yates@ieee.org % 'Can't Get It Out Of My Head' >http://www.digitalsignallabs.com % *El Dorado*, Electric Light Orchestra >
"gpezzella" <gpezzella@n_o_s_p_a_m.yahoo.com> writes:

> Hello > > only curiosity > > If I have understand good you have replaced midi chip > > bye
I had help, but I did get the ball rolling. --Randy
> >>"gpezzella" <gpezzella@n_o_s_p_a_m.yahoo.com> writes: >> >>> Dear Randy >>> >>> what you have invented for sony ericcson? >> >>What is your motivation in asking the question? >>-- >>Randy Yates % "Midnight, on the water... >>Digital Signal Labs % I saw... the ocean's daughter." >>mailto://yates@ieee.org % 'Can't Get It Out Of My Head' >>http://www.digitalsignallabs.com % *El Dorado*, Electric Light Orchestra >>
-- Randy Yates % "Remember the good old 1980's, when Digital Signal Labs % things were so uncomplicated?" mailto://yates@ieee.org % 'Ticket To The Moon' http://www.digitalsignallabs.com % *Time*, Electric Light Orchestra