Hello!
I am trying out an audio project which would require me to listen to a fixed frequency pulse which my microphone would hear and record the time of hearing. For this I am using the Teensy 4 + the SPH0645 I2S microphone (No audio shield). I have had success in using the peak and rms analyzers and the microphone seems to work fine. However when I try to use the FFT module in the audio library it fails. The connecting pins remain constant for the three (peak, rms, fft). Would be glad to get some help on this! Here is my source code which is based on the FFT example with the audio shield. The only output I get is the "failed" print I have inserted. If I remove the if statements and just print the read() value for all bins, I get 0.00 for everything. The same result for the FF256.
I am trying out an audio project which would require me to listen to a fixed frequency pulse which my microphone would hear and record the time of hearing. For this I am using the Teensy 4 + the SPH0645 I2S microphone (No audio shield). I have had success in using the peak and rms analyzers and the microphone seems to work fine. However when I try to use the FFT module in the audio library it fails. The connecting pins remain constant for the three (peak, rms, fft). Would be glad to get some help on this! Here is my source code which is based on the FFT example with the audio shield. The only output I get is the "failed" print I have inserted. If I remove the if statements and just print the read() value for all bins, I get 0.00 for everything. The same result for the FF256.
Code:
/*
SD -> pin 8 (in1)/pin 5 (in2)
L/R -> GND/VCC (left/right channel)
WS -> pin 20 (LRCLK1)/pin 3 (LRCLK2)
SCK -> pin21 (BCLK1)/pin 4 (BCLK2)
*/
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioInputI2S i2s1; //xy=500,322
AudioAnalyzeFFT1024 fft1024_1; //xy=701,316
AudioConnection patchCord1(i2s1, 0, fft1024_1, 0);
// GUItool: end automatically generated code
void setup() {
//Serial.begin(9600);
AudioMemory(70);
fft1024_1.windowFunction(AudioWindowHanning1024);
}
void loop() {
float n;
int i;
if (fft1024_1.available()) {
// 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 = fft1024_1.read(i);
if (n >= 0.01) {
Serial.print(n);
Serial.print(" ");
} else {
Serial.print(" - "); // don't print "0.00"
}
}
Serial.println();
}
else
{
Serial.println("failed");
}
}
Last edited: