Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //declare this somewhere else, just here as a reminder
- //float divFactor;
- void flex_radiate() {
- readMSGEQ7_mono(); // or ReadAudio(), whatever you want to call it
- ledindex = HALF_POS;
- k = 0;
- for (int band = 0; band < 7; band++) {
- k = (band + 1) % 7; // doesn't work perfectly, but serves as a value for the NEXT band number
- half_MAPPED_AMPLITUDE = half_mapped[band];
- // there is a lot of math here that helps smooth brightness values
- // at the EDGES of each band on the led strip, so it doesn't immediately go from one color to another
- // this helps a TON for having it wrapped around a tube
- divFactor = 1.0f / half_MAPPED_AMPLITUDE;
- // segment is a variable (declare it somewhere) for FINAL led number of each band, with ledindex
- // indicating the START of each band. it is incremented after each cycle
- segment = half_MAPPED_AMPLITUDE + ledindex;
- hue = band * 35; // or whatever you want. just determines how much of the hue spectrum fits on the strip
- //hue += mono[0] * 0.01;
- for (index = ledindex; index < segment; index++) {
- brightness = (mono[band] * (half_MAPPED_AMPLITUDE - cnt) * divFactor) + (mono[k] * cnt * divFactor);
- //brightness = map(brightness, 0, 255, 100, 255);
- leds[index] = CHSV(hue, saturation, brightness);
- // to mirror to the bottom half of the strip
- leds[HALF_POS - (index - HALF_POS)] = CHSV(hue, saturation, brightness);
- cnt++;
- }
- cnt = 0;
- ledindex += half_MAPPED_AMPLITUDE;
- }
- // ehhh, blur it. why not.
- blur2d(leds, kMatrixWidth, kMatrixHeight, 100);
- FastLED.show();
- }
Advertisement
Add Comment
Please, Sign In to add comment