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

Thread: FFT from live sound

  1. #1
    Junior Member
    Join Date
    Feb 2020
    Posts
    2

    FFT from live sound

    Hello,

    I'm trying to perform an FFT on sound from line-in. So I'm combining the Mic Check and FFT sketches from the tutorial.

    If I comment out everything having to do with the FFT, the sketch works perfectly - I can hear sound coming out of the speaker.
    But as soon as I add the FFT code, nothing happens - no sound comes out of the speaker and the serial monitor is blank.

    I know I'm doing something silly but I can't find it. Thanks in advance!

    Click image for larger version. 

Name:	audiotool.PNG 
Views:	2 
Size:	14.5 KB 
ID:	18954


    Code:
    #include <Audio.h>
    #include <Wire.h>
    #include <SPI.h>
    #include <SD.h>
    #include <SerialFlash.h>
    
    // GUItool: begin automatically generated code
    AudioInputI2S            i2s1;           //xy=214,234.00000190734863
    AudioAnalyzeFFT1024      fft1024_1;      //xy=424,264
    AudioOutputI2S           i2s2;           //xy=441.0000114440918,221.00000190734863
    AudioConnection          patchCord1(i2s1, 0, i2s2, 0);
    AudioConnection          patchCord2(i2s1, 0, i2s2, 1);
    AudioConnection          patchCord3(i2s1, 0, fft1024_1, 0);
    AudioControlSGTL5000     sgtl5000_1;     //xy=499,356
    // GUItool: end automatically generated code
    
    
    void setup() {
      Serial.begin(9600);
      AudioMemory(8);
      sgtl5000_1.enable();
      sgtl5000_1.volume(0.5);
      sgtl5000_1.inputSelect(AUDIO_INPUT_LINEIN);
      sgtl5000_1.lineInLevel(5,5);
      delay(1000);
    }
    
    void loop() {
      if (fft1024_1.available()) {
        for (int i=0; i<30; i++) {  // 0-25  -->  DC to 1.25 kHz
          float n = fft1024_1.read(i);
          printNumber(n); 
        }
        Serial.println();
      }
      
       
    }
    
    void printNumber(float n) {
      Serial.print(n, 3);
      Serial.print(" ");
    }

  2. #2
    Junior Member
    Join Date
    Mar 2017
    Location
    Australia
    Posts
    11
    I haven't got the hardware to test myself at the moment but only AudioMemory(8) is jumping out at me. Try something higher like AudioMemory(20).

    If it is a memory type issue, maybe check out Examples > audio > MemoryAndCpuUsage
    What Teensy board and CPU speed are you using?

  3. #3
    Junior Member
    Join Date
    Feb 2020
    Posts
    2

    Red face

    Quote Originally Posted by LachAus View Post
    I haven't got the hardware to test myself at the moment but only AudioMemory(8) is jumping out at me. Try something higher like AudioMemory(20).
    Bingo thank you!

Posting Permissions

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