AppleScripting iTunes: View Artist on AllMusic

I spend quite a bit of time listening to music and, being the nerd that I am, I like to know as much as I can about the music I’m enjoying. I find myself looking up bands so often that I decided I needed a shortcut.

tell application "iTunes"
	if player state is not stopped then
		set currentArtist to artist of current track
	end if
end tell

tell application "Safari"
	open location "http://allmusic.com/search/artist/" & currentArtist
end tell

The AppleScript itself is quite straightforward. We’re simply asking for the artist name from the currently playing track. Then we feed that into a search on all-know AllMusic. There we’ll be able to read a bio, see the band’s complete discography, find out whether they are categorized as “psychedelic pop” or just plain old “psychedelic”, all that good stuff.

Finally, Daniel Jalkut’s FastScripts software makes it a breeze to run our script right from iTunes. We’ll name our script something descriptive and good for a menu item like “View Artist on AllMusic.scpt” and place it into ~/Library/Scripts/Applications/iTunes/ (creating any directories that aren’t already there). With iTunes open and in front, our script will appear right in the FastScripts menu. We can also use the FastScripts Preferences pane to define a keyboard shortcut: I chose ⌘⇧A.

Try it out. Being unproductive has never been so efficient.

Lighthouse Video

I’ve been spending the past few months on a public art installation with my friends at goodgood and New American Public Art called “Lighthouse”. The piece will have several components: an internally lit sculpture on a roof, colored light projections from the sculpture down onto the ground, and generative video on a couple very large, very low resolution video screens.

The screens are very interesting. They are approximately 10′ wide by 8′ tall, and are just above the ground on walls that you can walk right up to. But they are only 64×48 pixels, meaning each pixel is a large glowing set of 3 LEDs. They are quite interesting to experience, and a bit of a challenge to create videos for.

Here’s a snapshot of my animation. It’s been processed to mimic the appearance when running on the low resolution screens.

If you’re in the Boston area, Lighthouse will be up for a few months starting on New Year’s Eve.

Risset Bell in SuperCollider

Trying to get my feet wet with SuperCollider, I decided to implement a version of Risset’s bell using additive synthesis. There’s an example in the help files for Pd (also described on Miller Puckette’s site) that I used for reference.

SynthDef(
	\risset_bell,
	{ |freq=440, dur=4.0, out=0|
		var partial;

		partial = { |amplitude, rel_duration, rel_freq, detune|
			OffsetOut.ar(out,
				EnvGen.kr(
					Env.perc(0.05, dur*rel_duration, amplitude*0.1, -4),
					doneAction: 0
				) * SinOsc.ar(freq*rel_freq+detune)
			);
		};

		partial.(1, 1, 0.56, 0);
		partial.(0.67, 0.9, 0.56, 1);
		partial.(1, 0.65, 0.92, 0);
		partial.(1.8, 0.55, 0.92, 1.7);
		partial.(2.67, 0.325, 1.19, 0);
		partial.(1.67, 0.35, 1.7, 0);
		partial.(1.46, 0.25, 2, 0);
		partial.(1.33, 0.2, 2.74, 0);
		partial.(1.33, 0.15, 3, 0);
		partial.(1, 0.1, 3.76, 0);
		partial.(1.33, 0.075, 4.07, 0);
	}
).add;

a = (
	type: \note,
	instrument: \risset_bell,
	freq: 500,
	dur: 10.0
);
a.play;   // play the note

Here’s my first take. I defined a Synth, and broke out a function to handle each partial for the additive synthesis. Env.perc makes a great envelope shape for a bell. I’m taking all the details–the tunings, relative amplitudes, and relative durations–from the Pd example.

The biggest trouble spot I ran into was the doneAction argument on EnvGen.kr. The doneAction is “an integer representing an action to be executed when the env is finished playing.” The common choice here would be 2, which means that the server should free the enclosing Synth as soon as the envelope has completed.

When I used a 2 I observed that the sound would cut off abruptly while still playing. It took me a bit to realize what was going wrong, but it eventually dawned on me that once the shortest partial had finished (remember, they each have different durations), it was triggering the doneAction and the server was freeing the entire Synth including all the other partials that I wanted to be still sounding.

To prove my hunch, I changed the doneAction argument to 0, or “do nothing”. Sure enough, the bell played all the way to completion. But that also left a Synth and a bunch of UGens sitting around on the server. These would continue to build up with every strike of the bell. Obviously this wasn’t acceptable.

