The Arduino FHT library
FHT does exactly the same job as the more well-known FFT but unlike this one it uses only real data, while FFT works on complex data, therefore FHT uses half processing power and half system memory.
This library uses a single array for data sampling instead of two, one for real values and one for imaginary values, used by FFT lib, it also simplifies complex mathematical calculations avoiding loops with complex floating point logarithmic calculations and instead uses some numerical tables.
The downside is that it always returns half the values of the size of the array used to perform the sampling, this leads to a certain loss of resolution and precision at the two ends of the audio range. However, in the specific case we do not have to develop a measuring instrument but a simple gadget, we do not need extreme precision, we just have to turn on a handful of LEDs in musical rhythm.
Of course this is not the right place to discuss the modality operation of the FHT library, anyone wishing to learn more can refer to the Open Music Lab website where they will find all the necessary documentation to understand the tricks used, the detailed explanation of the various functions and some generic examples already written for Arduino.
The FFT library is fast, so fast that it was necessary to insert a delay in the code to reduce flicker. You will immediately notice the final result, the display is much faster and more responsive than the version that uses the FFT library which often seemed to be lagging behind the music. Less use of system resources allowed us to add some lines of code to manage additional functions.The New Version
The project is identical to the previous version, so those who have already made the previous one need only add a button and a 10K resistor and update the code.
In addition to the implementation of the FHT library, this version has the following additional functions:
- has an additional button for brightness adjustment;
- allows saving color and brightness settings in the EEPROM in order to reload them the next time it is turned on;
- displays color and brightness settings level when buttons are pressed and when turned on (can be disabled).