Merge pull request #16 from netmindz/audio-palette-updates

Audio palette updates
This commit is contained in:
netmindz
2023-04-14 18:38:06 +01:00
committed by GitHub
4 changed files with 16 additions and 8 deletions

View File

@@ -256,7 +256,7 @@ CRGBPalette16 &Segment::loadPalette(CRGBPalette16 &targetPalette, uint8_t pal) {
targetPalette[i].b = prevRandomPalette[i].b*(5000-timeSinceLastChange)/5000 + randomPalette[i].b*timeSinceLastChange/5000; targetPalette[i].b = prevRandomPalette[i].b*(5000-timeSinceLastChange)/5000 + randomPalette[i].b*timeSinceLastChange/5000;
} }
break;} break;}
case 73: {//periodically replace palette with a random one. Transition palette change in 500ms case 74: {//periodically replace palette with a random one. Transition palette change in 500ms
uint32_t timeSinceLastChange = millis() - _lastPaletteChange; uint32_t timeSinceLastChange = millis() - _lastPaletteChange;
if (timeSinceLastChange > randomPaletteChangeTime * 1000U) { if (timeSinceLastChange > randomPaletteChangeTime * 1000U) {
prevRandomPalette = randomPalette; prevRandomPalette = randomPalette;
@@ -316,7 +316,8 @@ CRGBPalette16 &Segment::loadPalette(CRGBPalette16 &targetPalette, uint8_t pal) {
case 12: //Rainbow stripe colors case 12: //Rainbow stripe colors
targetPalette = RainbowStripeColors_p; break; targetPalette = RainbowStripeColors_p; break;
case 71: //WLEDMM netmindz ar palette +1 case 71: //WLEDMM netmindz ar palette +1
case 72: //WLEDMM netmindz ar palette +1 case 72: //WLEDMM netmindz ar palette +2
case 73: //WLEDMM netmindz ar palette +3
targetPalette.loadDynamicGradientPalette(getAudioPalette(pal)); break; targetPalette.loadDynamicGradientPalette(getAudioPalette(pal)); break;
default: //progmem palettes default: //progmem palettes
if (pal>245) { if (pal>245) {
@@ -1295,13 +1296,13 @@ uint8_t * Segment::getAudioPalette(int pal) {
xyz[6] = rgb.g; xyz[6] = rgb.g;
xyz[7] = rgb.b; xyz[7] = rgb.b;
rgb = getCRGBForBand(4, fftResult, pal); rgb = getCRGBForBand(128, fftResult, pal);
xyz[8] = 128; xyz[8] = 128;
xyz[9] = rgb.r; xyz[9] = rgb.r;
xyz[10] = rgb.g; xyz[10] = rgb.g;
xyz[11] = rgb.b; xyz[11] = rgb.b;
rgb = getCRGBForBand(8, fftResult, pal); rgb = getCRGBForBand(255, fftResult, pal);
xyz[12] = 255; // anchor of last color - must be 255 xyz[12] = 255; // anchor of last color - must be 255
xyz[13] = rgb.r; xyz[13] = rgb.r;
xyz[14] = rgb.g; xyz[14] = rgb.g;
@@ -2132,5 +2133,5 @@ const char JSON_palette_names[] PROGMEM = R"=====([
"Magenta","Magred","Yelmag","Yelblu","Orange & Teal","Tiamat","April Night","Orangery","C9","Sakura", "Magenta","Magred","Yelmag","Yelblu","Orange & Teal","Tiamat","April Night","Orangery","C9","Sakura",
"Aurora","Atlantica","C9 2","C9 New","Temperature","Aurora 2","Retro Clown","Candy","Toxy Reaf","Fairy Reaf", "Aurora","Atlantica","C9 2","C9 New","Temperature","Aurora 2","Retro Clown","Candy","Toxy Reaf","Fairy Reaf",
"Semi Blue","Pink Candy","Red Reaf","Aqua Flash","Yelblu Hot","Lite Light","Red Flash","Blink Red","Red Shift","Red Tide", "Semi Blue","Pink Candy","Red Reaf","Aqua Flash","Yelblu Hot","Lite Light","Red Flash","Blink Red","Red Shift","Red Tide",
"Candy2","Audio Responsive Ratio ☾","Audio Responsive Hue ☾","* Random Cycle" "Candy2","Audio Responsive Ratio ☾","Audio Responsive Hue ☾","Audio Responsive Ramp","* Random Cycle"
])====="; ])=====";

View File

@@ -5,7 +5,7 @@
* Readability defines and their associated numerical values + compile-time constants * Readability defines and their associated numerical values + compile-time constants
*/ */
#define GRADIENT_PALETTE_COUNT 61 //WLEDMM netmindz ar palette +2, ewowi Random Smooth palette +1 #define GRADIENT_PALETTE_COUNT 62 //WLEDMM netmindz ar palette +3, ewowi Random Smooth palette +1
//Defaults //Defaults
#define DEFAULT_CLIENT_SSID "Your_Network" #define DEFAULT_CLIENT_SSID "Your_Network"

View File

@@ -918,6 +918,7 @@ const byte* const gGradientPalettes[] PROGMEM = {
// Palette contents not actually used as built on the fly, just here to create menu option // Palette contents not actually used as built on the fly, just here to create menu option
audio_responsive_gp, //71-58 AudioResponsive WLEDMM netmindz ar palette - placeholder1 audio_responsive_gp, //71-58 AudioResponsive WLEDMM netmindz ar palette - placeholder1
audio_responsive_gp, //72-59 AudioResponsive WLEDMM netmindz ar palette - placeholder2 audio_responsive_gp, //72-59 AudioResponsive WLEDMM netmindz ar palette - placeholder2
audio_responsive_gp, //73-60 AudioResponsive WLEDMM netmindz ar palette - placeholder3
}; };
#endif #endif

View File

@@ -525,9 +525,15 @@ CRGB getCRGBForBand(int x, uint8_t *fftResult, int pal) {
} }
} }
else if(pal == 72) { else if(pal == 72) {
int b = map(x, 0, 255, 0, 8); // convert palette position to lower half of freq band int b = map(x, 1, 255, 0, 10); // convert palette position to lower half of freq band
hsv = CHSV(fftResult[b], 255, map(fftResult[b], 0, 255, 30, 255)); // pick hue hsv = CHSV(fftResult[b], 255, map(fftResult[b], 0, 255, 30, 255)); // pick hue
hsv2rgb_rainbow(hsv, value); // convert to R,G,B hsv2rgb_rainbow(hsv, value); // convert to R,G,B
} }
else if(pal == 73) {
int b = map(x, 0, 255, 0, 8); // convert palette position to lower half of freq band
hsv = CHSV(uint8_t(fftResult[b]), 255, x);
hsv2rgb_rainbow(hsv, value); // convert to R,G,B
}
return value; return value;
} }