19#include <OctoWS2811.h>
27const unsigned int matrix_width = 60;
28const unsigned int matrix_height = 32;
29const unsigned int myColor = 0x400020;
32const float maxLevel = 0.5;
33const float dynamicRange = 40.0;
34const float linearBlend = 0.3;
36CRGB leds[matrix_width * matrix_height];
39AudioInputAnalog adc1(A3);
40AudioAnalyzeFFT1024 fft;
41AudioConnection patchCord1(adc1, fft);
47float thresholdVertical[matrix_height];
53int frequencyBinsHorizontal[matrix_width] = {
54 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
55 2, 2, 2, 2, 2, 2, 2, 2, 2, 3,
56 3, 3, 3, 3, 4, 4, 4, 4, 4, 5,
57 5, 5, 6, 6, 6, 7, 7, 7, 8, 8,
58 9, 9, 10, 10, 11, 12, 12, 13, 14, 15,
59 15, 16, 17, 18, 19, 20, 22, 23, 24, 25
70 computeVerticalLevels();
73 FastLED.
addLeds<OCTOWS2811>(leds,(matrix_width * matrix_height) / 8);
79unsigned int xy(
unsigned int x,
unsigned int y) {
82 return y * matrix_width + x;
85 return y * matrix_width + matrix_width - 1 - x;
91 unsigned int x, y, freqBin;
94 if (fft.available()) {
99 for (x=0; x < matrix_width; x++) {
101 level = fft.read(freqBin, freqBin + frequencyBinsHorizontal[x] - 1);
107 for (y=0; y < matrix_height; y++) {
110 if (level >= thresholdVertical[y]) {
111 leds[xy(x,y)] =
CRGB(myColor);
118 freqBin = freqBin + frequencyBinsHorizontal[x];
128void computeVerticalLevels() {
130 float n, logLevel, linearLevel;
132 for (y=0; y < matrix_height; y++) {
133 n = (float)y / (
float)(matrix_height - 1);
134 logLevel = pow10f(n * -1.0 * (dynamicRange / 20.0));
135 linearLevel = 1.0 - n;
136 linearLevel = linearLevel * linearBlend;
137 logLevel = logLevel * (1.0 - linearBlend);
138 thresholdVertical[y] = (logLevel + linearLevel) * maxLevel;
CFastLED FastLED
Global LED strip management instance.
central include file for FastLED, defines the CFastLED class/object
void show(uint8_t scale)
Update all our controllers with the current led colors, using the passed in brightness.
static CLEDController & addLeds(CLEDController *pLed, struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add a CLEDController instance to the world.
Representation of an RGB pixel (Red, Green, Blue)