Question on ADC1 FFT

Status
Not open for further replies.

infibit

Member
Hello,

I am trying to do an FFT over ADC using the Teensy3.2 but I have not had any success.Here is my code:
Code:
#include <Audio.h>

// GUItool: begin automatically generated code
AudioInputAnalog         adc1(A2);           //xy=178.3333282470703,125.33332824707031
AudioAnalyzeFFT256       myFFT;       //xy=351.33331298828125,125.33334350585938
AudioConnection          patchCord1(adc1, myFFT);
// GUItool: end automatically generated code
void setup() {
  Serial.begin(115200);
  delay(5000);
  Serial.println("Hello");
  // Configure the window algorithm to use
  //myFFT.windowFunction(AudioWindowHanning256);
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:
float n;
  int i;

  //if(myFFT.available())
  if(1)
  {
    // each time new FFT data is available
    // print it all to the Arduino Serial Monitor
    Serial.print("FFT: ");
    for (i=0; i<40; i++) {
      n = myFFT.read(i);
      if (n >= 0.01) {
        Serial.print(n);
        Serial.print(" ");
      } else {
        Serial.print("  -  "); // don't print "0.00"
      }
    }
    Serial.println();
  }
}

Please let me know as to what is going wrong.I connected the mic output (MEMs microphone INMP401 -sparkfun) to ADC A2 on the Teensy and running this code but no success.
 
I just found out that audio requires memory to work. So when I put "AudioMemory(12)" this line in the code,it worked.I want to identify only when frequencies in the range of 80 -200hz are detected. How shall I do this with the FFT data?
 
I want to identify only when frequencies in the range of 80 -200hz are detected. How shall I do this with the FFT data?

Maybe use myFFT.read(2, 5); to read the sum of those bins?

Another alternative would be a FIR bandpass filter that attenuates below 80 and above 200. Then feed it to the RMS measurement object. But such a filter will require a large number of "taps" which might be even more CPU intensive than the FFT. Maybe?
 
Status
Not open for further replies.
Back
Top