0

I have some LEDs installed in my house, and I'd like to make them dance to music.

My setup:

  • 10 RGB LED strips (so 30 channels) controlled by PWM (48 steps) connected to a PC via USB.
    • The LED strips are physically located in 4 groups
  • Hardware is controlled by Node.js.
  • Music is played out of Traktor on a different machine.
    • Traktor provides MIDI data out with master tempo and level.
    • I have the MIDI data forwarded to the Node server over UDP.

I've written a library to abstract control of the LEDs, so in Node, I can just call:

channel[n].set(intensity, r, g, b);

...and it handles optimizing the data sent over the USB bus.

So on my Node server, I have music tempo and level data coming in, and want to translate that into a light show. Node gets the current audio level about every 60ms. The data looks like this (20 second sample from the middle of a song, click for bigger):

http://josh3736.net/images/ledviz.gif

The MIDI data is output on a scale of 0..127. In this case, the tempo value of 42 corresponded to a BPM of 128.

There are multiple parts to this question that can be addressed:

  • Most importantly, what is the best approach to use this data to control the LEDs?
    • Ideally, that input data should influence an animation/transition between colors; however, on hard hits an abrupt change/strobe might be nice too.
  • Is there any other MIDI data from Traktor I should send to Node?
  • How can I keep each of the 4 physical groups biased toward the same color?

Links of interest:

Community
  • 1
  • 1
josh3736
  • 139,160
  • 33
  • 216
  • 263
  • First off, MIDI is **not** audio data and has **nothing to do with audio** at all. MIDI is simply a protocol for controlling synthesizers and various other devices. If you expect to be able to get this to work in iTunes, then ignore MIDI entirely, and rewrite your question for audio only. – Brad Dec 14 '11 at 14:21
  • @Brad: Traktor uses MIDI to receive control commands from hardware and to send many types of data, including *data about the playing audio* -- in this case, I've configured it to send tempo (BPM) and level (volume). I'm going to scratch the line about iTunes since it's probably out of scope for the question anyway. – josh3736 Dec 14 '11 at 15:07
  • @josh3735, okay, now that we are ignoring audio completely and just looking at MIDI... Why not use standard MIDI sync messages? They should be sent by Traktor as well as other software, such as Ableton Live. You'll get 96 clock messages per beat. – Brad Dec 14 '11 at 20:02

2 Answers2

2

My top advice for doing LED strip animation and visualisation is to work in the HSV colour space. This way you can control the palette and intensity independently: https://www.npmjs.com/package/color-system

Work in HSV colours to code your animations, and then convert every pixel to RGB when you are ready to send them to the drive.

So you can, for example, connect your loudness to the (V) intensity, and the tempo to the hue (ie which part of the rainbow) (H). You can use sine waves to modulate these and make different patterns.

You can get some ideas from here - these patterns look complicated, but they are simple sine wave patterns modulated with the intensity and frequency of the music: https://www.instagram.com/stvito_performance_group/

0
  1. Scroll the whole image to the right or left when a new data sample comes in
  2. Blink the LEDs at the tempo reported by Traktor.

Can you get a MIDI report of the level post-filtering? You could use different frequency bands for different primary colors, I guess.

Matt K
  • 13,370
  • 2
  • 32
  • 51