Music Visualization with an Arduino

Audio Frequency Spectrum Analyzer & Spectrogram

As a followup to a previous post on Music Visualization with Processing (and a good excuse to play with my Arduino), I decided to convert my Processing music visualizer into hardware. The project is not finished yet, but I wanted to post a quick update and how-to on making what I have so far.

 

Media

Here a picture and video of the current working setup:

_DSC2334
visualizing music from my phone

 

Video

 

Info

An Arduino Duemilanove is used to sample sound through an anlog pin, compute the FFT of the sample, and visualize the audio on an LCD display. The center of the display shows the current frequency waveform plot, while a small-scale spectrogram is drawn on the left.

The original idea for this project was to make an audio spectrogram using an Arduino and an LCD. I wanted to use the full LCD for a nice big spectrogram graph. You will notice, though, in the picture and video above, that the spectrogram is a bit tiny and shares screen space with a frequency spectrum visualizer.

The spectrogram portion drawn is currently as large as can be because of memory limitations on the ATMega328 chip! (well, at least in the current version of the code). The spectrogram is stored as a 64×12 matrix where each column (12) is a stores the values (64) of the signal’s frequencies. 64 is the height of the screen, but 12 is far from the width (128), so I decided to fill the blank space with the waveform plot.

The spectrogram driver code is simply a modified version of my Processing app, and the frequency spectrum waveform plot is a modified version of this project’s code.

Mic pre-amp

This is a modified circuit from [here], with an added potentiometer (R5) for gain control.

mic-preamp
Simple microphone preamp.

R5: controls the gain.   Vout: to Arduino Analog Pin 5.   OP1: LM741 op-amp.

 

LCD

Buy from Adafruit: KS0108, and use the following wiring pinout:

GLCD-pinout-KS0108
KS0108 Arduino Pinout

More info: KS0108 Documentation

 

Code

Get My Arduino frequency analyzer + spectrogram source code and try it out for yourself!

You will also need: Arduino FFT source code & the GLCD/KS0108 Library.

Similar Project: Arduino audio analyzer (w/ VGA out)

 

Pics

Screen Shot 2012-12-11 at 10.14.56 PM.png
listening to music from my comp
Screen Shot 2012-12-11 at 10.07.23 PM.png
Testing out a new subwoofer

 

Future work

This project is far from done! I plan to eventually move everything off the breadboard, re-wire and solder the components to a real circuit board, and fit everything nicely into a small box. Meanwhile, it would be nice to find a workaround for the non-fullscreen spectrogram; if I can’t, it is fun to experiment with different ways of visualizing sound on this device. Maybe adding the ability to choose between a mic or ‘line-in’ jack would be cool too.

Thanks for reading – Please share if you enjoyed this post, and good luck if you plan to try it out yourself!

 

5 thoughts on “Music Visualization with an Arduino”

  1. Hi, MC, this is a great work done by you, I have been working on this project, but am facing an error during compiling,
    as below:

    sketch_may19a.cpp.o: In function `loop’:
    C:UsersSHANTIDesktoparduino-1.0.4-windowsarduino-1.0.4/sketch_may19a.ino:56: undefined reference to `fix_fft(char*, char*, int, int)’

    have created files in the libraries as “fix_fft.cpp and fix_fft.h”,
    same with the KS0108
    Arduino Ide 1.0.4
    Hardware: Arduino Uno Rev3

    Please help, not able to debug the same after many tries…

    thanks in advance…

  2. Saraswat:

    I would double check that you installe the fix_fft library in your arduino libraries directory (http://arduino.cc/en/Guide/Libraries and http://www.instructables.com/id/LoL-Shield-Audio-Spectrum-VU-Meter/step3/program-Arduino/). Also, it won’t hurt to place the .h and .cpp files in the same directory as the arduino program file (that is what I did, not sure if it helped though). Additionally, check the forum source for the fix_fft code (http://forum.arduino.cc/index.php/topic,38153.0.html) to see if anyone else has similar problems..

    Good luck!

  3. Dear Mc, thanks for your reply , the issue has been resolved now, this was an fft library installation issue. The lcd displays the spectrum but the gain is very very low, only two lines blinks on the screen. I was testing the module with an signal input taken from my galaxy note At full volume. Did you had similar issue…how to improve the gain? I have not yet build the electret mic ckt. As I have planned it for my preamplifier. Can it be driven directly by the preamp output or the opamp circuit is mandatory. Pls suggest…
    Regards
    Saraswat.

  4. Saraswat:
    Good news!
    Yes, you will need a mic pre-amp of some sorts. The one I build and listed does OK, though it still is fairly week (requiring close proximity to the mic). A suggestion would be to use a better microphone (than a $0.50 mic), or build a more elaborate pre-amp. Any pre-amp circuit will do, I just chose one that was fairly simple.

    Good luck!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.