Skip to content

Commit 74bc159

Browse files
author
gaaat
committed
enabled some audioreactive effects for single pixel strips/segments
1 parent 6276c2f commit 74bc159

File tree

1 file changed

+27
-16
lines changed

1 file changed

+27
-16
lines changed

wled00/FX.cpp

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6643,7 +6643,7 @@ static const char _data_FX_MODE_GRAVIMETER[] PROGMEM = "Gravimeter@Rate of fall,
66436643
// * JUGGLES //
66446644
//////////////////////
66456645
uint16_t mode_juggles(void) { // Juggles. By Andrew Tuline.
6646-
if (SEGLEN == 1) return mode_static();
6646+
//if (SEGLEN == 1) return mode_static();
66476647
um_data_t *um_data;
66486648
if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
66496649
// add support for no audio
@@ -6655,12 +6655,13 @@ uint16_t mode_juggles(void) { // Juggles. By Andrew Tuline.
66556655
uint16_t my_sampleAgc = fmax(fmin(volumeSmth, 255.0), 0);
66566656

66576657
for (size_t i=0; i<SEGMENT.intensity/32+1U; i++) {
6658+
// if SEGLEN equals 1, we will always set color to the first and only pixel, but the effect is still good looking
66586659
SEGMENT.setPixelColor(beatsin16(SEGMENT.speed/4+i*2,0,SEGLEN-1), color_blend(SEGCOLOR(1), SEGMENT.color_from_palette(strip.now/4+i*2, false, PALETTE_SOLID_WRAP, 0), my_sampleAgc));
66596660
}
66606661

66616662
return FRAMETIME;
66626663
} // mode_juggles()
6663-
static const char _data_FX_MODE_JUGGLES[] PROGMEM = "Juggles@!,# of balls;!,!;!;1v;m12=0,si=0"; // Pixels, Beatsin
6664+
static const char _data_FX_MODE_JUGGLES[] PROGMEM = "Juggles@!,# of balls;!,!;!;01v;m12=0,si=0"; // Pixels, Beatsin
66646665

66656666

66666667
//////////////////////
@@ -6761,7 +6762,7 @@ uint16_t mode_noisefire(void) { // Noisefire. By Andrew Tuline.
67616762

67626763
return FRAMETIME;
67636764
} // mode_noisefire()
6764-
static const char _data_FX_MODE_NOISEFIRE[] PROGMEM = "Noisefire@!,!;;;1v;m12=2,si=0"; // Circle, Beatsin
6765+
static const char _data_FX_MODE_NOISEFIRE[] PROGMEM = "Noisefire@!,!;;;01v;m12=2,si=0"; // Circle, Beatsin
67656766

67666767

67676768
///////////////////////
@@ -6871,7 +6872,7 @@ uint16_t mode_plasmoid(void) { // Plasmoid. By Andrew Tuline.
68716872

68726873
return FRAMETIME;
68736874
} // mode_plasmoid()
6874-
static const char _data_FX_MODE_PLASMOID[] PROGMEM = "Plasmoid@Phase,# of pixels;!,!;!;1v;sx=128,ix=128,m12=0,si=0"; // Pixels, Beatsin
6875+
static const char _data_FX_MODE_PLASMOID[] PROGMEM = "Plasmoid@Phase,# of pixels;!,!;!;01v;sx=128,ix=128,m12=0,si=0"; // Pixels, Beatsin
68756876

68766877

68776878
///////////////////////
@@ -7026,7 +7027,8 @@ static const char _data_FX_MODE_BLURZ[] PROGMEM = "Blurz@Fade rate,Blur;!,Color
70267027
// ** DJLight //
70277028
/////////////////////////
70287029
uint16_t mode_DJLight(void) { // Written by ??? Adapted by Will Tatam.
7029-
if (SEGLEN == 1) return mode_static();
7030+
//if (SEGLEN == 1) return mode_static();
7031+
// No need to prevent from executing on single led strips, only mid will be set (mid = 0)
70307032
const int mid = SEGLEN / 2;
70317033

70327034
um_data_t *um_data;
@@ -7047,13 +7049,14 @@ uint16_t mode_DJLight(void) { // Written by ??? Adapted by Wil
70477049
CRGB color = CRGB(fftResult[15]/2, fftResult[5]/2, fftResult[0]/2); // 16-> 15 as 16 is out of bounds
70487050
SEGMENT.setPixelColor(mid, color.fadeToBlackBy(map(fftResult[4], 0, 255, 255, 4))); // TODO - Update
70497051

7052+
// if SEGLEN equals 1 these loops won't execute
70507053
for (int i = SEGLEN - 1; i > mid; i--) SEGMENT.setPixelColor(i, SEGMENT.getPixelColor(i-1)); // move to the left
70517054
for (int i = 0; i < mid; i++) SEGMENT.setPixelColor(i, SEGMENT.getPixelColor(i+1)); // move to the right
70527055
}
70537056

70547057
return FRAMETIME;
70557058
} // mode_DJLight()
7056-
static const char _data_FX_MODE_DJLIGHT[] PROGMEM = "DJ Light@Speed;;;1f;m12=2,si=0"; // Circle, Beatsin
7059+
static const char _data_FX_MODE_DJLIGHT[] PROGMEM = "DJ Light@Speed;;;01f;m12=2,si=0"; // Circle, Beatsin
70577060

70587061

70597062
////////////////////
@@ -7097,7 +7100,8 @@ static const char _data_FX_MODE_FREQMAP[] PROGMEM = "Freqmap@Fade rate,Starting
70977100
// ** Freqmatrix //
70987101
///////////////////////
70997102
uint16_t mode_freqmatrix(void) { // Freqmatrix. By Andreas Pleschung.
7100-
if (SEGLEN == 1) return mode_static();
7103+
//if (SEGLEN == 1) return mode_static();
7104+
// No need to prevent from executing on single led strips, we simply change pixel 0 each time and avoid the shift
71017105
um_data_t *um_data;
71027106
if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
71037107
// add support for no audio
@@ -7140,12 +7144,13 @@ uint16_t mode_freqmatrix(void) { // Freqmatrix. By Andreas Plesch
71407144

71417145
// shift the pixels one pixel up
71427146
SEGMENT.setPixelColor(0, color);
7147+
// if SEGLEN equals 1 this loop won't execute
71437148
for (int i = SEGLEN - 1; i > 0; i--) SEGMENT.setPixelColor(i, SEGMENT.getPixelColor(i-1)); //move to the left
71447149
}
71457150

71467151
return FRAMETIME;
71477152
} // mode_freqmatrix()
7148-
static const char _data_FX_MODE_FREQMATRIX[] PROGMEM = "Freqmatrix@Speed,Sound effect,Low bin,High bin,Sensitivity;;;1f;m12=3,si=0"; // Corner, Beatsin
7153+
static const char _data_FX_MODE_FREQMATRIX[] PROGMEM = "Freqmatrix@Speed,Sound effect,Low bin,High bin,Sensitivity;;;01f;m12=3,si=0"; // Corner, Beatsin
71497154

71507155

71517156
//////////////////////
@@ -7202,7 +7207,8 @@ static const char _data_FX_MODE_FREQPIXELS[] PROGMEM = "Freqpixels@Fade rate,Sta
72027207
// As a compromise between speed and accuracy we are currently sampling with 10240Hz, from which we can then determine with a 512bin FFT our max frequency is 5120Hz.
72037208
// Depending on the music stream you have you might find it useful to change the frequency mapping.
72047209
uint16_t mode_freqwave(void) { // Freqwave. By Andreas Pleschung.
7205-
if (SEGLEN == 1) return mode_static();
7210+
//if (SEGLEN == 1) return mode_static();
7211+
// As before, this effect can also work on single pixels, we just lose the shifting effect
72067212
um_data_t *um_data;
72077213
if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
72087214
// add support for no audio
@@ -7246,13 +7252,14 @@ uint16_t mode_freqwave(void) { // Freqwave. By Andreas Pleschun
72467252
SEGMENT.setPixelColor(SEGLEN/2, color);
72477253

72487254
// shift the pixels one pixel outwards
7255+
// if SEGLEN equals 1 these loops won't execute
72497256
for (int i = SEGLEN - 1; i > SEGLEN/2; i--) SEGMENT.setPixelColor(i, SEGMENT.getPixelColor(i-1)); //move to the left
72507257
for (int i = 0; i < SEGLEN/2; i++) SEGMENT.setPixelColor(i, SEGMENT.getPixelColor(i+1)); // move to the right
72517258
}
72527259

72537260
return FRAMETIME;
72547261
} // mode_freqwave()
7255-
static const char _data_FX_MODE_FREQWAVE[] PROGMEM = "Freqwave@Speed,Sound effect,Low bin,High bin,Pre-amp;;;1f;m12=2,si=0"; // Circle, Beatsin
7262+
static const char _data_FX_MODE_FREQWAVE[] PROGMEM = "Freqwave@Speed,Sound effect,Low bin,High bin,Pre-amp;;;01f;m12=2,si=0"; // Circle, Beatsin
72567263

72577264

72587265
///////////////////////
@@ -7311,7 +7318,7 @@ static const char _data_FX_MODE_GRAVFREQ[] PROGMEM = "Gravfreq@Rate of fall,Sens
73117318
// ** Noisemove //
73127319
//////////////////////
73137320
uint16_t mode_noisemove(void) { // Noisemove. By: Andrew Tuline
7314-
if (SEGLEN == 1) return mode_static();
7321+
//if (SEGLEN == 1) return mode_static();
73157322
um_data_t *um_data;
73167323
if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
73177324
// add support for no audio
@@ -7325,20 +7332,21 @@ uint16_t mode_noisemove(void) { // Noisemove. By: Andrew Tuli
73257332
uint8_t numBins = map(SEGMENT.intensity,0,255,0,16); // Map slider to fftResult bins.
73267333
for (int i=0; i<numBins; i++) { // How many active bins are we using.
73277334
uint16_t locn = inoise16(strip.now*SEGMENT.speed+i*50000, strip.now*SEGMENT.speed); // Get a new pixel location from moving noise.
7335+
// if SEGLEN equals 1 locn will be always 0, hence we set the first pixel only
73287336
locn = map(locn, 7500, 58000, 0, SEGLEN-1); // Map that to the length of the strand, and ensure we don't go over.
73297337
SEGMENT.setPixelColor(locn, color_blend(SEGCOLOR(1), SEGMENT.color_from_palette(i*64, false, PALETTE_SOLID_WRAP, 0), fftResult[i % 16]*4));
73307338
}
73317339

73327340
return FRAMETIME;
73337341
} // mode_noisemove()
7334-
static const char _data_FX_MODE_NOISEMOVE[] PROGMEM = "Noisemove@Speed of perlin movement,Fade rate;!,!;!;1f;m12=0,si=0"; // Pixels, Beatsin
7342+
static const char _data_FX_MODE_NOISEMOVE[] PROGMEM = "Noisemove@Speed of perlin movement,Fade rate;!,!;!;01f;m12=0,si=0"; // Pixels, Beatsin
73357343

73367344

73377345
//////////////////////
73387346
// ** Rocktaves //
73397347
//////////////////////
73407348
uint16_t mode_rocktaves(void) { // Rocktaves. Same note from each octave is same colour. By: Andrew Tuline
7341-
if (SEGLEN == 1) return mode_static();
7349+
//if (SEGLEN == 1) return mode_static();
73427350
um_data_t *um_data;
73437351
if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
73447352
// add support for no audio
@@ -7366,20 +7374,22 @@ uint16_t mode_rocktaves(void) { // Rocktaves. Same note from eac
73667374
frTemp = fabsf(frTemp * 2.1f); // Fudge factors to compress octave range starting at 0 and going to 255;
73677375

73687376
uint16_t i = map(beatsin8(8+octCount*4, 0, 255, 0, octCount*8), 0, 255, 0, SEGLEN-1);
7377+
// i will be always constrained between 0 and 0 if SEGLEN equals 1
73697378
i = constrain(i, 0, SEGLEN-1);
73707379
SEGMENT.addPixelColor(i, color_blend(SEGCOLOR(1), SEGMENT.color_from_palette((uint8_t)frTemp, false, PALETTE_SOLID_WRAP, 0), volTemp));
73717380

73727381
return FRAMETIME;
73737382
} // mode_rocktaves()
7374-
static const char _data_FX_MODE_ROCKTAVES[] PROGMEM = "Rocktaves@;!,!;!;1f;m12=1,si=0"; // Bar, Beatsin
7383+
static const char _data_FX_MODE_ROCKTAVES[] PROGMEM = "Rocktaves@;!,!;!;01f;m12=1,si=0"; // Bar, Beatsin
73757384

73767385

73777386
///////////////////////
73787387
// ** Waterfall //
73797388
///////////////////////
73807389
// Combines peak detection with FFT_MajorPeak and FFT_Magnitude.
73817390
uint16_t mode_waterfall(void) { // Waterfall. By: Andrew Tuline
7382-
if (SEGLEN == 1) return mode_static();
7391+
//if (SEGLEN == 1) return mode_static();
7392+
// effect can work on single pixels, we just lose the shifting effect
73837393

73847394
um_data_t *um_data;
73857395
if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
@@ -7417,12 +7427,13 @@ uint16_t mode_waterfall(void) { // Waterfall. By: Andrew Tulin
74177427
} else {
74187428
SEGMENT.setPixelColor(SEGLEN-1, color_blend(SEGCOLOR(1), SEGMENT.color_from_palette(pixCol+SEGMENT.intensity, false, PALETTE_SOLID_WRAP, 0), (int)my_magnitude));
74197429
}
7430+
// loop will not execute if SEGLEN equals 1
74207431
for (int i = 0; i < SEGLEN-1; i++) SEGMENT.setPixelColor(i, SEGMENT.getPixelColor(i+1)); // shift left
74217432
}
74227433

74237434
return FRAMETIME;
74247435
} // mode_waterfall()
7425-
static const char _data_FX_MODE_WATERFALL[] PROGMEM = "Waterfall@!,Adjust color,Select bin,Volume (min);!,!;!;1f;c2=0,m12=2,si=0"; // Circles, Beatsin
7436+
static const char _data_FX_MODE_WATERFALL[] PROGMEM = "Waterfall@!,Adjust color,Select bin,Volume (min);!,!;!;01f;c2=0,m12=2,si=0"; // Circles, Beatsin
74267437

74277438

74287439
#ifndef WLED_DISABLE_2D

0 commit comments

Comments
 (0)