Hello,
I'm trying to perform an FFT on sound from line-in. So I'm combining the Mic Check and FFT sketches from the tutorial.
If I comment out everything having to do with the FFT, the sketch works perfectly - I can hear sound coming out of the speaker.
But as soon as I add the FFT code, nothing happens - no sound comes out of the speaker and the serial monitor is blank.
I know I'm doing something silly but I can't find it. Thanks in advance!
I'm trying to perform an FFT on sound from line-in. So I'm combining the Mic Check and FFT sketches from the tutorial.
If I comment out everything having to do with the FFT, the sketch works perfectly - I can hear sound coming out of the speaker.
But as soon as I add the FFT code, nothing happens - no sound comes out of the speaker and the serial monitor is blank.
I know I'm doing something silly but I can't find it. Thanks in advance!
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioInputI2S i2s1; //xy=214,234.00000190734863
AudioAnalyzeFFT1024 fft1024_1; //xy=424,264
AudioOutputI2S i2s2; //xy=441.0000114440918,221.00000190734863
AudioConnection patchCord1(i2s1, 0, i2s2, 0);
AudioConnection patchCord2(i2s1, 0, i2s2, 1);
AudioConnection patchCord3(i2s1, 0, fft1024_1, 0);
AudioControlSGTL5000 sgtl5000_1; //xy=499,356
// GUItool: end automatically generated code
void setup() {
Serial.begin(9600);
AudioMemory(8);
sgtl5000_1.enable();
sgtl5000_1.volume(0.5);
sgtl5000_1.inputSelect(AUDIO_INPUT_LINEIN);
sgtl5000_1.lineInLevel(5,5);
delay(1000);
}
void loop() {
if (fft1024_1.available()) {
for (int i=0; i<30; i++) { // 0-25 --> DC to 1.25 kHz
float n = fft1024_1.read(i);
printNumber(n);
}
Serial.println();
}
}
void printNumber(float n) {
Serial.print(n, 3);
Serial.print(" ");
}