Go Down

Topic: Music reactive LED strips (Read 491 times) previous topic - next topic

Bashmore

Hello , I am trying to rig up music reactive LED strips that change colour to the pitch of the song many times per second (like once every 10ms), i am just struggling with how to measure the frequency of the music and input it to the Arduino. I cannot just use a raw aux input as I intend on playing the music through Bluetooth speaker so I can't split the signal. I am currently thinking using a microphone/ sound sensor then putting that through a frequency to voltage circuit then mapping the voltage to the rgb colours. I am looking for advice on what hardware I need, mainly what type of sound sensor I can use to measure the frequency.
Many thanks

Grumpy_Mike

#1
Jul 31, 2019, 05:10 pm Last Edit: Jul 31, 2019, 05:11 pm by Grumpy_Mike
Changing the colour of a strip that often is not going to look very good. It will be a rapid  flashing that will aggregate to white.

Measuring the frequency of music is a bit meaningless because music is a whole mixture of frequencies all at the same time. A frequency to voltage chip only works on a single frequency with a repetitive waveform like a sin or square wave.

I think you will have to do a lot more reading about sound and the nature of sound before you can correctly formulate what is possible.

Quote
I cannot just use a raw aux input as I intend on playing the music through Bluetooth speaker so I can't split the signal.
I can't see why you think splitting the signal will prevent you from doing anything.

DVDdoug

#2
Jul 31, 2019, 07:14 pm Last Edit: Jul 31, 2019, 07:18 pm by DVDdoug
I've never used RGB LEDs and I haven't done any frequency-activated effects*,  but I have used separate-individual colored lights/LEDs for sound activated effects.

100ms seems "about right".   You can go faster but your eyes will perceive a "dimming" effect.   Incandescent bulbs take about 100ms to reach full-brightness, and a little longer to dim-out, and you get an actual-dimming effect if you go faster.   Of course you can go slower if you want to hold the state.

----------------------------------------------------------
If there's no way to get an electrical signal you can get a microphone board.   These have a microphone, a preamp, and the required biased-output.   

That particular one doesn't have a gain/sensitivity control and it may not have enough gain unless the sound is cranked-up loud.   Ideally, you'd like to tap-into a line-level audio signal before  it's volume controlled.   

But even if the signal isn't volume-controlled there are loud songs and quiet songs and you'll generally need some kind of sensitivity control (hardware or software).  There are ways to make an automatic sensitivity control in software.  For an example of automatic sensitivity control, see my World's Simplest Lighting Effect.


----------------------------------------------------------
The easiest way to get frequency information is with a slick little specialized chip called the MSGEQ7.   It puts-out 7 (multiplexed to one output) DC voltages representing the intensity of 7 different frequency bands.   Of course, you can ignore or combine bands if you only want to use 3 for 3-colors.
Some people have reported "quality problems" with the MSGEQ7.   I've never used one.

It can also be done in software with FFT or FHT.    If you want to see some examples of what can be done, search YouTube for "Arduino Frequency Analyzer".    FFT (or FHT) is not "easy" and it's very software-intense but there are libraries so you don't have to write the code yourself.   Of course, you still have to figure-out how to use the library and you have to figure-out how to control your LEDs


----------------------------------------------------------
Do you have the LED strips figured-out?   "Regular" LED strips will require a MOSFET (or transistor) driver for each channel/color.    NeoPixel strips have individually-addressable RGB LEDs that don't require a driver, and you can do amazing things with them.   (But, they are software/memory intensive.)






* A million years ago (before microcontrollers) I built a color organ (light organ) from a kit.  There were 3 color-channels for high, mid, and low frequencies.   After awhile, I got bored with it and made an effect that pops-up a different-random color pattern on the "beats".    I liked this effect because there was always at least one light on at full brightness, even when the music was quiet or silent.   (This was also originally done without an microcontroller but I've since made similar effects with the Arduino.)

Bashmore

#3
Aug 01, 2019, 11:24 am Last Edit: Aug 01, 2019, 12:30 pm by Bashmore Reason: It deleted a load of it
@Grumpy_mike - lol okay, thanks pal. I will do some more reading but I just saw a similar project use a frequency- voltage chip that why thought it would work , in answer to your question, i can use a direct aux input because I am also outputting the sound via Bluetooth, which to my knowledge isn't possible on windows ? Please correct me if I am wrong because if it is possible it'll make everything a lot simpler.


Bashmore

#4
Aug 01, 2019, 12:03 pm Last Edit: Aug 01, 2019, 12:33 pm by Bashmore Reason: I wrote so much but it deleted it all :(
DVDdoug ; Ahhh thanks dude, maybe 10ms was a bit excessive I will test once I get a system working. And to my knowledge I can't use a Bluetooth speaker, and still send data through the aux jack, if I am wrong then that'll make everything so much easier , coz then I can use a shield like this https://www.sparkfun.com/products/13116?_ga=2.175796641.2031956119.1564650448-1228876039.1564650448 .
 
That MSGEQ7 seems ideal I'll have a look, how would you separate each band if it's multiplexed.
I have looked at FFT but it seems a bit over kill for what I need. And yes I am using 2 x 5m strips of rgb individually addressable LEDs.
Hats off to you sir, I wouldn't dream of doing this without a micro controller

Question: if I use the 7 band audio analyser chip, would it possible to still , map a range of colours across the 7 bands

slipstick

Try Googling "Arduino colour organ" and see if that's the sort of thing you want.

Steve

Bashmore

@slipstick : Cheers pal will do 

Grumpy_Mike

Quote
which to my knowledge isn't possible on windows ?
You didn't say anything about the sound coming from a Windose PC in that first post!

DVDdoug

#8
Aug 01, 2019, 07:19 pm Last Edit: Aug 01, 2019, 07:24 pm by DVDdoug
Quote
And to my knowledge I can't use a Bluetooth speaker, and still send data through the aux jack...
If you can get into the speaker you can tap-into the wires going the speaker.  But you may not want to do that.


Quote
That MSGEQ7 seems ideal I'll have a look, how would you separate each band if it's multiplexed.
Demultiplexing! ;)    It's actually pretty simple...   If you look at the last page of the datasheet you'll see a timing diagram. 

The chip has two digital inputs (which will be connected to Arduino outputs).

The sequence is started with a Reset pulse.   Then when Strobe goes low, the analog output represents the 63Hz band.   You'll read that band (with an Arduino analog input) until the next low-going Strobe edge.    Then, you'll be reading the 160Hz band, etc.   After 7 reads, reset again and start over.  You can read each band for a long time but typically you'll just read it for a few milliseconds.

The timing diagram might be a little misleading because the output looks like a digital pulse and it's actually analog (between zero and +5V depending on the sound intensity of each frequency band).  The name-description of the chip IS misleading...  It's NOT a graphic equalizer chip! 

You should be able to find code examples.

Quote
Question: if I use the 7 band audio analyser chip, would it possible to still , map a range of colours across the 7 bands
Of course.  You have "information" from 7 bands which you can save in 7 variables and map to 7 colors.  Or, you could just read the bass and ignore everything else, etc.

Quote
And yes I am using 2 x 5m strips of rgb individually addressable LEDs.
I don't want to tell you what kind of effect to make, but with addressable LEDs you could   make a "color wave" that moves-down the strip.    The advantage is that the colors could remain separate and distinct, rather than blending on top of each other and trending toward whitish.   But, you may need to use some "software tricks" to create a limited-distinct color palette so the colors are always nice and intense.   But that's all stuff you can have fun experimenting with after you get the basics of reading the audio input and controlling the LEDs.

Go Up