I'm sure i'm missing something simple. Using Teensy 3.2 / Arduino 1.8.3 / Teensyduino 1.38-beta2.
The code below using AudioAnalyzeFFT256 prints only one number and then freezes, meaning myFFT.available() went true only one time. If I exchange the three lines commented out so I am using FFT1024 instead, I get all 100 lines as expected and the runtime in msec at the end. In this case I am using the Serial1 UART, but the same behavior occurs if I use the USB port. Any suggestions?
The code below using AudioAnalyzeFFT256 prints only one number and then freezes, meaning myFFT.available() went true only one time. If I exchange the three lines commented out so I am using FFT1024 instead, I get all 100 lines as expected and the runtime in msec at the end. In this case I am using the Serial1 UART, but the same behavior occurs if I use the USB port. Any suggestions?
Code:
#include <Audio.h> # Test Teensy 3.2 Audio Library FFT1024 and FFT256
AudioInputAnalog adc1;
// AudioAnalyzeFFT1024 myFFT;
AudioAnalyzeFFT256 myFFT;
AudioConnection patchCord1(adc1, myFFT);
// #define FBINS 512 // full length of frequency data from 1024-point FFT
#define FBINS 128 // full length of frequency data from 256-point FFT
#define SERPORT Serial1
void setup() {
float fv; // sum of FFT values
AudioMemory(12);
SERPORT.begin(57600);
delay(2000);
// SERPORT.println("FFT Test Start 1024");
SERPORT.println("FFT Test Start 256");
int tstart = millis();
for (int i=0; i<100; i++) { // do a few rounds
do {} while (!myFFT.available());
fv = 0;
for (int j=0; j<FBINS; j++) {
fv += myFFT.read(i);
}
SERPORT.println(fv);
}
int delta = millis()-tstart;
SERPORT.println(delta);
}
void loop() {}
Last edited: