I was able to get it doing 2048pt FFTs and decoding mp3s in real time, and while that shouldn't be hard on a Pi considering plenty of 8bit uCs have been made to do real time FFTs, everything is done in Python, which makes it convenient (for me) to eventually add control via a web browser, sms, and other things. There's not much room to spare, though, it chokes when I move the mouse.
Most of the code to do this is already available, my goal here is just to roughly document the steps to get this working, from the perspective of a first time Pi user. I also made some tweaks to the FFT analysis chunk to speed things up a bit.
Hardware: (thanks for the toys Adafruit!)
- RasPi -- I think mine is running wheezy, Raspbian, ver 3.10.19
- 15ft (1m) RGB LED strip, $125 (~160 leds) controllable via SPI, built in PWM control, you just send updates--very nice. I'm just using one strip wrapped around to form 5 columns, and writing to different segments of the strip. This way I just have three wires connected to the Pi: ground, SPI Clock and SPI Data.
- 10A 5V power supply to drive the LEDs, $25, you could probably power the Pi with this, too.
- Those are the essentials, but you'll probably want a bunch of other stuff:
- USB WiFi adapter $7.61(RTL8188CUS chipset drivers are built in to wheezy OS!). I used these instructions to get it working.
- SD card (I got an 8GB one)
- USB Power speakers $10
- Power USB Hub to plug in keyboard, mouse, wifi,
- Some cell phone charger to power the Pi via it's USB power connector
- ethernet cable to connect to internet thru a laptop pre-wifi
- USB keyboard, mouse, HDMI monitor
- wire, some female-to-female jumper wires
- I mostly just used this awesome Pi-based xmas lights controller code from Chris Usey,Todd Giles and Ryan Jennings. It's a full command center for orchestrating xmas lights to audio (wav, mp3, etc). Their code lets you setup playlists and turn on and off 120VAC power based on frequency bands. You can even vote on songs through SMS messages! Their code looks at frequency bands in the music, and if the sound crosses a threshold, it turns a GPIO pin on. I changed the code to display the actual frequency band level on an RGB LED strip, rather than just having an on / off threshold. Based on similarities in the code, I suspect they got their FFT processing code from this python real-time FFT demo.
- Python control of LPD8806 RGB LED strip via SPI.
- This isn't related to this project, but I used the Geany IDE for coding.