Athena is a wireless bluetooth speaker with built in leds that analyze the music that is being played and dance along with it. The goal of the project was to create a fun interactive speaker that can liven up any room with animation.
The architecture of the system uses a raspberry pi as the main computer and then an Arduino as the light card for controlling the lights.
To make Athena a reality I needed to put several different pieces together. The raspberry pi runs ubuntu 14.04 Trusty Tahr. The Audio system is run by pulse audio and the bluetooth connection is managed by the Ubuntu bluetooth daemon. Then the lights daemon is responsible for reading the audio off of the raspberry pi and performing a FFT to process the music. The FFT bins are approximately 100 hz wide and will provide amplitudes for the frequency being played. (If you want to learn more about how this works please see previous posts or the README in the git repo). I then split the lower section of the FFT, 0 hz to 1000 hz, into 52 bins. Each one of these bins roughly corresponds to a unique note and every 7 notes is an octave. If any one of these bins meets a threshold then we decide to turn on the light. To do this we create a bit mask of 8 bytes. Each byte corresponds to an octave and we turn on the bit if it meets the threshold. A message is then constructed in the form of :XXXXXXX where : marks the beginning of the message and each X is a byte. This message is then passed to the Arduino. The Arduino sits there waiting for messages from the serial port. When it gets a full message it then takes the bits and decides what lights to turn on or off.
To determine the threshold I looked at several graphs of the output of the FFT. I determined that at any point of time if we take 10*log(frequency) then if the note is hit it will be higher than 52 and anything lower is just noise.
To actually play the music I take advantage of ubuntu built in Pulse Audio and ALSA drivers and then play music out the raspberry pi’s audio jack.