I speculate here about building a spectrum analyzer. These ideas are mathematical and backed up with code. There are substantial hardware issues of which I am ignorant.

I presume that a sample set is taken at some time, chosen by the user. A sample set a set of 2n samples equally spaced in time taken on command of the user. A sample is a pair of b bit numbers supplied by a heterodyne circuit with the ambient electric field as its input. The intermediate frequency of the heterodyne circuit is f. I consider here only ‘quadrature heterodyne’.

The idea is to display magnitudes of the Fourier transform of a sample set annotated by frequency perhaps exactly like a commercial spectrum analyzer.

This code detects a signal hidden in noise. The signal to noise ratio is 0.01. There are 220 samples and so this is like looking for a kHz channel in a GHz band. Here are a few code comments. Here is a variant with 217 samples. It can find a signal but only with a SNR = 0.02. This variation clips heterodyne yields to 5 bits and hardly suffers thereby.

The files fft.c, rnd.c and misc.c and their respective header files are required auxiliaries. The file bb builds the auxiliary .o files and then b builds the running program.

Some math and physics

If hardware were much more capable we could do away with heterodyne logic and take real digital signals from the ether at perhaps 10 GHz. Soft radio does this but such hardware is rare and a bit expensive. If we are interested in signal and noise in a frequency band such as between 2.4 and 2.5 GHz, where some WiFi lives, then we can largely pretend that we are dealing with 100 MHz signals thru the magic of hetrodyne circuits.

In this section I may be over simplifying or idealizing. A heterodyne circuit has a stable oscillator producing a frequency f near the center of the band of interest. It produces the signal ei2πft = cos(2πft) + i sin(2πft). I assume here that both parts are really produced. The output of the heterodyne circuit is also analog and is the complex number:
h(t) = u=0e−2nu/de2π if(t−u)s(t−u)du
where s(t) is the real signal from the antenna. The output of the heterodyne circuit is h(t), a complex function of t, which is digitally sampled every d2−n seconds. The factor (e−2nu/d), as a function of u, is real and nearly zero outside the sample interval. Other shapes are fine if they are nearly zero outside the sample interval. (e−2nu/d) is merely my guess about real heterodyne circuits. Its shape hardly enters into subsequent considerations. I recall a mathematical note on ‘over sampling’ that concluded that fidelity to the amplitude of high frequencies benefitted by over sampling. The same is probably true here too. That would argue for replacing (e−2nu/d) by (0 < u && u < 2−n/d) in C speak.

Schematic diagrams of heterodyne circuits seldom show the output as other than a single analog signal. I assume quadrature heterodyne here for that keeps alias frequencies from interfering and confusing things. Googling ‘quadrature heterodyne’ leads to a few papers that indicate that this is done when extra precision is needed and other hacks fail.

See thoughts on a ‘digital quadrature heterodyne’.

Collected parameters.
There are 2n samples in a sample set. Perhaps n is limited by RAM. I suppose that 8 ≤ n ≤ 20.
There are b bits in a sample. I suppose that 4 ≤ b ≤ 16.
intermediate frequency of heterodyne circuit. Perhaps 0 GHz ≤ f ≤ 10GHz.
time duration of sample set. Time between successive samples is d2−n sec. I presume that 2 nsec ≤ d2−n ≤ 1000 nsec.

They claim to address the problem. DIY
An interesting recent product