Crosstalk issue?

Status
Not open for further replies.

jarsh

New member
Hello all,

First off, thanks for the audio library. It's been a lot of fun to mess around with. However, there's something that I've come across that seems off and I was wondering if someone could help me out.

Hardware: Teensy 3.2 & 3.6 + Audioshield. Issue occurs on both Teensys.

I am trying to generate a sine wave to be output on the audio shield's line out while also taking data in from the onboard microphone to a AudioRecordQueue. The problem is, the AudioRecordQueue is seeing
the sine wave that I am generating even when no speakers are attached.

Simple diagram:
AudioSynthWaveformSine ---> AudioOutputI2S // The Sine data is getting into the audiorecord queue
AudioInputI2S ---> AudioRecordQueue

Am I doing something wrong with my code or is this a known hardware limitation? The magnitude of the detected signal is significantly smaller than when it is actually playing on a speaker, but still very easily visually identifiable and I need
to eliminate it as best I can for my project.

The attached code demonstrates the issue with just a teensy + audioshield and the arduino serial monitor/plotter. Every second or so you should see the output transition to a pretty obvious sine wave and then back to noise.
If you swap the comments around line 16 (it says where) then the issue goes away, perhaps because no data is being sent to the codec.

If there's anything I'm doing wrong or can do to try to mitigate this I would appreciate any advice! Thanks.

Code:
// The Short, Self Contained, Compilable Example
#include <Audio.h>

AudioInputI2S audioIn;
AudioOutputI2S audioOut;

AudioSynthWaveformSine sineGenerator;

// Incoming microphone/line in data goes here.
AudioRecordQueue inputQueue;
// Sine can go here or to audio out
AudioRecordQueue sineQueue;

// Comment out the next line and uncomment the one below it
// to see the change in behavior.
AudioConnection cord1(sineGenerator, 0, audioOut, 0);
//AudioConnection cord1(sineGenerator, 0, sineQueue, 0);
AudioConnection cord2(audioIn, 0, inputQueue, 0);

// Works for MIC as well, but LINEIN is less noisy when
// nothing is attached.
const int inputSource = AUDIO_INPUT_LINEIN;

AudioControlSGTL5000 audioShield;

unsigned long prevTime = millis();
bool play = false;

void setup() {

  // Fast serial
  Serial.begin(115200);
  delay(10);

  // Yuuuge amounts of memory
  AudioMemory(40);

  audioShield.enable();
  audioShield.inputSelect(inputSource);

  audioShield.volume(0.6);

  sineGenerator.amplitude(0.6);
  sineGenerator.frequency(8000);

  inputQueue.begin();
  sineQueue.begin();
  

}

void loop() {

  if (inputQueue.available()) {
    // Process our incoming data.
    int16_t* samples = inputQueue.readBuffer();

    // Spits out sample values for visualization in
    // serial plotter (or just look at magnitude in monitor)
    for (int i = 0; i < 128; i++) {
      Serial.println(samples[i]);
    }

    // Free our buffer at the end.
    inputQueue.freeBuffer();
  }

  // Just to keep queue happy
  if (sineQueue.available()) {
    sineQueue.readBuffer();
    sineQueue.freeBuffer();
  }

  // Turn signal on/off to make change apparent
  if (millis() - prevTime > 1000) {
    play = !play;
    play ? sineGenerator.amplitude(0.6) : sineGenerator.amplitude(0);
    prevTime = millis();
  }

}
 
The crosstalk it's worse if you overclock the teensy (3.1).
At 72MHz it's not bit deal, but at 96 and 120 some times it's very noticeable.
 
The issue still occurs at both 72mhz and 48mhz on the Teensy 3.2, and I keep the 3.6 on stock values as well. But thank you for giving me something else to try!

If anyone could do a quick test (it just requires the teensy and audioshield, nothing else fancy) I'd really appreciate it.
 
I've used your sketch and can see the crosstalk even at 48Mhz (teensy 3.1).
An rough calculation show that the audio leakage it's about 0.0018 in amplitude for a 0.6 sine.
I think the crosstalk it's there because some trace it's leaking to another trace, or even a trace to the SGTL5000 himself. Not because SGTL5000 internal leaking.
But for practical effects its really small, almost imperceptible on silence and impossible to notice with sound.
Overall I'm really happy with the price/quality and possibilities of the audio adaptor.
 
Awesome. Thank you for confirming that for me. There are ways I can work around that now that I know to expect it. The audio board is indeed a fantastic piece of hardware!

Thank you for your help Stendall, and thanks to Paul/PJRC for this hardware.
 
Status
Not open for further replies.
Back
Top