This is a personal adaptation for the ESP32 microcontroller of the well known kissFFT library.
Invoke a instance of the FFTProcessor class.
FFTProcessor *FFT = new FFTProcessor(SIGNAL_LENGTH, WINDOW_SIZE);
This software works perfect when AUDIO_LENGHT and WINDOW_SIZE are equal and less than 1300.
Test the code with a sine wave. First create a sine wave of frecuency "freq" and Number of samples equal to AUDIO_LENGTH.
float *sin_200 = FFT->sin_wave(freq, SIGNAL_LENGTH);
(Take in mind that freq has to be < SIGNAL_LENGTH/2). For example, if SIGNAL_LENGTH = 1200 -> freq < 600.
FFT->computeFFT(sin_200);
You can then see the output with various functions (I'll be adding more when i have the time):
- FFT->print_energy_python(); -> prints the FFT result in a python array style.
- FFT->print_energy(); -> prints the absolute value of each frecuency.
- FFT->print_complex(); -> prints the result for each frecuency in their complex format ( real + i*imag )
(You can find this signal in 'data.h')
After applyig the FFT to the signal, we can compare the output of the spectral density generated by the ESP32 with the result generated by the python FFT algorithm.