display spectrum with logarithmically horizontal scale

Status
Not open for further replies.

fred_france

Active member
Hello,
I made my first spectrum analyzer displayed on the ILI9341 using AudioAnalyzeFFT1024.
I would like to display the frequency axis logarithmically.
Here, for example, are the graduations:
0 - 50 - 100 - 200 - 500 - 1K - 2K - 5K - 10k - 20khz

(And in a second time the vertical axis in dB).

Here is an example of these axes taken from an IOS application (spectrum anaylser):

IMG_1481(1).PNG

Thank you in advance for your help
 

Attachments

  • IMG_1481.PNG
    IMG_1481.PNG
    201.8 KB · Views: 56
Then you'll need to map your x coord to frequency through an exponential function, and use that to decide which FFT bin corresponds
to that frequency. And you'll probably want to interpolate between bins at the low frequencies for a smoother curve there, and
average multiple bins at the higher frequencies.
 
for the x axis I thought to force the values ​​that interest me in an array because if I use an exponential function to draw the axes because I think that I will not have the precision between 0 and 1Khz as in my example (1 khz is at half of the axis).

For interpolation and averaging, how will I go about it?

thank you
 
for the x axis I thought to force the values ​​that interest me in an array because if I use an exponential function to draw the axes because I think that I will not have the precision between 0 and 1Khz as in my example (1 khz is at half of the axis).
The FFT output is always equally spaced frequency bins, nothing you can do to change that, you simply want
to present that information recscaled logarithmically. For each x position map to an actual frequency (exponential
conversion as I said), then lookup the value in the FFT bins. Simple.
For interpolation and averaging, how will I go about it?

thank you

Standard mathematical operations, thousands of online tutorials about this kind of thing, you'll probably find some
code examples too if you search.

You could stat just by taking the nearest bin reading - the curve will end up rather steppy at the start, but it would
be a starting point for refinement.
 
thank you

I realize that if I want to put 1 khz roughly half of the screen (x = 320/2 = 160px), the precision will not be good because of the insufficient number of bins (512 for 22Khz, so 23 for 1khz).
So if I want to display 23 bins on 160px, that's a maximum of 7 bars that can be displayed on this half of the screen.

I guess I need to increase the sample rate (base at 44100Hz)
What can be done on the Teensy 4 to enhance this sampling?
 
thank you

I realize that if I want to put 1 khz roughly half of the screen (x = 320/2 = 160px), the precision will not be good because of the insufficient number of bins (512 for 22Khz, so 23 for 1khz).
So if I want to display 23 bins on 160px, that's a maximum of 7 bars that can be displayed on this half of the screen.

I guess I need to increase the sample rate (base at 44100Hz)
What can be done on the Teensy 4 to enhance this sampling?

No, you want to reduce the sampling rate or increase the number of FFT bins or both.
 
Status
Not open for further replies.
Back
Top