FFT available blocking?
Question about the FFT library: is there anything (other than FIFO not ready) that would cause it to block? I'm observing the following behavior:
1) Using:
Code:
// Create Audio components
AudioInputI2Sslave audioInput;
AudioAnalyzeFFT256 myFFT(20);
AudioAnalyzePrint myprint("i2s");
AudioOutputI2Sslave audioOutput;
// Create Audio connections between components
AudioConnection c1(audioInput, 0, audioOutput, 0);
AudioConnection c2(audioInput, 0, myFFT, 0);
AudioConnection c3(audioInput, 1, audioOutput, 1);
AudioConnection c4(audioInput, 0, myprint, 0);
2) Using AudioAnalyzePrint:
Code:
Serial.println("Start sine test");
musicPlayer.sineTest(100, 1);
myprint.length(20);
uint32_t count = 0;
while (1) {
Serial.print("Count: 0x"); Serial.println(count, HEX);
count++;
myprint.trigger();
delay(1000);
}
Results:
Count: 0x2
trigger i2s
-2549
-2481
-2393
-2286
-2160
-2016
-1857
-1682
-1493
-1292
-1081
-861
-635
-402
-167
70
307
540
769
992
3) Using FFT:
Code:
Serial.println("Start sine test");
musicPlayer.sineTest(100, 1);
while (1) {
if (myFFT.available()) {
Serial.print("FFT: ");
for (int i=0; i<12; i++) {
Serial.print(myFFT.output[i]);
Serial.print(",");
}
Serial.println();
}
}
results:
Start sine test
FFT: 0,0,0,0,0,0,0,0,0,0,0,0,
So, the i2s FIFO is getting data, but the FFT is blocking. What's really interesting is if I change the sine test to an actual muisc file, the FFT magically unblocks:
Code:
while (1) {
if (musicPlayer.stopped()) {
Serial.println("Start playing music");
musicPlayer.startPlayingFile("AND_YO~1.MP3");
Serial.println("kickoff done");
} else {
if (myFFT.available()) {
Serial.print("FFT: ");
for (int i=0; i<12; i++) {
Serial.print(myFFT.output[i]);
Serial.print(",");
}
Serial.println();
}
}
}
Results:
Start playing music
kickoff done
FFT: 0,0,0,0,0,0,0,0,0,0,0,0,
FFT: 0,0,0,0,0,0,0,0,0,0,0,0,
FFT: 0,0,0,0,0,0,0,0,0,0,0,0,
FFT: 0,0,0,0,0,0,0,0,0,0,0,0,
FFT: 0,0,0,0,0,0,0,0,0,0,0,0,
FFT: 0,0,0,0,0,0,0,0,0,0,0,0,
FFT: 0,0,0,0,0,0,0,0,0,0,0,0,
FFT: 0,0,0,0,0,0,0,0,0,0,0,0,
FFT: 0,0,0,0,0,0,0,0,0,0,0,0,
FFT: 0,0,0,0,0,0,0,0,0,0,0,0,
FFT: 0,0,0,0,0,0,0,0,0,0,0,0,
FFT: 0,0,0,0,0,0,0,0,0,0,0,0,
FFT: 0,0,0,0,0,0,0,0,0,0,0,0,
FFT: 0,0,0,0,0,0,0,0,0,0,0,0,
FFT: 27,133,61,0,0,0,0,0,0,0,0,0,
FFT: 21,60,9,0,0,0,0,0,0,0,0,0,
FFT: 0,0,0,0,0,0,0,0,0,0,0,0,
The music clip starts silently. Here are some later results:
FFT: 330,239,183,234,96,77,42,134,99,63,9,36,
FFT: 329,239,271,319,159,118,176,206,111,36,43,58,
FFT: 378,305,265,232,91,99,165,204,9,81,27,0,
FFT: 389,314,160,152,63,88,160,198,39,9,0,0,
FFT: 401,343,114,165,102,82,171,229,78,30,9,0,
FFT: 331,294,203,201,118,78,124,121,0,0,0,0,
FFT: 241,202,174,189,95,58,96,164,70,45,9,0,
FFT: 217,231,210,199,94,58,119,81,9,0,0,0,
Background info: Using a VS1033 to decode MP3 files from an SD card. Modified Adafruit library used to play the MP3 files with VS1033 I2S output enabled. Eventual goal is to drive a strip of WS2811s with musical spectrum. (FFT may be overkill here - thinking about a 16 band filter bank instead...)