I'm new to this, but I've been interested in Arduino for a long while. Been setting up my new room, and I thought, "Why not include fully functional LED strip lighting that reacts to stereo music?"
So here I am. I have a basic sketch in mind, and here's how it goes:
WS2812B Neopixel LED strip. Can run off 5v straight from the Arduino UNO, so no extra power supply.
Arduino UNO to handle the LED programming. I intend to separate the strip programmatically into two sections, one for left and right stereo signal each.
1334 UDA1334A for Stereo Decoding. This is to send it to the speaker afterwards.
I'm yet to decide on an ADC.
My programming plan goes like this:
Analog audio to ADC.
ADC to UNO.
UNO checks the amplitudes of the highs, mids and lows (both left and right) and sets the LED lighting accordingly.
UNO to DAC.
DAC to Digital Audio(to speaker).
Now, I'm pretty sure I'm asking for too much. And frankly, I'm not even sure if my plan is good enough.
My questions:
Should I use an ADC and DAC separately? Or a single Audio Codec? Which ones?
Are there any extra components needed, outside of the ones I mentioned?
Is UNO even capable of handling real-time audio analyzing?
Should I remove the Codecs altogether and make my laptop handle the Audio analyzing? If so, how should I send the relevant data to the UNO?
I'm definitely asking a bunch of trivial questions, but your guidance would be highly appreciated. Thanks a lot!
Uno does not have the necessary speed or memory to deal with high quality stereo audio data at all. It certainly doesn't have the power to perform a frequency analysis across the full audio spectrum on 2 channels.
Your proposed DAC has an i2s input. Uno doesn't have an i2s output.
If your speaker has a digital input, why are you converting the audio to analog?
Well the last steps (digital to analog) is not really needed as you already have an analog signal on step 1.
Classic way to achieve what you need is to perform a Fourier transform
on an input stream. Look here, FFT library Library extracts 5 peaks of frequencies.
If UNO is too slow for Fourier transform you probably have to make external filters (RC) which will separate low/high frequencies and feed their output to your UNO: 3 filters feeding 3 separate UNO pins. There are sulutions for that on internet (fully analog, no MCU is used).
Example of 3 filters (you can feed your ADC instead of LEDs to get your frequencies intensity):
This has been my hobby for the past five years. Using my 25 years in the low voltage electrical technician I got into this wanting to design the christmas lights to go on the house that are superior to what people have and I found my passion is making scenic props that animate with light and sound.
It's an undertaking to build your own sound reactive LED controller when you are "new" to Arduino/C++. I tried in the past and ended up just buying them for $9 each. You can use pretty much any arduino so long as you have enough pins to accomplish what you want to do. Here are the things I have learned about LED lighting.
LED strips, strings, groups, and so on should NEVER be powered by your Arduino!!!!
Get a power supply unit that can power the LEDs and the Arduino.
PSUs come on a large variety of form factors size shape and ability.
To calculate the power supply unit (PSU) size needed for an LED strip, you can use the formula length of strip (ft) x watts per foot / 0.80. The result is the minimum rated LED power supply required.
With all electrical circuits you want the supplied power (Watts) to be 30% more than you need to cover spikes and LEDs spike a lot! It does not matter if you need 12 Watts and have a 20 Watt unit or a 200 Watt unit the lights will work with either, and the extra wattage will allow you to suppy power to more things from a single PSU.
LEDs consume power and are a pain to power beyond (somewhere around 125 WS2812B LEDs) you will need power injection for a longer strip of LEDs.
That is only scratching the surface of what you need to know to get started which is why I buy the controllers already made. I have not tried to reverse engineer one yet as I don't have any extra ones to sacrafice but I know they are built on a board that is the size of an Arduino Nano.
I get my supplies from this source BFT LIGHTING They might not be the cheapest but I go for long term use when I spend money on something. Plus they are really good at helping if you reach out to them for assistance.
I bought my son a roll of remote controlled LEDs off Aliexpress and his roku remote volume buttons happen to use the same RF frequency.
In the late '70s an engineer got the jump on surround sound by making band-pass filters for ADSR waveforms of each instrument in an orchestra, connecting to speakers around the room so you could sit as the conductor or in any "section."
Your audible-vision is possible.
An alternative to audio-reactive lighting is to time your audio. In this simulation, the "music" was broken down to effect-start-second and effect-stop-second. Those seconds were translated to milliseconds and placed in a header file containing this array (intervals.h). The lights were for a dance performance. The main code will work with any array of the same structure.