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

Kill that Screen Sharing Dialog Box

As long as we’re taking about OS X, I have a fix for when you try to screen share another computer on your network and the dialog box hangs… Really, this is super-annoying. You can get rid of it by rebooting, but I hate rebooting. You can’t easily hide it because it floats above other windows, and you can’t force quit it. Well, not easily…

In your favorite terminal program (I personally like iTerm but Terminal.app will do) type the following:

ps aux | grep NetAuthAgent

And you should see something like this:

pete  38146  0.4  0.2  2823072 13644 ??  S  8:28AM 0:43.59 /System/Library/CoreServices/NetAuthAgent.app/Contents/MacOS/NetAuthAgent
pete  40131  0.0  0.0  2425700   264 s001 R+ 10:26AM 0:00.00 grep NetAuthAgent

That first line, with the /System/Library/CoreServices/NetAuthAgent.app bit is the one you want. See the first set of numbers in that line? That’s the process id (or PID.) Once you know the PID, you can do the following:

kill 38146

Typing the kill command followed by the process id should get rid of the dialog box.

Alternately, you can type:

killall NetAuthAgent

killall is a little more risky, as it kills processes based on name, not the PID, so if you have multiple process with the same name, it will kill them all. Hose things up enough and you’ll need to reboot, which is what we wanted to avoid doing in the first place.

Aren’t bugs fun?

Categories
Uncategorized

Fixing an iDVD “locked” file

I still use iDVD a lot, because it’s quick and easy to spit out a DVD either with simple menus, or an as auto-play disc with no menus at all… but every now and then, I get this warning about the file being locked.

This specific error came up when I copied the file to another Mac, but I’ve seen similar locking problem even on the same Mac and even with the same user…

Here’s the fix: command-click on the file in the Finder, and select Show Package Contents from the contextual menu. This will open a Finder window showing you the files.

Go into Contents, and then Resources, and look for the project.lock file, and delete it. That should fix it.

Bonus Tip: If you want a fast way of recursively opening all folders in list view, select the main folder, and hit command-option-right arrow. Want to close them all? command-option-left arrow.

Categories
Uncategorized

Internet is up!

Perl

I needed this script last week… See, our ISP had a bit of downtime, roughly 7 hours of downtime actually, but throughout the day there were some periods where our connection would be up for a few minutes before it went down again.

#!/usr/bin/perl

use Net::Ping;

$p = Net::Ping-&gt;new(&quot;tcp&quot;, 2);
$p-&gt;{port_num} = getservbyname(&quot;http&quot;, &quot;tcp&quot;);
$host = 'www.google.com';

while (1) {
if ($p-&gt;ping($host)) {
print &quot;Internet is up!\n&quot;;
# the next two lines will only be useful on osx
$cmd = 'say -v Victoria &quot;Internet is up&quot;';
system ($cmd);
}
else {
print &quot;...\n&quot;;
}
sleep(5);
}

To alert me to these few golden minutes of Internet connectivity I whipped up this script. It keeps trying to reach some server (in this example I’m using the highly-available www.google.com) waiting just 5 seconds between each check, and if it reaches the server (meaning our Internet connection is up) it prints “Internet is up!” and on Mac OS X it also says “Internet is up.” I made it say that so I could keep staring at what I was working on and be alerted audibly when the connection returned.

I was tempted to run this on our Mac jukebox so it would announce to the entire office when the connection was up, but by that time things seemed back to normal.

Obviously you could reverse this code to check if a server is up instead of down, and in fact one of my monitoring systems does just that. If you’re ever at the 2XL Networks office and hear “Attention! The server is not responding!” being yelled from one of the Macs… you know there’s a problem.

Categories
Uncategorized

Time Lapse Bot 3

Time Lapse Bot 3

I built the original “Time Lapse Bot” in September 2009 before BarCampMilwaukee4 happened. I managed to get an old office chair that someone was throwing away and thought I could put it to good use to move around the iMac and camera rig I had attached to it. You can see the original Time Lapse Bot post for more info.

The main issue with the original Time Lapse Bot was that if you unplugged it, you had to boot it up again, set the clock, and then restart the image capture. We thought about a UPS to give it a bit of “unplugged” time, but never added one.

Next up was Time Lapse Bot 2 which used an old clamshell iBook in place of the old iMac. This made everything much lighter but because the battery couldn’t hold a charge we still suffered the inability to unplug it and move it while it was running. (We typically solved this problem with really long extension cords.)

Time Lapse Bot 3

Time Lapse Bot 3 is the next step in Time Lapse Bot technology. We’ve taken an old PowerBook G4 (donated by Matt Gauger) which has a good battery in it, and paired it with a Canon ZR800 MiniDV camera, which also has a good battery. The result is a unit that can run on battery (at least for a few hours) and starts charging the batteries as soon as you plug in the AC power cord.

The entire unit is housed in a custom case which allows for easy transport. By “custom case” we’re referring to the plywood box that I constructed and painted black. That’s what we consider the pinnacle of “custom cases” around here.

The software that runs Time Lapse Bot is EvoCam by Evological. It’s $30 and well worth it. It’s feature packed, and rock solid. If you’re putting together a Mac-based time lapse rig that uses a video camera, or a web cam, or whatever, I highly recommend it.

Here’s a few of the time lapse videos we’ve made with the help of Time Lapse Bot.

We’ve finally reached a point where we are fairly pleased with Time Lapse Bot and it’s performance, so this is obviously not the time to sit still and relax. We’re currently working on a few upgrades to Time Lapse Bot, and hope 2011 brings even more Time Lapse Bot goodness to all the folks who enjoy time lapse videos…

(Thanks for reading this. If you’re reading it on Facebook or Google Reader or somewhere else it got syndicated to, consider visiting the original post, especially if you’d like to leave a comment.)