Davidelvig
Well-known member
I'm struggling - hopefully with something simple.
I had a more complex FFT implementation going with an analog microphone, but now myFFT.available() is always returning false.
I backed off to the most stripped-down code I can find from File\Examples\Audio\Analysis\FFT.
I opted for the AudioSynthWaveformSine object to eliminate peripherals.
With the following code, I only get "FFT not available" on the console
Thanks in advance.
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
// Create the Audio components. These should be created in the
// order data flows, inputs/sources -> processing -> outputs
//
AudioSynthWaveformSine sinewave;
AudioAnalyzeFFT1024 myFFT;
AudioOutputI2S audioOutput; // audio shield: headphones & line-out
// Connect synthesized sine wave
AudioConnection patchCord1(sinewave, 0, myFFT, 0);
void setup() {
// Audio connections require memory to work. For more
// detailed information, see the MemoryAndCpuUsage example
AudioMemory(12);
// Configure the window algorithm to use
myFFT.windowFunction(AudioWindowHanning1024);
// Create a synthetic sine wave, for testing
// To use this, edit the connections above
sinewave.amplitude(0.8);
sinewave.frequency(1034.007);
}
void loop() {
float n;
int i;
if (myFFT.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 = myFFT.read(i);
if (n >= 0.01) {
Serial.print;
Serial.print(" ");
} else {
Serial.print(" - "); // don't print "0.00"
}
}
Serial.println();
}
else {
Serial.println("FFT not available");
}
}
I had a more complex FFT implementation going with an analog microphone, but now myFFT.available() is always returning false.
I backed off to the most stripped-down code I can find from File\Examples\Audio\Analysis\FFT.
I opted for the AudioSynthWaveformSine object to eliminate peripherals.
With the following code, I only get "FFT not available" on the console
Thanks in advance.
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
// Create the Audio components. These should be created in the
// order data flows, inputs/sources -> processing -> outputs
//
AudioSynthWaveformSine sinewave;
AudioAnalyzeFFT1024 myFFT;
AudioOutputI2S audioOutput; // audio shield: headphones & line-out
// Connect synthesized sine wave
AudioConnection patchCord1(sinewave, 0, myFFT, 0);
void setup() {
// Audio connections require memory to work. For more
// detailed information, see the MemoryAndCpuUsage example
AudioMemory(12);
// Configure the window algorithm to use
myFFT.windowFunction(AudioWindowHanning1024);
// Create a synthetic sine wave, for testing
// To use this, edit the connections above
sinewave.amplitude(0.8);
sinewave.frequency(1034.007);
}
void loop() {
float n;
int i;
if (myFFT.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 = myFFT.read(i);
if (n >= 0.01) {
Serial.print;
Serial.print(" ");
} else {
Serial.print(" - "); // don't print "0.00"
}
}
Serial.println();
}
else {
Serial.println("FFT not available");
}
}