Hello,
I did some searching but I was not able to find an answer to this question, so hopefully, I am not duplicating the question. I'm trying to use ADC Stereo input with the 256 pt FFT from the audio library on a Teensy 4.1. My drawing from the Audio Library tool looks like the following:
I have the audio going through the recommended hardware from the library to shift the voltage to the input levels required for the ADC. I then am sending the same signal to A2 and A3 (for now, eventually, I will use the actual stereo input but I'm just debugging at this point).
The issue is that the code below does not function. I get from the serial interface the "FFT Test" text, but then no output from the FFT since the FFT is not available. If I change the MONO to 1, and use just a single ADC input the code works fine and I get results and the proper frequencies are showing in the correct bins. The same is true if I use A3 instead of the default A2 in the mono case. Looking for any thoughts would I could be missing on why the stereo input does not work. Below is the code I am using. Appreciate your time.
-Kevin
I did some searching but I was not able to find an answer to this question, so hopefully, I am not duplicating the question. I'm trying to use ADC Stereo input with the 256 pt FFT from the audio library on a Teensy 4.1. My drawing from the Audio Library tool looks like the following:
I have the audio going through the recommended hardware from the library to shift the voltage to the input levels required for the ADC. I then am sending the same signal to A2 and A3 (for now, eventually, I will use the actual stereo input but I'm just debugging at this point).
The issue is that the code below does not function. I get from the serial interface the "FFT Test" text, but then no output from the FFT since the FFT is not available. If I change the MONO to 1, and use just a single ADC input the code works fine and I get results and the proper frequencies are showing in the correct bins. The same is true if I use A3 instead of the default A2 in the mono case. Looking for any thoughts would I could be missing on why the stereo input does not work. Below is the code I am using. Appreciate your time.
-Kevin
Code:
/********************************************************************
* Includes *
********************************************************************/
/* Arduino Libaries */
#include <Audio.h>
#define MONO 0
#if (MONO == 1)
// GUItool: begin automatically generated code
AudioInputAnalog adc1; //xy=301,309
AudioMixer4 mixer1; //xy=455,333
AudioOutputI2S2 i2s2_1; //xy=627,424
AudioAnalyzeFFT256 fft256_1; //xy=636,362
AudioConnection patchCord1(adc1, 0, mixer1, 0);
AudioConnection patchCord2(mixer1, fft256_1);
AudioConnection patchCord3(mixer1, 0, i2s2_1, 0);
AudioConnection patchCord4(mixer1, 0, i2s2_1, 1);
// GUItool: end automatically generated code
#else
// GUItool: begin automatically generated code
AudioInputAnalogStereo adcs1; //xy=223,320
AudioMixer4 mixer1; //xy=455,333
AudioOutputI2S2 i2s2_1; //xy=634,404
AudioAnalyzeFFT256 fft256_1; //xy=636,362
AudioConnection patchCord1(adcs1, 0, mixer1, 0);
AudioConnection patchCord2(adcs1, 1, mixer1, 1);
AudioConnection patchCord3(mixer1, fft256_1);
AudioConnection patchCord4(mixer1, 0, i2s2_1, 0);
AudioConnection patchCord5(mixer1, 0, i2s2_1, 1);
// GUItool: end automatically generated code
#endif
const int ledPin = LED_BUILTIN;
int ledState = LOW;
IntervalTimer myTimer;
void setup(void)
{
system_StartupSequence();
AudioMemory(60);
mixer1.gain(0, 1.0);
mixer1.gain(1, 1.0);
myTimer.begin(blinkLED, 500000);
pinMode(ledPin, OUTPUT);
while (!Serial) ; // wait for Arduino Serial Monitor
Serial.println("FFT test");
}
void loop(void)
{
if (fft256_1.available()) {
for (int i=0; i < 40; i++) { // print the first 20 bins
Serial.print(fft256_1.read(i), 3);
Serial.print(" ");
}
Serial.println();
}
}
void blinkLED() {
if (ledState == LOW){
ledState = HIGH;
} else {
ledState = LOW;
}
digitalWrite(ledPin, ledState);
}