Using line-in for FFT

Status
Not open for further replies.

Maxim

Member
Hi!

A couple of questions:
I have a Teensy 3.2 and an audio shield.

1)I want to receive audio input and to do a real-time FFT.
Did I understand correctly that all I need is just to solder in a 3.5mm stereo female socket, and then I can use AudioInputI2S of GUI?
http://www.pjrc.com/teensy/gui/?info=AudioInputI2S

2)If a logarithmic scale is needed, a simple

Code:
//...
#include "math.h"
//....
float m=fft1024_1.read(i);
int x = max(20*log(m)+100,0);
is enough, or there is a more efficient way to do it?

3)If I want to use the built-in ADC of Teensy, I don't need SGTL5000 at all?
Is the circuitry here
http://www.pjrc.com/teensy/gui/?info=AudioInputAnalog
sufficient for this purpose or an anti-aliasing filter is needed?

Thanks,
Maxim.
 
Code:
float m=fft1024_1.read(i);
int x = max(20*log(m)+100,0);

You should limit the m value to positive numbers before taking the logarithm
Code:
float m=(float)max(1,fft1024_1.read(i));
int x = (int)(20.0f*log10f((float)m))+100;
as m is integer log10(1) = 0, so you do not need the second max after logarithm
You should use log10 as log is natural log that gives you 20*Neper and not dB
 
Ok, thanks!
But if I'm not mistaken the 1 is the maximum value of
fft1024_1.read(i);
and not the minimum one.
 
Ok, thanks!
But if I'm not mistaken the 1 is the maximum value of
fft1024_1.read(i);
and not the minimum one.

I don't know, I'm not using this. OK, I checked it, it gives you normalized values. In this case take max(1.0e-5,fft1024_1.read(ii)), this way the min value is 0dB (20*log10(1e-5) = -100)
 
Status
Not open for further replies.
Back
Top