Add second audio responsive palette

This commit is contained in:
Will Tatam
2022-11-18 12:10:20 +00:00
parent 181f8c546b
commit 359ef875de
6 changed files with 29 additions and 19 deletions

View File

@@ -516,17 +516,24 @@ void enumerateLedmaps() {
}
//WLEDMM netmindz ar palette
CRGB getCRGBForBand(int x, uint8_t *fftResult) {
CRGB getCRGBForBand(int x, uint8_t *fftResult, int pal) {
CRGB value;
CHSV hsv;
if(x == 0) {
value = CRGB(fftResult[10]/2, fftResult[4]/2, fftResult[0]/2);
if(pal == 71) { // bit hacky to use palette id here, but don't want to litter the code with lots of different methods. TODO: add enum for palette creation type
if(x == 0) {
value = CRGB(fftResult[10]/2, fftResult[4]/2, fftResult[0]/2);
}
else if(x == 255) {
value = CRGB(fftResult[10]/2, fftResult[0]/2, fftResult[4]/2);
}
else {
value = CRGB(fftResult[0]/2, fftResult[4]/2, fftResult[10]/2);
}
}
else if(pal == 72) {
int b = map(x, 0, 255, 0, 16); // convert palette position to freq band
hsv = CHSV(fftResult[b], 255, map(fftResult[b], 0, 255, 50, 255)); // pick hue
hsv2rgb_rainbow(hsv, value); // convert to R,G,B
}
else if(x == 255) {
value = CRGB(fftResult[10]/2, fftResult[0]/2, fftResult[4]/2);
}
else {
value = CRGB(fftResult[0]/2, fftResult[4]/2, fftResult[10]/2);
}
return value;
}