Mario.Tapilouw

Wednesday, March 31, 2010

Real Time 1D FFT

Another project using FFT, this time I need to have a 1-D FFT transform for analyzing frequency component of a signal. I have an idea to do this FFT real time and show it using my previous technique for GUI using openCV.

I found the reference for making 1D FFT from this website and I modified the source code to work with my compiler and highgui library from OpenCV for showing the result.

For the data buffer, I created a circular buffer using std::deque, continuously updating the buffer using timer and show it into the screen. Currently my FFT class needs an array as the input, so there's an overhead for converting the std::deque to array, so I'm planning to modify my source code for handling std::deque directly for saving processing time.

The data is generated by using a TTimer (not really accurate though.. :( ) and it is sampled by another TTimer. I am planning to move to multimedia timer instead because it is faster and more accurate. The screenshot of the output from this circular buffer is as follow:

And the output of the frequency spectrum is as follow:

The sampling frequency is 250 Hz and the signal source is 50Hz. I am going to use multimedia timer instead for faster sampling time. One thing that I found is that the update rate of my real time viewer is limited to several milliseconds (2-3 ms).

The detail of the FFT source code can be found in this website so I won't post it here and also you can read the "Numerical Recipes in C" book which is quite a good book for programmers.

Labels: , , ,

0 Comments:

Post a Comment

<< Home