25 February 2010

My first venture into writing code - Intro to Audio in Processing

Last time I mentioned this class Computational Principles for Media Art. Today we had pressure project 2 due, and this is what I came up with. Remember what it was like starting out and trying to learn something you'd never done before? The world of not understanding anything and knowing that in a couple months you'll look back and think - gosh, that's so easy - why couldn't I understand it? Well... read on.

For project 2, my goal was to learn as much as I could about the processing language. Ironically enough, for project 1, I chose to do video on Max/MSP, and for project 2, I chose to do audio on Processing. As it turns out, it would have made my life easier to have swapped those, but you live and learn, right?

In my research, I stumbled upon an awesome project that I’ve decided to take on this semester. It will be quite an undertaking for me, but it fulfills all of my goals I have for this class this semester. Without giving too much away, the programming portion is to take an incoming audio signal, run it through an FFT, extract amplitude and frequency information, and map those values to light intensity and color, respectively, sending the signals through an arduino to hardware. This is a straight forward and simple example of feature extraction. In Max, the programming is fairly simple. I suppose it is in Processing, too, but, disclaimer: I’ve never in my life written a piece of code.

I spent several hours going through the book “Programming Interactivity” by Joshua Noble, which is a great guide for complete beginners like myself. From there I learned the basics of all programming and the basics of the Processing language. I downloaded the minim library and perused the quickstart guide. From here I enlisted the help of fellow AME student Isaac, who volunteered to help me get through the bugs of learning to program. It turns out that nearly everything I wanted to accomplish was already pasted on the quickstart guide, so with only a few minor bugs, I was able to copy and paste from the web and create a window that displays an FFT and a waveform of the input from my microphone on my computer. At this point, I tried to make it play an mp3 file and display the FFT and waveform of the song. Here is where things start to go downhill. I got stuck. I couldn’t make Processing find the file I wanted to play. I moved on to looking at extracting frequency and amplitude, and I found nothing in the book or in the documentation that explained how to do what I wanted to do. Isaac showed me how to make Processing do what I wanted, and he accomplished it in about 30 minutes. It’s awesome. I unfortunately can’t explain how at this point, so I didn’t bring it. I’ve attached some annotated screenshots of my process to bring you back into the world of learning to write code from scratch. This is a project I hope to continue to build upon, and I think I’ve set a solid foundation of learning to help me along the way.

No comments:

Post a Comment