donfreenut
Member
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.
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();
}
}