Sunday, January 30, 2011

XMas light simulator application

I created the simulator in Processing with minim library to play music and ControlP5 library for GUI components.

There are couple steps to creating a light show.
1) Mark the beats / add lyrics - I found that keyboard shortcuts work very well.  While playing the song, pressing the <spacebar> adds an asterisk next to the time mark.  It's fairly easy to click the <spacebar> at the start of each word.  Then, I go back and add lyrics at the times marked with asterisks.
2) Turn on/off lights - The right side of the screen shows which lights are on/off, and allows me to switch lights on/off by clicking.  I can play the simulated show, pause, and turn on/off the lights until I get the show just right.
I started by adding GUI buttons for all the functions, and quickly realized that it is much easier keeping my hands on they keyboard.  Navigating up and down the song is accomplished with the arrow keys, Page Up/Down, and Home/End.

I used the minim library Audio Player to play audio.  It's really easy, but I found one feature that causes me a little trouble.  When you get toward the end of the song, and call the audio player Skip method with a negative value (to skip backwards in the song), it takes a long time.  I'm guessing the implementation requires the player to start at the beginning and run through the song to get to the new position.  This is a bit of an annoyance, but really not that big a deal.
The center section of the simulator shows a timeline.  The first column is the time, in seconds.  Next to the time is what I call the beat indicator.  While playing a song, I press the <spacebar> on the words or beats.  This adds the asterisk at that time.  This helps me enter the lyrics (the next column) and synchronize the lights. The last two columns are the values of the lights.  The first number represents the state of the first 16 lights, and the second number represents the state of the next 16 lights.  In my next post, I'll discuss these numbers.
The right side of the screen shows picture(s) of the house.  When playing the song, windows light up simulating the lights.  I can also click the windows to indicate which lights I want turned on.
So, here's the finished XMas lights simulator.  I'm pretty happy with the way it turned out.  If I find some time, I'll probably go back and remove some hard-coded stuff and clean it up, but overall it does the job.

I used a nice piece of open source software called CamStudio to take the movie.  If you're looking to make a video of your screen, I highly recommend it.

In my next blog entry, I'll talk about the output of the simulator, the "piano roll" of instructions for the Arduino.

1 comment:

  1. First, I'm surprised that there are not any comments for this yet!?!?! Thanks for posting it.

    I need to create a simulator, and Google brought me right to this. So I'm thinking about creating the same thing as you.

    I do have a question: How scalable is this? The project I'm considering will have several hundred relays, and probably use Vixen to control multiple Arduinos. This will give me access to the effects in Vixen I don't have now using Arduinos directly (at least not without creating a coding nightmare).

    Part of the scalability question is whether the simulator can have different colors on top of each other?

    Please let me know, and thanks again for this post.

    Bob

    ReplyDelete