Introduction: Audio Level Signal Grapher
Please vote for me in the sensors contest if you find this instructable cool, useful, or anything in between!
In this instructable, I will show you how to convert an audio signal from any music playing device to a graph of the audio level/wave using an Arduino board. I believe these are also called music levels, audio levels, or audio equalizers, but I don't know much about audio.
Step 1: Gather the Supplies
For this instructable, you're going to need the following supplies:
- Wire strippers
- A 3.5mm audio jack (could be from an aux cord, headphones, etc...)
- Phone, laptop, boombox, speaker (something with a headphone jack or audio out)
- A lighter/flame or soldering iron
You will also need the following software:
We're using the Arduino IDE to get our analog input values and to share those values with our entire computer. In this guide, Processing will only be used to graph those values. In other words, the Arduino code will do the behind the scenes work and Processing will make an interface to go along with it.
I wouldn't recommend using an expensive audio device because you could potentially short out the audio signal and fry your boombox/phone/laptop. I've never fried a device of mine, but I don't see why it wouldn't be possible.
Step 2: Strip the Wires
Some audio cables don't use enamel, but rather insulate each wire separately. In that case, you should just strip all of the insulation and keep the wires apart from each other. If your wires look like mine and have enamel, you only need to strip the outside insulation to get to the enameled wires.
Step 3: Melt the Enamel
If you have enameled wires, it's usually easier to melt the enamel rather than sand it off. Be careful not to melt the enamel off in the areas where the wires are supposed to be separate or else the signal will short and potentially fry your device that's producing the audio signal.
Step 4: Find Audio and Ground
With your wires all nice and bare, we can test for continuity between each wire and its respective "ring" (e.g. left, right, or ground) to determine which wire goes with which ring. This is a good point to check your work so far by testing for continuity between the rings. If there is continuity between ground and left or ground and right, your audio signal will short out, so go back and find where the wires are making contact with other wires (you may have melted the enamel too far down the wire). If there's no continuity between the rings and you've identified which wire is continuous with each ring, give yourself a pat on the back because you can now move onto the next step.
Step 5: Attach Header Pins (optional)
If you have header pins, let's attach them. Choose which side of the audio you want to use, right or left, and connect that to a header pin and connect the ground to another header pin. Attaching header pins makes it easier to connect the signals to the the Arduino ground and analog input in the next step.
Step 6: Connect to Arduino
Connect the ground wire to Arduino ground and connect the left/right audio signal wire to A0 (analog input 0).
Step 7: Create the Arduino Program
Code - http://pastebin.com/e1QndQ2A
Now that we finished modifying our hardware, let's write the Arduino code. All that we are asking of our Arduino board is to communicate its analog readings (our audio signal) to the rest of the computer via serial communication. The code and line by line explanations can be found above; however, if you are familiar with Arduino, you should have no trouble writing it yourself.
Step 8: Create the Processing Program
Code - http://pastebin.com/jiPDtWSm
So far, Arduino is reading the values of the audio signal and it's communicating all of these values with the rest of the computer via serial communication. Now, we need to make a graph out of these values. The Arduino board has made it possible for programs to share information via serial communication and allows us to write a completely unrelated program that reads our values and displays them. You may be wondering why we need another program instead of programming it in the Arduino IDE. The answer is that the Arduino IDE lacks the programming libraries to create a sufficient graphical interface, so we will instead use the Processing IDE that is meant for these tasks. You can find the code and line by line explanations for our Processing program in the link above. Once our Arduino board establishes serial communication with the computer, we can run the Processing program to instantly graph our audio signal.
Step 9: You're Done!
After your Arduino starts to communicate with the computer via serial communication, our Processing program will begin to graph our values.
If you enjoyed this instructable, please vote for me in the sensors contest!
Be on the lookout for my next instructable; I plan to take this project and use the audio levels to flash LED strips in rhythm to the music.
Please let me know if you have any questions or feedback. Enjoy your audio signal graphs!
We have a be nice policy.
Please be positive and constructive.