Hey sorry to bother I am unable to read data from the left and right line-in at the same time.
I am using Teensy 4.0 with the Audio Board Rev D.
I have checked my (3.5mm jack) out with an oscilloscope and seems like the correct sinewaves are showing up, also the code works for the left channel if patchcord1 is set to pin 0 and patchcord2 is set to 0 I am able to get readings on the left side if patchcord1 is set to pin 1 and patchcord2 is set to I can read right side but I cannot read both when I have patchcord1 set to 0 and patchcord2 set to 1 or patchcord1 set to 1 and patchcord2 set to 0.
I am pretty sure my connections are correct and of course, I do have a ground.
I know the issue might be with me setting up stuff incorrectly but I am unable to fix the issue even after hours of looking at the Forum/GitHub/Sketches, so I hope you do not mind me asking here.
Thanks for any guidance or links to a post where this is resolved!
I am using Teensy 4.0 with the Audio Board Rev D.
I have checked my (3.5mm jack) out with an oscilloscope and seems like the correct sinewaves are showing up, also the code works for the left channel if patchcord1 is set to pin 0 and patchcord2 is set to 0 I am able to get readings on the left side if patchcord1 is set to pin 1 and patchcord2 is set to I can read right side but I cannot read both when I have patchcord1 set to 0 and patchcord2 set to 1 or patchcord1 set to 1 and patchcord2 set to 0.
I am pretty sure my connections are correct and of course, I do have a ground.
I know the issue might be with me setting up stuff incorrectly but I am unable to fix the issue even after hours of looking at the Forum/GitHub/Sketches, so I hope you do not mind me asking here.
Thanks for any guidance or links to a post where this is resolved!
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
#include <FastLED.h>
#include <deque>
//const int myInput = AUDIO_INPUT_MIC;
const int myInput = AUDIO_INPUT_LINEIN;
// Create the Audio components. These should be created in the
// order data flows, inputs/sources -> processing -> outputs
//
AudioInputI2S audioInput;
AudioSynthWaveformSine sinewave;
AudioAnalyzeFFT1024 fftLeft;
AudioAnalyzeFFT1024 fftRight;
AudioOutputI2S audioOutput; // audio shield: headphones & line-out
AudioConnection patchCord1(audioInput, 0, fftLeft, 0);
AudioConnection patchCord2(audioInput, 1, fftRight, 0);
//AudioConnection patchCord1(sinewave, 0, myFFT, 0);
AudioControlSGTL5000 audioShield;
void setup() {
AudioMemory(12);
audioShield.enable();
audioShield.inputSelect(myInput);
audioShield.lineInLevel(0,0);
//audioShield.volume(0.5);
audioShield.micGain(0);
//myFFT.begin(true);
//myFFT1.begin(true);
fftLeft.windowFunction(AudioWindowHanning1024);
fftRight.windowFunction(AudioWindowHanning1024);
sinewave.amplitude(0.8);
sinewave.frequency(1034.007);
Serial.begin(115200);
}
void loop() {
float n;
int i;
if (fftLeft.available()) {
float left_subbass = 0, left_bass = 0, left_midrange = 0, left_highfreq = 0, left_presence = 0, left_brilliance = 0;
float right_subbass = 0, right_bass = 0, right_midrange = 0, right_highfreq = 0, right_presence = 0, right_brilliance = 0;
for (i=0; i<512; i++) {
float left_n = fftLeft.read(i);
float right_n = fftRight.read(i);
if (i >= 0 && i <=6) {
left_subbass += left_n;
right_subbass += right_n;
}
else if (i >= 6 && i <= 20) {
left_bass += left_n;
right_bass += right_n;
}
else if (i >= 20 && i <= 40) {
left_midrange += left_n;
right_midrange += right_n;
}
else if (i >= 40 && i <= 180) {
left_highfreq += left_n;
right_highfreq += right_n;
}
else if (i >= 180 && i <= 277) {
left_presence += left_n;
right_presence += right_n;
}
else if (i >= 278 && i <= 512) {
left_brilliance += left_n;
right_brilliance += right_n;
}
}
Serial.print("Left: ");
Serial.print(left_subbass);
Serial.print(",");
Serial.print(left_bass);
Serial.print(",");
Serial.print(left_midrange);
Serial.print(",");
Serial.print(left_highfreq);
Serial.print(",");
Serial.print(left_presence);
Serial.print(",");
Serial.print(left_brilliance);
Serial.print(", ");
Serial.print("Right: ");
Serial.print(right_subbass);
Serial.print(",");
Serial.print(right_bass);
Serial.print(",");
Serial.print(right_midrange);
Serial.print(",");
Serial.print(right_highfreq);
Serial.print(",");
Serial.print(right_presence);
Serial.print(",");
Serial.print(right_brilliance);
Serial.println(",");
}
}
Last edited: