Categories
Uncategorized

Processing Audio

I got into Processing when I saw that it was a way to interface my desktop computer with an Arduino. Since then I’ve been exploring Processing more and seeing what it can do.

The latest excursion has been into audio, and I found a library called minim to play with. Download it, unzip it, and drop the ‘minim’ folder into your ‘libraries’ folder in your Processing folder, and you’re ready to go. Here’s my first experiment.

There’s an example for AudioInput which shows audio waveforms, so I grabbed the example and modified it slightly, I mainly twiddled the numbers a bit for a larger display.

Audio Waveform

Here’s the (slightly modified) code. (1280×800 being the screen size of my MacBook.)

/*
 * WavyLines.pde
 */

import ddf.minim.*;

Minim minim;
AudioInput in;

void setup()
{
  size(1280, 800, P3D);
  minim = new Minim(this);
  minim.debugOn();
  in = minim.getLineIn(Minim.STEREO, 1280);
}

void draw()
{
  background(0);
  stroke(0,255,0);
  // draw the waveforms
  for(int i = 0; i < in.bufferSize() - 1; i++)
  {
    line(i, 250 + in.left.get(i)*150, i+1, 250 + in.left.get(i+1)*150);
    line(i, 550 + in.right.get(i)*150, i+1, 550 + in.right.get(i+1)*150);
  }
}

void stop()
{
  // always close Minim audio classes when you are done with them
  in.close();
  minim.stop();
  super.stop();
}

This code (at least on Mac OS X) runs and expects the sound input to be the built-in mic on the MacBook. This is pretty fun, and my daughter (who plays the trumpet) had a good time making all sorts of strange noises and watching the waveforms that were generated. If you export it from Processing as an application, you can run it full screen with no menubar, etc.

While the mic input is fun, you can also build yourself a little audio visualizer that reacts to what audio your computer is playing. There’s a bit in the manual about Setting the System Mixers, but I just went the Soundflower route here.

Once you’ve got Soundflower installed, you can set up your audio routing…

Sound Out
Sound In

Here’s my sound output and sound input settings in System Preferences.

Fire up Soundflowerbed, and then choose a song in iTunes and our “WavyLines” application should respond appropriately.

Waveform

Here’s what you should get… well, depending on the audio playing. Maybe I can team up with the guys in the Handmade Music Group at the Milwaukee Makerspace and come up with some ways to enhance this into something even cooler.

Categories
Uncategorized

Visualizing Data

We all know that management loves its charts & graphs but normal people like us? We love data visualizations!

Why, just take a look at sites such as information aesthetics, Information Is Beautiful, or FlowingData for some examples.

I’m proud to say I’ve been dabbling in data visualization myself recently, and I’d like to share a few things with you.

visualization showing how dark is it at midnight
This is a visualization showing how dark is it at midnight.

visualization showing how bright is it at noon
This is a visualization showing how bright is it at noon.

visualization showing what color genderists think girls like
This is a visualization showing what color genderists think girls like.

visualization showing what color genderists think boys like
This is a visualization showing what color genderists think boys like.

visualization showing how dirty dirt really is
This is a visualization showing how dirty dirt really is.

visualization of a successful stabbing attempt
This is a visualization of a successful stabbing attempt.

visualization showing the color of oranges
This is a visualization showing the color of oranges.

Whew, that’s a lot of data! Aren’t you glad you were able to visualize it with my help? So many others make visualizing data complex, but we work hard to make it simple.

Data Visualization is just one of the many services we offer here at RasterWeb! Contact us for your next Data Visualization project.