Arduino Nano, FFT library to process 3.5mm jack input

Hello,
I currently have the following schematic http://forum.arduino.cc/index.php?action=dlattach;topic=121540.0;attach=34854 working very well. With analogRead() I receive values 0-1023, works great.

What I am now trying to do is use the FFT library to process the signal.

I am using this person's code - Arduino-Sampling/fft_log_fast.ino at master · atuline/Arduino-Sampling · GitHub

I found that this variable

int tmp = qsuba(fft_log_out[2*i+2], noiseval);

is always 0. This leads me to believe that I am not receiving any signal, which seems weird. I am using A5.
What's the deal here?
Am I not providing the signal correctly? Does this only work with microphone (doesn't sound logical)?

Stoil:
I found that this variable

int tmp = qsuba(fft_log_out[2*i+2], noiseval);

is always 0. This leads me to believe that I am not receiving any signal, which seems weird. I am using A5.
What’s the deal here?
Am I not providing the signal correctly? Does this only work with microphone (doesn’t sound logical)?

You have a reasonable hypothesis in “I am not receiving any signal”, so print the signal data input buffer to the serial port immediately after collecting a sample and display it on the Arduino IDE serial plotter. If it doesn’t looks like signal then work back upstream in your signal collect software/hardware setup to see where it’s gone wrong and if there is something that looks like signal work downstream to the display function.

That code is in the custom display routine. Check that the actual fft results are meaningful - perhaps reduce FFT_N to 16 and print out the fft results to Serial.

...I've never used FFT.

is always 0. This leads me to believe that I am not receiving any signal, which seems weird. I am using A5.

But you said analogRead() was showing a signal...

If you're not doing so already, try a constant test tone (sine wave) at a known frequency. If you don't already have an easy way of doing that, [u]Audacity[/u] can generate sine waves that you can play on your computer.

DVDdoug:
…I’ve never used FFT.
But you said analogRead() was showing a signal…

If you’re not doing so already, try a constant test tone (sine wave) at a known frequency. If you don’t already have an easy way of doing that, [u]Audacity[/u] can generate sine waves that you can play on your computer.

@MarkT - Regardless if FFT_N is 16 or 256, this line:

fft_input[i] = ADC - DC_OFFSET;

returns 514 constantly. ADC is 1023.

@DVDDoug - analogRead works but this code doesn’t use analogRead. I tried with the test tones - doesn’t work, still the same results. I tried some tutorials out there but many of them use an unfamiliar to me way of addressing pins and I cannot understand how to adjust them to A5, since I’ve already built this on board.

edit: With this code I get all kinds of digits with the test tones, so again I think the problem is with the reading. I’d use this code if I also had the logic to light up the strips. I’ve only used the envelope follower circuit with single color strips:

#include "arduinoFFT.h"
 
#define SAMPLES 128             //Must be a power of 2
#define SAMPLING_FREQUENCY 1000 //Hz, must be less than 10000 due to ADC
 
arduinoFFT FFT = arduinoFFT();
 
unsigned int sampling_period_us;
unsigned long microseconds;
 
double vReal[SAMPLES];
double vImag[SAMPLES];
 
void setup() {
    Serial.begin(115200);
 
    sampling_period_us = round(1000000*(1.0/SAMPLING_FREQUENCY));
}
 
void loop() {
   
    /*SAMPLING*/
    for(int i=0; i<SAMPLES; i++)
    {
        microseconds = micros();    //Overflows after around 70 minutes!
     
        vReal[i] = analogRead(5);
        vImag[i] = 0;
     
        while(micros() < (microseconds + sampling_period_us)){
        }
    }
 
    /*FFT*/
    FFT.Windowing(vReal, SAMPLES, FFT_WIN_TYP_HAMMING, FFT_FORWARD);
    FFT.Compute(vReal, vImag, SAMPLES, FFT_FORWARD);
    FFT.ComplexToMagnitude(vReal, vImag, SAMPLES);
    double peak = FFT.MajorPeak(vReal, SAMPLES, SAMPLING_FREQUENCY);
 
    /*PRINT RESULTS*/
    //Serial.println(peak);     //Print out what frequency is the most dominant.
 
    for(int i=0; i<(SAMPLES/2); i++)
    {
        /*View all these three lines in serial terminal to see which frequencies has which amplitudes*/
         
        //Serial.print((i * 1.0 * SAMPLING_FREQUENCY) / SAMPLES, 1);
        //Serial.print(" ");
        Serial.println(vReal[i], 1);    //View only this line in serial plotter to visualize the bins
    }
 
    //delay(1000);  //Repeat the process every second OR:
   // while(1);       //Run code once
}

If I stop playing sounds on the PC, the Arduino (or maybe some of the components) start making WEIRD noises.

edit2: I started wondering - what type of circuit do I even need to do FFT? I’m currently using the 2.5v bias one and getting 512-1023 as values with analogRead().