From 76afab29a94dda1a3dac76cdd07c60f547a849af Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 21 Sep 2024 22:12:47 +0100 Subject: [PATCH 1/3] Quick experiment to expand frequency range --- wled00/FX.cpp | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/wled00/FX.cpp b/wled00/FX.cpp index 1fbc74e689..7d90d8a884 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -106,6 +106,27 @@ static um_data_t* getAudioData() { } return um_data; } + + +static uint8_t getMax(uint8_t* myArray) { + uint8_t maxV = 0; + for (int i = 0; i < (sizeof(myArray) / sizeof(myArray[0])); i++) { + maxV = max(myArray[i], maxV); + } + return maxV; +} + +static uint8_t* getSmallFFT(uint8_t* fftresult) { + static uint8_t data[3] = {0}; + uint8_t group1[5] = {fftresult[0], fftresult[1], fftresult[3], fftresult[4], fftresult[5] }; + data[0] = getMax(group1); + uint8_t group2[5] = {fftresult[6], fftresult[7], fftresult[8], fftresult[9], fftresult[10]}; + data[1] = getMax(group2); + uint8_t group3[5] = {fftresult[11], fftresult[12], fftresult[13], fftresult[14], fftresult[15]}; + data[2] = getMax(group3); + // USER_PRINTF("%u %u %u\n", data[0], data[1], data[2]); + return data; +} // effect functions /* @@ -7306,6 +7327,7 @@ uint16_t mode_DJLight(void) { // Written by Stefan Petrick, Ad um_data_t *um_data = getAudioData(); uint8_t *fftResult = (uint8_t*)um_data->u_data[2]; + uint8_t *fftSmall = getSmallFFT(fftResult); float volumeSmth = *(float*)um_data->u_data[0]; if (SEGENV.call == 0) { @@ -7319,8 +7341,11 @@ uint16_t mode_DJLight(void) { // Written by Stefan Petrick, Ad CRGB color = CRGB(0,0,0); // color = CRGB(fftResult[15]/2, fftResult[5]/2, fftResult[0]/2); // formula from 0.13.x (10Khz): R = 3880-5120, G=240-340, B=60-100 - if (!SEGENV.check1) { - color = CRGB(fftResult[12]/2, fftResult[3]/2, fftResult[1]/2); // formula for 0.14.x (22Khz): R = 3015-3704, G=216-301, B=86-129 + if (SEGENV.check1) { + color = CRGB(fftSmall[2]/2, fftSmall[1]/2, fftSmall[0]/2); + } + else if(true) { + color = CRGB(fftResult[15]/2, fftResult[5]/2, fftResult[0]/2); // formula from 0.13.x (10Khz): R = 3880-5120, G=240-340, B=60-100 } else { // candy factory: an attempt to get more colors color = CRGB(fftResult[11]/2 + fftResult[12]/4 + fftResult[14]/4, // red : 2412-3704 + 4479-7106 From dd4cf26c969afc6dfc20933e5dba0599bb5f369e Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 21 Sep 2024 22:42:22 +0100 Subject: [PATCH 2/3] Quick experiment to expand frequency range --- wled00/FX.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/wled00/FX.cpp b/wled00/FX.cpp index 7d90d8a884..3ef0fcbbd5 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -118,7 +118,7 @@ static uint8_t getMax(uint8_t* myArray) { static uint8_t* getSmallFFT(uint8_t* fftresult) { static uint8_t data[3] = {0}; - uint8_t group1[5] = {fftresult[0], fftresult[1], fftresult[3], fftresult[4], fftresult[5] }; + uint8_t group1[3] = {fftresult[0], fftresult[1], fftresult[2]}; data[0] = getMax(group1); uint8_t group2[5] = {fftresult[6], fftresult[7], fftresult[8], fftresult[9], fftresult[10]}; data[1] = getMax(group2); @@ -7342,10 +7342,10 @@ uint16_t mode_DJLight(void) { // Written by Stefan Petrick, Ad CRGB color = CRGB(0,0,0); // color = CRGB(fftResult[15]/2, fftResult[5]/2, fftResult[0]/2); // formula from 0.13.x (10Khz): R = 3880-5120, G=240-340, B=60-100 if (SEGENV.check1) { - color = CRGB(fftSmall[2]/2, fftSmall[1]/2, fftSmall[0]/2); + color = CRGB(fftSmall[2], fftSmall[1]/2, fftSmall[0]/3); } else if(true) { - color = CRGB(fftResult[15]/2, fftResult[5]/2, fftResult[0]/2); // formula from 0.13.x (10Khz): R = 3880-5120, G=240-340, B=60-100 + color = CRGB(fftResult[15], fftResult[5]/2, fftResult[0]/2); // formula from 0.13.x (10Khz): R = 3880-5120, G=240-340, B=60-100 } else { // candy factory: an attempt to get more colors color = CRGB(fftResult[11]/2 + fftResult[12]/4 + fftResult[14]/4, // red : 2412-3704 + 4479-7106 @@ -7365,11 +7365,11 @@ uint16_t mode_DJLight(void) { // Written by Stefan Petrick, Ad if (color.getLuma() > 32) { // don't change "dark" pixels CHSV hsvColor = rgb2hsv_approximate(color); hsvColor.v = min(max(hsvColor.v, (uint8_t)48), (uint8_t)204); // 48 < brightness < 204 - if (SEGENV.check1) - hsvColor.s = max(hsvColor.s, (uint8_t)204); // candy factory mode: strongly turn up color saturation (> 192) - else + // if (SEGENV.check1) + // hsvColor.s = max(hsvColor.s, (uint8_t)204); // candy factory mode: strongly turn up color saturation (> 192) + // else hsvColor.s = max(hsvColor.s, (uint8_t)108); // normal mode: turn up color saturation to avoid pastels - color = hsvColor; + // color = hsvColor; } //if (color.getLuma() > 12) color.maximizeBrightness(); // for testing From 58d79faec667c6a3c07b8d6e17fc09acd1bf9c88 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Wed, 2 Oct 2024 19:19:12 +0100 Subject: [PATCH 3/3] smallFFT updates and DJLight settings --- wled00/FX.cpp | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/wled00/FX.cpp b/wled00/FX.cpp index 3ef0fcbbd5..30f3e66c14 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -108,22 +108,33 @@ static um_data_t* getAudioData() { } -static uint8_t getMax(uint8_t* myArray) { +static uint8_t getMax(uint8_t* myArray, int arraySize) { uint8_t maxV = 0; - for (int i = 0; i < (sizeof(myArray) / sizeof(myArray[0])); i++) { + for (int i = 0; i < arraySize; i++) { maxV = max(myArray[i], maxV); } return maxV; } +static uint8_t decayValue(uint8_t last, uint8_t newValue) { + if(last == 0 || SEGMENT.check2 == false) { + return newValue; + } + return max((uint8_t) (last * 0.8), newValue); +} + static uint8_t* getSmallFFT(uint8_t* fftresult) { static uint8_t data[3] = {0}; - uint8_t group1[3] = {fftresult[0], fftresult[1], fftresult[2]}; - data[0] = getMax(group1); - uint8_t group2[5] = {fftresult[6], fftresult[7], fftresult[8], fftresult[9], fftresult[10]}; - data[1] = getMax(group2); - uint8_t group3[5] = {fftresult[11], fftresult[12], fftresult[13], fftresult[14], fftresult[15]}; - data[2] = getMax(group3); + + uint8_t group1[3] = {fftresult[0], fftresult[1]/2, fftresult[2]/2}; + data[0] = decayValue(data[0], getMax(group1, 3)); + + uint8_t group2[3] = {fftresult[4]/2, fftresult[5], fftresult[6]/6}; + data[1] = decayValue(data[1], getMax(group2, 3)); + + uint8_t group3[3] = {fftresult[13]/2, fftresult[14], fftresult[15]/2}; + data[2] = decayValue(data[2], getMax(group3, 5)); + // USER_PRINTF("%u %u %u\n", data[0], data[1], data[2]); return data; } @@ -7342,7 +7353,7 @@ uint16_t mode_DJLight(void) { // Written by Stefan Petrick, Ad CRGB color = CRGB(0,0,0); // color = CRGB(fftResult[15]/2, fftResult[5]/2, fftResult[0]/2); // formula from 0.13.x (10Khz): R = 3880-5120, G=240-340, B=60-100 if (SEGENV.check1) { - color = CRGB(fftSmall[2], fftSmall[1]/2, fftSmall[0]/3); + color = CRGB(fftSmall[2]/2, fftSmall[1]/2, fftSmall[0]/3); } else if(true) { color = CRGB(fftResult[15], fftResult[5]/2, fftResult[0]/2); // formula from 0.13.x (10Khz): R = 3880-5120, G=240-340, B=60-100 @@ -7385,7 +7396,7 @@ uint16_t mode_DJLight(void) { // Written by Stefan Petrick, Ad return FRAMETIME; } // mode_DJLight() -static const char _data_FX_MODE_DJLIGHT[] PROGMEM = "DJ Light@Speed,,,,,Candy Factory;;;01f;m12=2,si=0"; // Arc, Beatsin +static const char _data_FX_MODE_DJLIGHT[] PROGMEM = "DJ Light@Speed,,,,,Small FFT,Decay;;;01f;m12=2,si=0"; // Arc, Beatsin ////////////////////