uint8_t fftResult = nullptr;
um_data_t um_data;
if (usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
fftResult = (uint8_t*)um_data->u_data[8];
} else {
// add support for no audio data
}
if (!fftResult) return mode_static();
//static int previousBarHeight[64]; //array of previous bar heights per frequency band
if (SEGENV.call == 0) for (uint16_t i=0; i<cols; i++) previousBarHeight[i] = 0;
Please replace 2d_GEQ with this:
uint16_t WS2812FX::mode_2DGEQ(void) { // By Will Tatam. Code reduction by Ewoud Wijma. if (!isMatrix) return mode_static(); // not a 2D set-up
int NUMB_BANDS = map(SEGMENT.custom1, 0, 255, 1, 16);
const uint16_t cols = SEGMENT.virtualWidth(); const uint16_t rows = SEGMENT.virtualHeight(); const uint16_t dataSize = sizeof(CRGB) SEGMENT.width() SEGMENT.height(); // using width*height prevents reallocation if mirroring is enabled
if (!SEGENV.allocateData(dataSize + colssizeof(uint16_t))) return mode_static(); //allocation failed CRGB leds = reinterpret_cast<CRGB>(SEGENV.data); uint16_t previousBarHeight = reinterpret_cast<uint16_t*>(SEGENV.data + dataSize);
uint8_t fftResult = nullptr; um_data_t um_data; if (usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) { fftResult = (uint8_t*)um_data->u_data[8]; } else { // add support for no audio data } if (!fftResult) return mode_static();
//static int previousBarHeight[64]; //array of previous bar heights per frequency band if (SEGENV.call == 0) for (uint16_t i=0; i<cols; i++) previousBarHeight[i] = 0;
fadeToBlackBy(leds, 96+(SEGMENT.speed>>2));
bool rippleTime = false; if (millis() - SEGENV.step >= (256 - SEGMENT.intensity)) { SEGENV.step = millis(); rippleTime = true; }
uint16_t xCount = cols;
for (uint16_t x=0; x < xCount; x++) { uint8_t band = map(x, 0, xCount-1, 0, NUMB_BANDS - 1); uint16_t barHeight = map(fftResult[band], 0, 255, 0, rows); if (barHeight > previousBarHeight[x]) previousBarHeight[x] = barHeight; //drive the peak up
}
setPixels(leds); return FRAMETIME; } // mode_2DGEQ() static const char *_data_FX_MODE_2DGEQ PROGMEM = " ♫ 2D GEQ@Bar speed,Ripple decay,# of bands=255,Color bars=64;!,,Peak Color;!=11";