2009
03.11

Uh oh, what have I been up to?About 3 months ago, I had the most random idea — I wanted a real time music visualizer. However, I just didn’t have the time to do the research necessary for this project because of homework. Well, now that I am on spring break, I decided to make a reality. And it worked! The first time too!

There are two sides of this project, the hardware and the software. The hardware part was the easy part. Mike had an Arduino board laying around and I went to radioshack to buy a relay, a 9 volt battery, a diode, and a transistor. Thats basically all that is needed for the hardware side. I used the schematic found on http://www.glacialwanderer.com/hobbyrobotics/?p=9 to make sure I’m doing everything right. Putting this together only took about 2 hours.

The software side was a little bit more tricky. I tried two differently languages: MATLAB and C#. Both turned out to be quite a big failure. Then I stumbled upon Processing, which is basically an extension onto Java that made it easy for visual artists to create programs. Processing included a library called Minim, which had lots of built in features for audio analysis. I used the beat detection algorithm from Minim and then used that to send a signal to the Arduino board over USB to turn on or off the lights.

Basically thats all! Later I plan to find a better relay, something that lasts longer [solid state relay?], and then put it in a box so it is safer and looks better.

For now, enjoy the video!

19 comments so far

Add Your Comment
  1. Pretty sweet, can’t wait to see this in person. You are one step closer to a party button. Also, if you want to fire up some circuit boards in diptrace I can manufacture you some.

  2. I might just have to take you up on that offer Gerrit.

  3. [...] More about Music controlled lights via Arduino [...]

  4. [...] More about Music controlled lights via Arduino [...]

  5. [...] More about Music controlled lights via Arduino [...]

  6. any way to avoid passing through processing and a laptop and wiring up directly to arduino?

    nice job, thougt

  7. @davide
    There is a possibility of using one of the analog inputs on the arduino board. I just did not have the time to hack the minim library to use this input instead of javasound.

    The reason I am using an arduino board in the first place, is because in the future, I wanted to buy more relay switches and control several lights at once, each referring to their own frequency band.

    There are options other than using an arduino too! In fact, there is an entire site dedicated to this kind of application:
    http://relaycontrollers.com/

    I just happen to have an arduino board laying around, and since I’m in college on a limited budget, I decided to use that instead of buying one of the options from that site.

  8. very cool! Any chance that you could upload the arduino and proccessing code?
    Thanks,
    Joe

  9. [...] More about Music controlled lights via Arduino [...]

  10. [...] Más sobre Música controla luces a través de un Arduino. [...]

  11. This looks awesome! I can’t wait to see the finished project.

    I second Joe’s request.
    I’d love to see how you set this up, if that’s okay with you.
    Thanks!

  12. Hey Andrew,

    It’s really cool that you were able to rig it up so quickly!
    I’m doing a similar project but I used an Arduino Shield to play music instead. I am stuck in one part that I’m guessing you are the only one who can answer. How did you manage to send the output of beat signals to the arduino through MINIM? Did you have to code something?

    Please help!

  13. @Sally
    I used MINIM to do the beat detection – I then sent it to the arduino using processing’s serial connection. I just sent a 1 or a 0 determining if the light should be on or not.

    If you wanted to actually play music via minim on the arduino would be a different story. If you wanted to interface with speakers, you could put the output from the analog output pins on the arduino through an amplifier (LM386?) and then to the speakers. I’m not sure what quality of sound you might get out of it either. If you dont have analog out, then a digital-to-analog convert -> LM386 should work as well. Thats more complicated though. Software wise, I would look at the AudioBuffer class in Minim to extract the sound data.

    Good luck,
    Andrew

  14. Thanks alot!

    I’m completely new to this since I’m not an engineering student. I’ll try out what you told me. Thanks again.

  15. Very nice! I’m working on a similar project. Any chance you could share your code?

  16. please can you share the code,

  17. Have you tried to use analog pins to define a better signal variation or does MINIM not do analog? Also,rather than just on and off – have you tried to connect multiple lights to include fade-in’s/out’s to denote beats other than a solid beat and silence?

  18. Hi, i am in an arduino class, and we are currently doing self projects. I would like to make a light that responds to the beat, similar to your arduino controlled music lights. I am a beginner and having trouble with the coding, is there any chance you could send me the coding you use to make it work properly? Thanks – Matt

  19. Copy-and-pasted from an email I sent back to Matt:

    It’s awesome that you are working with the Arduino – thats how I started and I think it was probably the best approach to learning about electronics. I’ve been studying for my undergraduate degree in college so I have very limited amount of time to browse the Internet which is why its been hard to get around to your question.

    This project you referred to was lost in a computer crash – so I have no code to give you. But let me give you a few hints.

    I used the “Minim” library for java that you can find here: http://code.compartmental.net/tools/minim/. I believe this library is now included with Processing now (the platform I used to communicate over serial to the arduino).

    Minim requires an audio input, so you can either run a splitter from an ipod to your microphone port on your computer, or use some sort of software to route the sound output from your computer back as an input. I ran my software on a Mac so I used a piece of software called SoundFlowerBed.

    Anyways, Minim has a BeatDetect class (seen here: http://code.compartmental.net/tools/minim/manual-beatdetect/) It was useful in the video I had but it can be pretty jumpy sometimes.

    You can also use what is called a Fast Fourier Transform (FFT For short) (Minim does this too, check out their documentation.) An FFT basically takes your audio input and seperates it into frequency ranges. So basically you can tell how loud the audio is from say 0-60 Hz and compare that with the entire audio signal. From there I was able to basically look at the “jumps” produced by the bass of the music and determine if that is a beat compared to how the jumps occurred in the last say 10 seconds.

    Beat detection is a fairly complex thing to do – and I never got it to really “work” half of the time. For example, a snare hit spreads across the whole frequency spectrum of hearing (20-20000Hz) so when I compared the lower frequencies to everything else, it just seems that it fit in.

    I went a long way since then, and found the best effect is when you just change the intensity of the light with respect to how loud those lower frequencies are. You can see this in my video I attached of my last lighting project.

    I hope this gives you some ideas, good luck with your project.