FFT plot and waterfall for gqrx

Following my success with integrating the frequency control widget from cutesdr into gqrx I have decided to try the same with the FFT plot and waterfall widget. This too seemed to be a single C++ class that might be easy to integrate into my experimental software receiver powered by GNU Radio and Qt GUI.

In reality integrating the FFT plot into gqrx was a little more challenging because the class uses interfaces from the SDR interface class. Besides from some AD overload code, which was easy to eliminate, the FFT plotter fetches scaled FFT data from another object rather than providing a method to set new FFT data. I fixed that by adding the appropriate method to set FFT data and providing the necessary internal functions to scale the FFT data to screen size.

For the FFT code itself I decided to do something similar to what is done in the gr-qtgui component of GNU Radio. I created a block that uses the gri_fft_c code, which is basically just a wrapper around the FFT functions from FFTW.

Currently there is no speed optimisation and an FFT calculation is performed as soon as there are enough samples in the buffer. In practice this means that lower FFT size will consume more CPU than higher since the FFT calculations are performed more often. Of course, this is only true up to a certain limit. I found that an FFT size of 3840 provides very good performance and can still provide a new FFT at 96000 / 3840 = 25 Hz. The screenshot below shows the CPU load with FFT enabled and disabled on rather old dual core CPU running at 1.8 GHz.

As you can see, the difference beetween no FFT and FFT of size 3840 is barely noticeable.

The CPU load with the FFT plot and waterfall running at 10 fps is only a few percent higher, see the screenshot below.

If you have seen cutesdr in action you have probably notices that I also changed the colors – just as I did it with the frequency controller. Oh, by the way… the signal strength meter on the screenshot above is also from cutesdr. It is not quite functional yet so I will talk about that later.

In its present form the FFT plot widget is quite functional and sufficient for now for testing the DSP code and finishing that part of the receiver. It provides the necessary functionality, including tuning within the passband by clicking on the graphs or by dragging the vertical line in the middle of the filter overlay. The filter width can also be adjusted by dragging the edges of the overlay. Later I may want to re-implement it using the item based QGraphicsScene drawing backend available in Qt.

Currently there is a little glitch with the FFT code, which can be seen as sudden jumps on the FFT plot. There are no clicks in the speaker while this happens, which is why I suspect the FFT code and not the FCD or some weird timing jitter. The video below shows these FFT artifacts.

Watch video on YouTube.

Author: Alexandru Csete

Embedded software engineer in the satcom industry during the day. Radio amateur and SDR hacker during the night.