Hi all
I'm starting from this: https://hackaday.io/project/8599-teensy-audio-spectrum-analyser#j-discussions-title
Basically it works, but I'd like to replace the unknown frequencies from calcBands function with a 64 frequencies array. Can you help me understanding the relationship between frequencies in Hertz, loBound and hiBound?
I've added two LED test functions, because 2 of the LED matrixes from Aliexpress have one and two pixels not working! >:(
const int sampleRate = 16384;
const int timeSize = 1024; //FFT points
Center of each of the 512 buckets:
freq = index * (sampleRate / timeSize)
0 -> DC
1 -> 16 Hz
2 -> 32 Hz
3 -> 48 Hz
4 -> 64 Hz
511 -> 8176 Hz
Each bucket is 16 Hz wide.
I think what the code is doing is dividing the 64 display columns among the 512 values to get an equal change of pitch (not frequency) in each column. Sort of like semitones in an octave.
If the sample rate is 16384 Hz, then the maximum allowable frequency in the audio input stream is half that, or 8192 Hz. Any input signal component with higher frequency will be aliased and confuse the spectrum display.
I think what the code is doing is dividing the 64 display columns among the 512 values to get an equal change of pitch (not frequency) in each column.
Correct. The FFT frequency bins are grouped logarithmically on the x-axis, to correspond to the logarithmic response of human hearing.
630 is the middle of the 20Hz to 20kHz audible range... but the FFT only goes up to 8176 so a large portion of your display would be unused if you made 20kHz the top of the display. The middle of a 64Hz to 8176Hz range is 723Hz.
Maybe he has hardware capable of sampling at 44kHz.
Where did you get 43Hz steps? 64 to 8167 in 64 steps is 7.872784%
You could try cranking up the the sample rate until you reach 44 kHz or you exceed the capability of the analog input hardware. Then crank up the FFT size (currently 1024 samples) until you run out of RAM or the FFT calculations take too long to be usable.