Teensy 3.6 with Audio Board - audio out is clipping

Status
Not open for further replies.
Hi all,

I received my Teensy 3.6 and Audio Board today and I'm playing with the FFT. The audio out of my Bose speakers is clipping, and I don't know why. I am using the connections shown in the photo below, and my code is also below. My intent is to do the FFT while also hearing crisp audio out of my speakers.

In the photo, the blue cable is the USB cable connected to my computer to power the Teensy and the Audio Board. There is an iPad with a 3.5mm stereo splitter and silver and black aux cables. The silver cable goes to my Bose speaker, and the black cable goes to the Line In on the Audio Board. The iPad provides the audio.

I have a feeling that the audio clipping occurs because I'm mixing the stereo signal down to a mono signal, but I would like confirmation. And if that is the case, is there a way to FFT a mono signal while also outputting a stereo signal? Or is it okay to FFT a stereo signal or is that too much data for the Teensy to handle?

When I only have the iPad connected to the Bose speaker, the audio clipping does not occur. The audio clipping only occurs when I introduce the Teensy. And the FFT output works fine - it's just the clipping of the audio out of the speakers that is a problem.

Code:
// FFT Test
//
// Compute a 1024 point Fast Fourier Transform (spectrum analysis)
// on audio connected to the Left Line-In pin.  By changing code,
// a synthetic sine wave can be input instead.
//
// The first 40 (of 512) frequency analysis bins are printed to
// the Arduino Serial Monitor.  Viewing the raw data can help you
// understand how the FFT works and what results to expect when
// using the data to control LEDs, motors, or other fun things!
//
// This example code is in the public domain.

#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

const int myInput = AUDIO_INPUT_LINEIN;
//const int myInput = AUDIO_INPUT_MIC;

// GUItool: begin automatically generated code
AudioInputI2S            audioInput;           
AudioMixer4              mixer1;         
AudioOutputI2S           audioOutput;          
AudioAnalyzeFFT1024      myFFT;     
AudioConnection          patchCord1(audioInput, 0, mixer1, 0);
AudioConnection          patchCord2(audioInput, 1, mixer1, 1);
AudioConnection          patchCord3(mixer1, 0, audioOutput, 0);
AudioConnection          patchCord4(mixer1, 0, audioOutput, 1);
AudioConnection          patchCord5(mixer1, myFFT);
AudioControlSGTL5000     audioShield;    
// GUItool: end automatically generated code

void setup() {
  // Audio connections require memory to work.  For more
  // detailed information, see the MemoryAndCpuUsage example
  AudioMemory(12);

  // Enable the audio shield and set the output volume.
  audioShield.enable();
  audioShield.inputSelect(myInput);
  audioShield.volume(0.5);

  // Configure the window algorithm to use
  myFFT.windowFunction(AudioWindowHanning1024);
  //myFFT.windowFunction(NULL);

  // Create a synthetic sine wave, for testing
  // To use this, edit the connections above
  //sinewave.amplitude(0.8);
  //sinewave.frequency(1034.007);
}

void loop() {
  float n;
  int i;

  if (myFFT.available()) {
    // each time new FFT data is available
    // print it all to the Arduino Serial Monitor
    Serial.print("FFT: ");
    for (i=0; i<40; i++) {
      n = myFFT.read(i);
      if (n >= 0.024) {
        Serial.print(n);
        Serial.print(" ");
      } else {
        Serial.print("  -  "); // don't print "0.00"
      }
    }
    Serial.println();
  }
}

IMG_0788 (1).jpg

Capture.PNG
 
You've connected the speaker to the headphone-output.
Use line-out instead, and try without splitter first.
 
IMHO, Frank is right. The headphone output of the audio board risks to overdrive the Bose Speaker. Before plugging things together, you should meticulously study the data sheets of all involved and interconnected devices and make sure that you have the correct levels and impedances matched everywhere. And a good oscilloscope (not that cheap PC sound card stuff) is indispensable for this kind of engineering.
 
Oops! haha. I'll connect a breadboard-friendly 3.5mm plug to the nicely labeled "Line Out" through-holes on the Audio Board and try again. Thanks!
 
I just connected Line Out to my speakers as suggested, but the audio coming out of the speakers is still clipping. I am not understanding why the audio isn't crisp. This doesn't seem like a complicated way to connect.

Can someone please draw me a diagram, or specifically explain how to pass audio into the Teensy Audio Board and out to a set of speakers without clipping occurring? This particular exercise really doesn't seem like something complicated that would require an oscilloscope.

The speaker works absolutely fine. The clipping issue only happens when I plug the speaker into the Teensy Audio Board.

Here is how I have it connected now. The black cable is connected to Line Out with the other end of the black cable connected to my speakers. The blue "Auvio" cable is connected to the audio source, in this case an iPad. And the blue USB cable is connected to my computer to power the Teensy and the Audio Board. I am running the same code as posted in Comment #1.

IMG_0793.jpg
 
Last edited:
The blue "Auvio" cable is connected to the audio source
I don't understand how this works. The blue cable is connected to the headphone-output. It's not an input(?!) What are you doing ? Something is terribly wrong..

Remove that cable and modify your sketch to output a sine - just as a test. You shouldn't hear clipping if everything is OK.
 
Ahahahahahahaha!!!!! :D I was laughing so hard.

I didn't know that it's a headphone out. Ahahaha!!!

I re-wired it as shown below and it works perfectly. I'm running it now, and my FFT is running and I'm getting crisp audio out to my speakers.

I should have looked at the spec sheet first. :D :D

Thanks for your patience, and my apologies for all of the confusion.

IMG_0797.jpg
 
You might also be getting clipping on the software mixer. The channels default to 1.0 gain (signal pass through), so 2 signals mixed together with default gain could certainly have clipping in the mixer.

Best to configure the mixer channels for 0.5 gain.

This mixer clipping issue is covered in the tutorial, part 2-2 and 2-3.

https://www.pjrc.com/store/audio_tutorial_kit.html
 
Status
Not open for further replies.
Back
Top