Add audio responsive pallette by Netmindz

const.h: increase GRADIENT_PALETTE_COUNT
fcn_declare: add getCRGBForBand
FX.h: add getAudioPalette
FX_fcn.cpp: call and getAudioPalette, add Audio Responsive palette
palettes.h: add audio_responsive_gp
util.cpp: add getCRGBForBand
This commit is contained in:
Ewoud
2022-11-18 12:09:47 +01:00
parent 017f0267a2
commit 181f8c546b
9 changed files with 69 additions and 7 deletions

View File

@@ -278,6 +278,8 @@ CRGBPalette16 &Segment::loadPalette(CRGBPalette16 &targetPalette, uint8_t pal) {
targetPalette = RainbowColors_p; break;
case 12: //Rainbow stripe colors
targetPalette = RainbowStripeColors_p; break;
case 71: //WLEDMM netmindz ar palette +1
targetPalette = getAudioPalette(); break;
default: //progmem palettes
if (pal>245) {
targetPalette = strip.customPalettes[255-pal]; // we checked bounds above
@@ -1137,6 +1139,38 @@ uint32_t Segment::color_from_palette(uint16_t i, bool mapping, bool wrap, uint8_
return RGBW32(fastled_col.r, fastled_col.g, fastled_col.b, 0);
}
//WLEDMM netmindz ar palette
CRGBPalette16 Segment::getAudioPalette() {
um_data_t *um_data;
if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
um_data = simulateSound(SEGMENT.soundSim);
}
uint8_t *fftResult = (uint8_t*)um_data->u_data[2];
uint8_t xyz[12]; // Needs to be 4 times however many colors are being used.
// 3 colors = 12, 4 colors = 16, etc.
CRGB rgb = getCRGBForBand(0, fftResult);
xyz[0] = 0; // anchor of first color - must be zero
xyz[1] = rgb.r;
xyz[2] = rgb.g;
xyz[3] = rgb.b;
rgb = getCRGBForBand(4, fftResult);
xyz[4] = 128;
xyz[5] = rgb.r;
xyz[6] = rgb.g;
xyz[7] = rgb.b;
rgb = getCRGBForBand(8, fftResult);
xyz[8] = 255; // anchor of last color - must be 255
xyz[9] = rgb.r;
xyz[10] = rgb.g;
xyz[11] = rgb.b;
return CRGBPalette16(xyz);
}
///////////////////////////////////////////////////////////////////////////////
// WS2812FX class implementation
@@ -1840,6 +1874,7 @@ uint8_t Bus::_cctBlend = 0;
uint8_t Bus::_gAWM = 255;
const char JSON_mode_names[] PROGMEM = R"=====(["FX names moved"])=====";
//WLEDMM netmindz ar palette add Audio responsive
const char JSON_palette_names[] PROGMEM = R"=====([
"Default","* Random Cycle","* Color 1","* Colors 1&2","* Color Gradient","* Colors Only","Party","Cloud","Lava","Ocean",
"Forest","Rainbow","Rainbow Bands","Sunset","Rivendell","Breeze","Red & Blue","Yellowout","Analogous","Splash",
@@ -1848,5 +1883,5 @@ const char JSON_palette_names[] PROGMEM = R"=====([
"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",
"Semi Blue","Pink Candy","Red Reaf","Aqua Flash","Yelblu Hot","Lite Light","Red Flash","Blink Red","Red Shift","Red Tide",
"Candy2"
"Candy2","Audio Responsive"
])=====";