Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 5 of 5

Thread: Adding AudioInputAnalog breask the project

  1. #1
    Junior Member
    Join Date
    Nov 2019
    Posts
    3

    Adding AudioInputAnalog breaks the project

    Hello!
    I'm a beginner with Teensy, so I've spent the night setting up a simple mic and analog input that I want to do FFT. I've tried all samples I can find that uses AudioInputAnalog, but it just won't compile if I select Teensy 4.0 as a board. If I select any other Teensy board it will, but then it won't upload to the Teensy (which, of course, is understandable).

    Is it me or something else?


    Here's what I'm trying to do:
    Code:
    #include <Audio.h>
    #include <Wire.h>
    #include <SPI.h>
    #include <SD.h>
    #include <SerialFlash.h>
    
    // GUItool: begin automatically generated code
    AudioInputAnalog         adc1;           //xy=122,68
    AudioAmplifier           amp1;           //xy=279,126
    AudioAnalyzeFFT1024      fft1024;      //xy=433,180
    AudioConnection          patchCord1(adc1, amp1);
    AudioConnection          patchCord2(amp1, fft1024);
    // GUItool: end automatically generated code
    
    //AudioInputAnalog adc1(A0);
    float level[16];
    
    void setup() {
      AudioMemory(12);
    }
    
    
    void loop() {
      if (fft1024.available()) {
        // read the 512 FFT frequencies into 16 levels
        // music is heard in octaves, but the FFT data
        // is linear, so for the higher octaves, read
        // many FFT bins together.
        level[0] =  fft1024.read(0);
        level[1] =  fft1024.read(1);
        level[2] =  fft1024.read(2, 3);
        level[3] =  fft1024.read(4, 6);
        level[4] =  fft1024.read(7, 10);
        level[5] =  fft1024.read(11, 15);
        level[6] =  fft1024.read(16, 22);
        level[7] =  fft1024.read(23, 32);
        level[8] =  fft1024.read(33, 46);
        level[9] =  fft1024.read(47, 66);
        level[10] = fft1024.read(67, 93);
        level[11] = fft1024.read(94, 131);
        level[12] = fft1024.read(132, 184);
        level[13] = fft1024.read(185, 257);
        level[14] = fft1024.read(258, 359);
        level[15] = fft1024.read(360, 511);
        // See this conversation to change this to more or less than 16 log-scaled bands?
        // https://forum.pjrc.com/threads/32677-Is-there-a-logarithmic-function-for-FFT-bin-selection-for-any-given-of-bands
    
    
        for (int i = 0; i < 16; i++) {
          Serial.print(level[i]);
    
          //Serial.print(shown[i]);
          Serial.print(" ");
        }
        Serial.print(" cpu:");
        Serial.println(AudioProcessorUsageMax());
      }
    }
    Last edited by Moskus; 11-06-2019 at 09:59 PM.

  2. #2
    Same here.

  3. #3
    Junior Member
    Join Date
    Nov 2019
    Posts
    3
    ... anyone?

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,808
    AudioInputAnalog is not yet supported on Teensy 4.0.

    It will be at some point in the future, but with the missing USB types at a higher priority, it may be several weeks until this gets serious engineering time. I know that timeframe isn't great news, but hopefully an honest answer is better than not knowing?

  5. #5
    Junior Member
    Join Date
    Nov 2019
    Posts
    3
    I really appreciate your honesty, even if it wasn't the answer I was hoping for.

    It cost me another $20+ as I bought a Teensy 3.6 so I can continue codingwhile you hopefully fix the 4.0 compatibility issues... But I guess that's good new for you.
    It's not a problem, I'll live with it. And the good news is that I will be able to use the Teensy 4.0 sometime in the future.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •