Issues with FFT functions?

What should happen: Using arduinoFFT, serial should print out data computed from microphone sensor. Using Adafruit_Neopixel, light strip should illuminate based on colorWipe function.

What is happening: (1): only the serial data is printed, light strip does not illuminate. OR (2): if I remove FFT.Compute and FFT.ComplexToMagnitude functions from code below, serial prints data (incorrect data b/c of removed functions) and lights illuminate properly.

I can’t seem to figure out why FFT.Compute and FFT.ComplexToMagnitude seems to prevent the light strip from illuminating properly. Without those two lines, the lights work as expected. Any guidance appreciated.

Full code below:

#include <arduinoFFT.h>
#include <Adafruit_NeoPixel.h>
#define SAMPLES 128

#define PIN 6
#define NUMPIXELS 300

int delayval = 500;

Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

arduinoFFT FFT = arduinoFFT();
unsigned int sampling_period_us;
unsigned long microseconds;
double vReal[SAMPLES];
double vImag[SAMPLES];
void setup() {
    sampling_period_us = round(1000000*(1.0/SAMPLING_FREQUENCY));

void loop() {  

    colorWipe(strip.Color(255, 255, 255));

    for(int i=0; i<SAMPLES; i++) {
        microseconds = micros();
        vReal[i] = analogRead(0);
        vImag[i] = 0;

        while(micros() < (microseconds + sampling_period_us)){

    FFT.Compute(vReal, vImag, SAMPLES, FFT_FORWARD);
    FFT.ComplexToMagnitude(vReal, vImag, SAMPLES);
    double peak = FFT.MajorPeak(vReal, SAMPLES, SAMPLING_FREQUENCY);

    for(int i=0; i<(SAMPLES/2); i++) {
        Serial.println(vReal[i], 1);


void colorWipe(uint32_t c) {
    for(uint16_t i=0; i<strip.numPixels(); i++) {
        strip.setPixelColor(i, c);;

900 bytes for frame.buffer.

128 samples and 2 4 byte doubles per sample means 1024 bytes for that.

Add in the serial buffer and other variables, and on a 2048-byte ram board based on 328p, you're out of ram. This will result in the dynamically allocated frame buffer mot being allocated and the neopixels not workibg.

It works without those functions, I think, because the compiler is optimizing our one or both of those sample buffera.