Hey everyone! I gotta apologize for having little knowledge about C++ and Arduinos as a whole. I'm in the process in creating a light system that reacts to the beat of music using 7 frequency ranges. I have 2 RGB strips. My vision is to have Strip A light up the 3 frequencies in the low range and Strip B to light up the 3 frequencies in the high range while both overlap the mids. I've downloaded the FFT Library from the site at http://wiki.openmusiclabs.com/wiki/ArduinoFFT. I've also found a code to create all digital pins to PWM however, I'm only requesting one digital pin to become a PWM. I'm using a spectrum analyzer shield for the music analysis https://www.sparkfun.com/products/10306. I'm turning to your help to guide me in the direction of what I need to know to make this system to all come together. In advanced, I'd like to thank you for you help because I wouldn't be able to finish my project without you.
DISCLAMER - I've never used the MSGEQ7 chip.
I'm using a spectrum analyzer shield for the music analysis https://www.sparkfun.com/products/10306.
With the MSGEQ7 chip, you don't need FFT. That chip has the frequency-filters built-in, which REALLY simplifies things. You get-out a time-multiplexed DC voltage that corresponds to the signal level of each frequency band. You will need the MSGEQ7 code to get the clocks & timing right.
My vision is to have Strip A light up the 3 frequencies in the low range and Strip B to light up the 3 frequencies in the high range while both overlap the mids.
The MSGEQ7 code will give you 7 "numbers". You can average/combine those to suit your needs. As a "lighting effect", you may get better results if you throw-away the middle band, or even if you throw-away more than one middle-band and let the LED's respond to the bass & highs.... That's up to you and you can experiment once you get going.
I've also found a code to create all digital pins to PWM however, I'm only requesting one digital pin to become a PWM.
So... The entire LED strip is going to dim as a whole, right? You'll need one PWM output for each LED strip.
You're also going to need a MOSFET (or something) to power the LED strip. I'd suggest you develop the project with a pair of regular LEDs and switch to the LED strips after everything else is working to your satisfaction.
For my lighting effects, I take a moving average (see the Smoothing Example) over about 20 seconds and use that for a reference. That way, I can automatically adjust for volume changes for good "lighting action" with quiet or loud songs, or when the volume changes. I also automatically switch between the 5V & 1.1V ADC references depending on signal level. (Like I said, I've never used the MSGEQ7, so I can't really help you with adding those features to your sketch.)
Since your spectrum shield has two MSGEQ7s, you might want to get 4 LED strips and make a stereo effect.
PWM (dimming) may be not be necessary... One of my effects simply turns-on the light when the signal is louder than average and turns it off when the signal is below average. That gives me a nice "flicker to sound" effect that automatically adjusts to the moving average for a lot of "light action". (Personally, I don't want a dim effect.... I want the lamps/lights to flash brightly.)
Thank you for responding! I understand now I don't need FFT, so thank you for reassuring that's what the shield does. I have 2ULN2803 Darilington transistors and a 12v DC 4.1A wall adapter to power the strips. I have 4 led strips; however, they tie into 2 strips really because the pairs are hardwired together before they touch the ULNs and UNO board. I'll consider throwing away the middle band! Any idea where I can find the code required for the MSGEQ7 or the system in general? I agree I don't want to dim it. We both have the same vision where the above average sound is what should be visible. Also, each strip is made up with the red green and blue data pins. So I really have 6 data pins along with the 1 PWM coming from the shield. Using the UNO, I need to create 1 software pin that will work in line with the rest of the code because I have 7 pins needing PWM while only 6 are offered on the board initially. I planned on having it mono because it'll simplify the process to a novice programmer and arduino guy. However, I believe I can keep that open in the future. I'll also look into the smoothing effect because that sounds interesting! Also my shield uses A0, A1, D4, and D5. In the smoothing example it talks about A0. Can't I move it to A3 or A4 without having any issues?
Hmmmm... I thought the MSGEQ7 sample code was on the SparkFun site, but I'm not finding it now. I didn't find it on the manufacturer's site either. :( You can find sample projects, but maybe somebody can point you to the "real master code".
If you don't want to dim the LEDs, you don't need PWM.
I'd save the smoothing/averaging for a future enhancement. Of course you can smooth any or all of the inputs. They are just numbers in an array. I'm not using any frequency-filtering, so I have one array for the left channel and another for the right. You might want an array for each frequency band, or maybe you can use one array to average everything.
What I do, is I save a "reading" once per second and store it in the smoothing array array. So, my 20-second array only has 20 values, and once per second I re-calculate the average and re-find the peak value in the array. Some of my effects use the peak as a reference. The peak in the array isn't the true-peak (and the average isn't the true-average) since the Arduino is running in a fast-loop and I'm only grabbing/saving a value once per second. But, it's close enough for what I'm doing.
The once-per-second timing is based on the Blink Without Delay Example, where I check the to see if one second is up every time through the loop. (I actually have multiple "timers" running at the same time.)
We are on similiar wavelenghts I believe. With your programming knowledge, can you tell me if this is possible and bear with me. It’s about to get complicated.
Here are my thoughts on how the final project was going to work.
We are cutting out a 7th bandwidth, the highest one. We have 6 bandwidths and each pin(red, green, blue wire) represents a bandwidth for each strip. We are still keeping Pair A(lows) and Pair B(highs) the same. They just won’t overlap. The mids will be infused into Pair B.
First. we will a threshold to prevent basic noise. If it less than say .2v(any value I don’t know what is an accurate guess), it will stay off no matter what. Then we will create a second threshold for the music. Each pin of the RGB strip represents a frequency and when a threshold is reached, the lights will turn on. The threshold of each frequency is determined by a value above the average magnitude of the frequencies from the mono audio input. A percentage for example! If the average was 50%, the threshold could be at 65%. The brightness of the lights is determined by how much the magnitude of the frequency is over the threshold. If a frequency hit 65.1%, the light will turn on, at 64.9% its off. This is so only the louder than average sounds are displayed. However, that percentage is low enough to allow multiple pins to be activated simultaneously. Because when multiple pins are activated at once, we will create different colors of light. In essence, we can create every color possible. My thoughts are that this “percentage” can come from smoothing the data out. http://arduino.cc/en/Tutorial/Smoothing. A sample of say 3 seconds will determine what amplitude the frequencies need to meet that threshold(65%) requirement to turn on. If the threshold is made, the lights will start at a value of 60 for example and so by the time they it hits 80%, it reached the 255 max value for that pin…Is this possible?