2024-09-14 08:31 PM - edited 2024-09-14 08:32 PM
I am trying to make a music visualizer with led matrix and stm32f411 usb audio function
previously , i tried to use stm32f103 blue pill but the usb audio stuck and i can't find the reason
so i purchased the black pill to do it
but now the problem is the fft result is always drifted and seems not accurate
my usb audio sample rate is 48k Hz
i have tried kissfft and the fft in arm_math.h , they have similar result
for example ,when i play a 5k Hz sound on my pc , would result in peak at around 2.5kHz
and some similar peak at around 20kHz
i know that some fft result will have symmetric form at with start and end of the output buffer
but i think it is not the case
the video show i do some simple math to display the fft on led matrix from 0-20000Hz
the high frequency is at left , low frequency is at right
and you can see it kind of like being symmetric but not exactly ,especially the high frequency side is low at start
i am thinking of maybe the audio data have some problem
but i don't know how to verify
Solved! Go to Solution.
2024-09-15 09:08 PM
thank you
i just realize that the data is in stereo
and i have tested to print out one side of the the data
when i play one side it have brunch of different data
when i play other side it keeps printing 0 or 1
it is quite match my expectation
but when i feed the data to fft
the result still strange and likely half of the played frequency
and some strange frequency are rising as i observe
however , i tested the almost same code this morning
it run perfectly good....
the possible reason i am thinking of is the uart ground was plugging to other pc at the first place
2024-09-15 04:28 AM
When you play a 5KHz tone, the FFT indicates a 2.5KHz tone - out by a factor of two (if you feed it 6KHz do you get 3KHz?). It is probably some simple error that is producing the factor 2 error. Perhaps try feeding the FFT with a simple mathematically(+timer) generated sine wave - ideally test the FFT with a standalone program, test each part of your program separately (eg. dump and check a portion of your ADC data when sampling the 5KHz tone).
2024-09-15 09:08 PM
thank you
i just realize that the data is in stereo
and i have tested to print out one side of the the data
when i play one side it have brunch of different data
when i play other side it keeps printing 0 or 1
it is quite match my expectation
but when i feed the data to fft
the result still strange and likely half of the played frequency
and some strange frequency are rising as i observe
however , i tested the almost same code this morning
it run perfectly good....
the possible reason i am thinking of is the uart ground was plugging to other pc at the first place