Command line Fourier analysis and spectrum analyser written in C++ with no third-party libraries. See Fourier transform on Wikipedia.
$ make noise
There's a make rule to run cppcheck
and one to run clang-format
over all cpp and h files with the default settings and apply the results. It
would be nice if this were more integrated into the workflow. And it can be
useful to swap in iwyu
to weed out any left over includes. But I don't
really like the output so it's used purely as a guide.
make CC=iwyu
I've instrumented the code and switched between compiler optimisation settings (none or three) during development.
C arrays are marginally quicker than vectors.
Calling reserve with a vector is quicker than a C array.
The twiddle array is the most computationally expensive procedure.
Only half of the twiddle array is needed.
Aim for the compiler to do as much as possible up front: optimise away the calculation.
Using floats for all the calculations is slower than doubles.
Creating the array offline results in a very quick twiddle calculation but it takes a long time to compile and both clang and gcc cough for large arrays. The build procedure is also becoming very complicated.
Hardcoding the bin count halves the twiddle calculation before compiler optimisation.
Rather than introduce the complication of ncurses for animation the results are simply printed to the screen. But it happens quickly enough to make it appear smooth like a zoetrope.