Skip to content
Draft
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 31 additions & 6 deletions wled00/FX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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[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);
// USER_PRINTF("%u %u %u\n", data[0], data[1], data[2]);
return data;
}
// effect functions

/*
Expand Down Expand Up @@ -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) {
Expand All @@ -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], 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
} 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
Expand All @@ -7340,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

Expand Down