I'm starting from this:
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! >:(
PsicoSA_v0.4.zip (14.2 KB)
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.
Yes, that's right.
Hey! I see now that Nick replied to my message! I thought he wasn't reading there anymore!
The range will be from just above 50hz (or down to 10hz if your hardware is good enough to set m_shift = 0.1) to 22khz.
I don't understand... You're right: const int sampleRate = 16384;
Why does he say "to 22kHz"?
I ask him...
Thank you for your help!
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.
The problem is that 630Hz should be at the center, at the 32nd of 64 columns (20:630=630:20000), but with 43Hz steps: 630/43=15!
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%
I'm using a Teensy 3.2. Connecting a generator at the input, I saw up to 20kHz.
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.
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.