The Fast Fourier Transform (FFT) is an algorithm capable of converting a signal from its original domain (often time or space) to a representation in the frequency domain and vice versa. It works alongside the consideration that every non-periodical signal in the time domain is a sum of periodic ones in terms of sines and cosines that can be broken down.
In the audio field, this tool can help us to find and filter unwanted noises (frequencies), analyze functions harmonics, extract meaningful features of a signal for Machine Learning purposes, and much more.
FFT is considered the most important numerical algorithm of our lifetime, and in this guide, you will be implementing it with WisBlock.
If you are a visual learner, you can watch the video tutorial instead.
Hardware
To carry out this test you need some WisBlock hardware:
You can choose between several microphones:
- RAK18000 PDM Stereo Microphone Module
- RAK18030 WisBlock Audio PDM Microphone Module
- RAK18031 WisBlock Audio PDM Microphone Module
- RAK18032 WisBlock Audio Ultrasonic Microphone Module
đź“ť NOTE: This is also compatible with the ESP32 and RP2040 cores. |
Software
- Arduino IDE
Follow the installation guide of BSP to set up your Arduino IDE to program WisBlock boards.
WisBlock Assembly
To put together the different modules, you just need to connect them to the respective slots in the base board.
Code
To open the code, download and install the RAKwireless Audio Library from the GitHub repository.
Open the Arduino IDE, and search for the ZIP file by navigating to Sketch > Include Library > Add .ZIP Library…
On the Arduino IDE, navigate to File > Examples > RAKwireless Audio Library > RAK4631 > PDMSerialPlotterFFT.
📝 NOTE There’s also a High Rate FFT example.
Select the board you are using, connect it through the USB cable, and select the respective COM port.
Click Upload, and wait for the core to be flashed.
Testing
Once the code is uploaded, open the Serial Plotter on the Arduino IDE and you should see a line graph.
📝 NOTE: The line graph doesn’t work with Arduino IDE 2.0. |
To better see the FFT in action, use Online Tone Generator to generate pure tones of any frequency to play some notes.
Lastly, set the frequency to 440 Hz. The Serial Plotter shows us a high amplitude spike and specifies the frequency component extracted. It almost perfectly matches the set on the tone generator, so we are up and running with very accurate results, which is great.
Updated