Arduino FFT for audio spectrum analyzer

I try Audio Spectrum Analyzer Matrix 8x8x4 leds, but I have a problem ):

#include <rduinoFFT.h>
#include <MD_MAX72xx.h>

// Number of samples for FFT. Should be a power of 2.
const uint16_t samples = 64;  
uint16_t k = 0;
double vReal[samples];
double vImag[samples];
double ganancia = 0.1;

#define HARDWARE_TYPE MD_MAX72XX::PAROLA_HW
#define MAX_DEVICES  4

// Define pins for SPI
#define CLK_PIN   13  // or SCK
#define DATA_PIN  11  // or MOSI
#define CS_PIN    10  // or SS

ArduinoFFT FFT = ArduinoFFT();

// SPI hardware interface
MD_MAX72XX mx = MD_MAX72XX(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);

// We always wait a bit between updates of the display
#define DELAYTIME  100  // in milliseconds

void setup() {
    Serial.begin(115200);
    mx.begin();
    mx.clear();
}

void loop() {
    for (int i = 0; i < samples; i++) {
       vReal[i] = analogRead(A0) * ganancia;
       vImag[i] = 0;
       Serial.println(vReal[i]);
    }

    // Perform FFT
    FFT.Windowing(vReal, samples, FFT_WIN_TYP_RECTANGLE, FFT_FORWARD);
    FFT.Compute(vReal, vImag, samples, FFT_FORWARD);
    FFT.ComplexToMagnitude(vReal, vImag, samples);

    // Display the FFT results
    LedColumn(1, 0);
    LedColumn(9, 1);
    LedColumn(17, 2);
    LedColumn(25, 3);

    delay(DELAYTIME);
}

// Function to display the FFT results on the LED matrix
void LedColumn(int Fi, int Ci) {
    for (int i = Fi; i < Fi + 8; i++) {
        if (vReal[i] > 100) {
            mx.setColumn(Ci, B11111111);
        } else if (vReal[i] > 90) {
            mx.setColumn(Ci, B01111111);
        } else if (vReal[i] > 80) {
            mx.setColumn(Ci, B11111100);
        } else if (vReal[i] > 60) {
            mx.setColumn(Ci, B11111000);
        } else if (vReal[i] > 50) {
            mx.setColumn(Ci, B11110000);
        } else if (vReal[i] > 40) {
            mx.setColumn(Ci, B11100000);
        } else if (vReal[i] > 30) {
            mx.setColumn(Ci, B11000000);
        } else if (vReal[i] > 15) {
            mx.setColumn(Ci, B10000000);
        } else {
            mx.setColumn(Ci, B00000000);
        }
        Ci++;
    }
}

My error is: exit status 1

Compilation error: cannot deduce template arguments for 'ArduinoFFT<...auto...>' from '()'

And your first problem is where you posted this question.

You should never post in the Uncategorised section.
It says so in the description of the section. Therefore I have moved your post here.

You might want to look at this How to get the best out of this forum before you proceed any further.
We only know what you tell us, and without knowing what you have, we don't stand a chance.

A minimum requirement is your code, well done for posting this correctly. Also we need to see a schematic, this is missing.

In which case we need to see the error message reported back in the IDE window. Just copy it and past it like you would past code.

1 Like

You should select "verbose" output for compiler messages, if you haven't already set this.

Could it be that you have a spelling mistake with this decleration?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.