FFT library and plot

Since FFT was the subject, it seemed fitting to do some Fourier using the FFTW3 library on some audio. Using an example from the net as a starting point was a time saver in one way and not in another. Debugging code is always fun so ... I had used the AT&T voice server to get some audio for the expression "Segmentation fault" as an example and so that was the file to perform FFT with. Step one was to compile and it was necessary to add a few includes for memset and math to resolve some "implicit declaration warns" and it compiled fine. Next was running test and it printed out "Segmentation fault". It didn't seem there was a line to print the input wav file name, but it could have been overlooked. Since my mind is wandering it is an unusual thing that Spock used a Jewish ceremonial gesture as a "Vulcan" symbol of "live long and prosper".

So it took about one second to realize that it was a real SIGSEGV. It took another few minutes to scope out the fact that rplan was "NULL and VOID", which an assert would have been fitting if it was being proffered as something to be used by others, and the gnuplot code was a bit funky and that was fixed in about 30 seconds. Also it was using a "Magic" number to match the file data structure size, even though it is a given in the header of the .wav. Fixed and fixed. The code below shows the two methods of making the FFTW3 plan and the bottom will return NULL with the newer versions. Understandable, changing the spec is not likely to retrofit every code against an interface that is in flux. If the interface allows, somebody will cut that corner anyway so all in all it wasn't too much work to get the image above and left.



rplan = fftw_plan_r2r_1d(n, rdata, idata, FFTW_R2HC, FFTW_ESTIMATE); fftw_execute(rplan);

rplan = fftw_plan_r2r_1d(n, rdata, idata, FFTW_R2HC, FFTW_FORWARD); fftw_execute(rplan);

It does seem fitting that the wav file chosen was "Segmentation fault" by name and content, as if it was an omen of the future. It would have been more fun if SDL sound was included and "Segmentation fault" was spoken right before it crashed.

0 comments:

Automated Intelligence

Automated Intelligence
Auftrag der unendlichen LOL katzen