Teensy 3.1: Audio library only working when Audio Adapter Board is present?

Status
Not open for further replies.

PaulS

Well-known member
I'm trying to get the audio libary to work on a Teensy 3.1. I didn't buy the Audio Adapter Board [yet].
Started off with a basic program that reads the ADC port and outputs a 1024 FFT to the serial port.
Here is the code:
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>

// GUItool: begin automatically generated code
AudioInputAnalog         adc1;
AudioAnalyzeFFT1024      fft1024_1;
AudioConnection          patchCord1(adc1, fft1024_1);
// GUItool: end automatically generated code

void setup() {
  Serial.begin(115200);
  while (!Serial) {
    ; // wait for serial port to connect.
  }
  delay(1000);
  Serial.println("Serial port connected");
  pinMode(13, OUTPUT);
  digitalWrite(13, HIGH);
  
  AudioMemory(12);
  fft1024_1.windowFunction(AudioWindowHanning1024);
}

void loop() {
  float n;
  int i;
  Serial.println("in the loop");

  if (fft1024_1.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 = fft1024_1.read(i);
      if (n >= 0.01) {
        Serial.print(n);
        Serial.print(" ");
      } else {
        Serial.print("  -  "); // don't print "0.00"
      }
    }
    Serial.println();
  }
}

Compiling and downloading went OK, serial monitor is fine and a continuous "in the loop" is printed, but no FFT values are displayed.
It seems the fft1024_1.available() never becomes true. I tested analog port A2 with a simple analogRead(2) and it's working fine.

Any ideas? Am I overlooking the obvious?

Using Arduino 1.6.3, Teensy Loader 1.22, Teensy Audio Library 1.02.

Thanks for your help upfront,
Paul
 
Last edited:
Some more info on the problem that I still did not solve...
Below is a screenshot of the sketch instead of the code snippet above.
I noticed that #include <Audio.h> and #include <Wire.h> are not BOLD while #include <SPI.h> and #include <SD.h> actually are; does that mean something?
TeensyFFT.jpg
Any help is much appreciated since I'm kind of stuck!
Paul
 
Hi Paul,

Thanks a lot for your reply: setting the clock to 96Mhz optimized (overclock) did the trick!
Another question: "optimized" means optimized for speed, not optimized for code size, correct?

Regards,
Paul

PS: I tried to search the forum but the Advanced Search function seems to be broken - I posted a message about this last night.
 
Status
Not open for further replies.
Back
Top