SynthDef(
	\risset_bell,
	{ |freq=440, dur=4.0, out=0|
		var partials, addPartial;

		partials = Array.new(11);

		addPartial = { |amplitude, rel_duration, rel_freq, detune|
				partials.add(
					EnvGen.kr(
						Env.perc(0.05, dur*rel_duration, amplitude*0.1, -4),
						doneAction: 0
					) * SinOsc.ar(freq*rel_freq+detune)
				);
		};

		addPartial.(1, 1, 0.56, 0);
		addPartial.(0.67, 0.9, 0.56, 1);
		addPartial.(1, 0.65, 0.92, 0);
		addPartial.(1.8, 0.55, 0.92, 1.7);
		addPartial.(2.67, 0.325, 1.19, 0);
		addPartial.(1.67, 0.35, 1.7, 0);
		addPartial.(1.46, 0.25, 2, 0);
		addPartial.(1.33, 0.2, 2.74, 0);
		addPartial.(1.33, 0.15, 3, 0);
		addPartial.(1, 0.1, 3.76, 0);
		addPartial.(1.33, 0.075, 4.07, 0);

		OffsetOut.ar(out,
			EnvGen.kr(
				Env.perc(0.05, dur, curve: -4),
				doneAction: 2
			) * Mix.new(partials)
		);
	}
).add;

a = (
	type: \note,
	instrument: \risset_bell,
	freq: 500,
	dur: 10.0
);
a.play;   // play the note

After some searching I came upon a solution in Mark Polishook’s tutorial. He suggests wrapping the entire series of partials in an envelope, and put the done action on that overarching envelope. To make this happen I had to do a bit of refactoring: I threw the partials into an array and then mixed them down inside of the overlapping envelope. I left the doneAction of 0 on the individual partials, and gave the new envelope a doneAction of 2.

This was just the trick I needed. The bell rings loud and clear all the way to the end, and all the pieces are neatly cleaned up afterwards.

Golan Levin’s Double-Taker Robot

I have yet to see it in person, unfortunately, but I love this video documentation for Double-Taker (Snout) by Golan Levin. I think the movements are terrific—they breathe life and charm into what might otherwise be a strange or creepy object. I want to sit and watch it while it watches others.

Wind Dance Going Open Source

Project

Over the last several months I’ve been working on a series of art prints with my friend Jane Marsching. She had the idea to take wind readings from weather stations and translate them into drawings that resemble, and serve as, diagrams for dances. I’ve been writing a program called Wind Dance to help make that happen.

Here’s how it works: given a day’s worth of weather data, the program selects a representative reading for each hour and uses that to to determine the size and direction of the barb it plots. These barbs are spaced according to wind speed and direction as well.

Wind Dance accepts data in a comma-separated file, such as generated by Weather Underground (e.g., the “Comma Delimited File” link at the bottom of a typical page).

Language

Wind Dance is currently written in Ruby-Processing. I’ve been using Processing in my artwork for years, and I’m also a Ruby fan, so combining them seemed like a splendid idea. The Ruby language combined with the simplicity of Processing has definitely made the writing process smooth and elegant. That said, along the way we’ve run into some challenges due to Processing’s pixel-based nature. As we tried to shoehorn diagrams of wildly differing shapes and expanses into a standard size, and then as we worked to generate prints using various techniques, the image format seemed to make our lives more difficult.

So at this point I’m looking to convert Wind Dance to use a language and framework that can easily output vector-based images. I’m thinking this will probably be Flash/ActionScript, bundled as an AIR application to facilitate file imports and exports. I have to run some tests to make sure this will serve all my needs, but if you have and suggestions I’d love to hear them.

Ruby-Processing and JVM Memory Management

I recently started work on an art project, and decided to use Ruby-Processing for it. For years I’ve used standard Processing in other projects and wanted to try out a variation. I’ve loved being able to use Ruby syntax and conventions, while retaining the simple Processing API.

I ran into a small snag at one point, though. I’d decided to generate a larger image, and suddenly my program was crashing with the error message:

java.lang.OutOfMemoryError: Java heap space (NativeException)

I was familiar enough with Java to know that the Java Virtual Machine [JVM] was being started with too little memory allocated and wasn’t able to handle the amount of processing I was asking for. But I was writing what felt like a plain Ruby script. Where did the JVM come into play, and how was it being initialized?

I know that Ruby-Processing uses JRuby to call into Java and run Processing. I was hoping I wouldn’t have to dig too deep into this relationship to make adjustments to the JVM startup settings.

Luckily I discovered that Jeremy Ashkenas [jashkenas], the creator of Ruby-Processing, posted a solution on the Processing bulletin board. The trick is to put a file named “java_args.txt” into your sketch’s data folder.

I had to create a new folder named “data” in the root directory of my project. In it I added the new java_args.txt file. The following settings worked for my needs:

-Xms528m -Xmx1024m

This was picked up the next time I ran my script and I was off and running.