Apply FFT on a Real Time signal

Hi everyone, I'm trying to do a Timegrapher and I want to analyse the output samples[n].
I'm trying to apply the FFT on the output before printing it, without success. Any help will be welcome.
Thanks in advance.

#include <SPI.h>    
#define SS 5   

int16_t* samples;
uint32_t n = 0;
int count = 0;
unsigned long start_time;
unsigned long end_time;
const unsigned long event = 10000;
const uint32_t max_samples=50000;

void setup() {
  Serial.begin(115200);                     /* initialization of serial communication */
  SPI.begin();                            /* initialization of SPI port */
  SPI.setDataMode(SPI_MODE0);             /* configuration of SPI communication in mode 0 */
  SPI.setClockDivider(SPI_CLOCK_DIV64);   /* configuration of clock at 1MHz */
  pinMode(SS, OUTPUT);
  Serial.println("Start");
  
  samples = (int16_t*)malloc(sizeof(int16_t)*max_samples);
  if(samples == NULL){
      Serial.print("insufficient memory");
    }
    else{
      Serial.print("malloc ok.");   
    }
}

void loop() {
  start_time = millis();
  for (n=0; n<max_samples; n++)
  {
    samples[n] = Sound();
  }
  end_time = millis();
  Serial.print("Dauer [ms]: ");
  Serial.print((end_time-start_time));
  Serial.print(" ||| ");
  Serial.print("Beats: ");
  Serial.print(n);
  Serial.println(" ||| ");
  for (n = 0; n < max_samples; n++)
  {
    Serial.print(samples[n]);
    //Serial.print(",-35000,35000");
    Serial.println();
  }
}


int16_t Sound(void) {
  digitalWrite(SS, LOW);                                        //activate chip select
  int sound = SPI.transfer(0) | (SPI.transfer(0) << 8);         //reconstruct 12-bit data
  digitalWrite(SS, HIGH);                                       //deactivate chip select
  return sound;
}

Not in the posted code.

What is connected to the SPI pins?

the Mic, for real time input

Does the microphone input work as you expect?

What Arduino do you have? Most have very limited memory.

const uint32_t max_samples=50000;

yes the mic (Pmod MIC3) work as expected, I'm using ESP32

Try the Arduino_FFT library, starting with the library examples.

That's the point Remington, I really don't know how to use those examples on my case

The examples should run "out of the box". You collect some data, and transform it.

What is it that you don't understand?