Originally shared by Nikolay Hristov
Looks super. Can you give some details about the setup? Num LEDs, type, controller?
Yes it’s my development arduino uno and the strip is the cheaper one WS2811 ~60 pixels * 3led per pixel. The code is from here don’t remember original author but I liked it and modified a little to suit my needs. Still struggle to get good readings from MSGEQ7 board I have very much noise when no audio is playing and this is quite hard to cut it without loosing much of the signal … If someone want could post code here
#include <FastLED.h>
#define LED_PIN 4
#define COLOR_ORDER BRG
#define CHIPSET WS2811
#define NUM_LEDS 60
#define BRIGHTNESS 255
#define FRAMES_PER_SECOND 60
#define MSGEQ7_STROBE_PIN 8
#define MSGEQ7_RESET_PIN 7
#define MSGEQ7_LEFT_PIN A0
int filter_min = 600;
int filter_max = 1000;
int prev_value;
int left_value;
float lowPass_audio = 0.18;
uint8_t band;
int left[7];
int mono[7];
int mapped[7];
uint8_t zero;
uint8_t three;
uint8_t six;
int HALF_POS = (NUM_LEDS * 0.5) - 1;
CRGB leds[NUM_LEDS];
void setup() {
delay(3000); // sanity delay
FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.setBrightness( BRIGHTNESS );
Serial.begin(115200);
}
void loop()
{
// Add entropy to random number generator; we use a lot of it.
// random16_add_entropy( random());
initializeAudio();
READ_AUDIO(); // run simulation frame
radiate();
}
void initializeAudio() {
pinMode(MSGEQ7_LEFT_PIN, INPUT);
pinMode(MSGEQ7_RESET_PIN, OUTPUT);
pinMode(MSGEQ7_STROBE_PIN, OUTPUT);
digitalWrite(MSGEQ7_RESET_PIN, LOW);
digitalWrite(MSGEQ7_STROBE_PIN, HIGH);
}
void READ_AUDIO() {
float left_volume = 0.0;
int mono_volume = 0;
float mono_factor = 0;
digitalWrite(MSGEQ7_RESET_PIN, HIGH);
digitalWrite(MSGEQ7_RESET_PIN, LOW);
delayMicroseconds(1);
for (int band = 0; band < 7; band++)
{
digitalWrite(MSGEQ7_STROBE_PIN, LOW);
delayMicroseconds(36);
prev_value = left[band];
left_value = analogRead(MSGEQ7_LEFT_PIN);
left_value = constrain(left_value, filter_min, filter_max);
left_value = map(left_value, filter_min, filter_max, 0, 255);
left[band] = prev_value + (left_value - prev_value) * lowPass_audio;
left_volume += left[band];
digitalWrite(MSGEQ7_STROBE_PIN, HIGH);
delayMicroseconds(1);
mono[band] = left[band] ;
mono_volume += mono[band];
}
mono_factor = float(HALF_POS) / mono_volume;
for (int band = 0; band < 7; band++)
{
mapped[band] = mono[band] * mono_factor;
}
}
void radiate() {
zero = (mono[0]+mono[1]+mono[2]/2);
three = mono[2]/2+mono[4]/2+mono[3];
six = (mono[5]+mono[6]);
Serial.print(zero);
Serial.print(" “);
Serial.print(three);
Serial.print(” ");
Serial.println(six);
leds[HALF_POS] = CRGB(zero, three, six);
// high frequencies = blue = FAST SPEED
EVERY_N_MILLISECONDS(35) {
for (int i = NUM_LEDS; i > HALF_POS; i-) {
leds[i].blue = leds[i - 1].blue;
}
}
// mid frequencies = green = MEDIUM SPEED
EVERY_N_MILLISECONDS(45) {
for (int i = NUM_LEDS; i > HALF_POS; i-) {
leds[i].green = leds[i - 1].green;
}
}
// low frequencies = red = SLOW SPEED
EVERY_N_MILLISECONDS(55) {
for (int i = NUM_LEDS; i > HALF_POS; i-) {
leds[i].red = leds[i - 1].red;
}
}
// for mirroring to the other half of the strip
for (int i = NUM_LEDS; i > HALF_POS; i-) {
leds[HALF_POS - (i - HALF_POS)] = leds[i - 1];
}
FastLED.show();
}
@Nikolay_Hristov Thank you for the info. Is the audio line from the player to the MSGEQ7 really long? Do you still get lots of noise even when the audio to MSGEQ7 is unplugged?
You will notice that G+ does not display code nicely. It is better to share code on http://gist.github.com
Radiate is by @Drew_Andre
for the noise you are talking about, what msgeq7 board are you using?
missing/deleted image from Google+
Looks like an adaptation of this code https://plus.google.com/u/0/115124694226931502095/posts/iMQiXg3tTH3
Well the MSGEQ7 data contains allways some noise. What helps is to A) set a threshold and discard any data smaller than that and B) perform some averaging / datasmoothing / ring buffering on the good data to minimize the erratic peaks and C) speed up the MSGEQ7 readout and read the audio band data several times before rendering one frame. And as @marmil recommended the analog circuit is better connected by well shielded (and short) cables . Same for the MSGEQ7 output lines.
@Stefan_Petrick , Yes there is about 30-100 steps noise in all of the bands when there is not input / With input connected but without music playin it even more. I grounded also input line and there is about 200 levels noise. Wondering if there some other reason for ex. noisy power supply from Arduino or something . As i wrote dont know originalo author of code ( not mine ) but I like it very much
I was wondering if it is possible do make some BPM detection on the signal and add it as the parameter to the speed of every band - slow music is rendering nice but something fast like 175BPM (DNB) become too “crowded” . Anybody tried this ?
@Nikolay_Hristov Well, I´m the author of the original code
Glad, you like it. Even a proper wired MSGEQ7 often shows a noise level up to 50. Just cut it off.
if (bands[i] < 50) bands[i] = 0;
BPM detection is a very tricky thing. I saw no implementation yet that covers all thinkable usecases. Zyou might want to read this - no bpm count but obviously a good beat indicator: https://forum.pjrc.com/threads/35299-Realtime-Beat-Detection-and-Audio-Analysis-DMX-Master-Demonstration
In case of fast audio stuff you need to tune your animation - it needs to run as fast as possible. So no map and stuff - you need really fast functions. The faster, the better. Also have a look here: https://www.youtube.com/watch?v=Xh9_JUiUiNg and at other videos from me - often I explained details about tuning in the comments.
Same code with some really messy audio input: https://www.youtube.com/watch?v=7Xifqp1WVa4
sorry, just thought that @Drew_Andre wrote it here
https://plus.google.com/111342001986849165184/posts/jX2iPjepik3
The code is simple enough and the animation is great for displaying music - the question is how could be enhanced and and more parameters added - I thought about some bluring or fading to be added in the ends of the strip also that fixed “every_n_seconds” is something that I could want to change ( again music dependent)
Big thanks to @Stefan_Petrick to share this idea with us 
