Greasemonkey script: Pitchfork links

Last.fm links on Pitchfork I read a lot of record reviews over at Pitchfork, and when something sounds good, I usually jump over to Last.fm to listen to it, or to remind myself to check it out again later. For a long time, I've been meaning to write up a Greasemonkey script for Firefox to generate the Last.fm link for me, so I don't have to type it in every time. You know, because that's so hard.

Anyway, I'm working on an, ahem, not tremendously exciting project at work, so I finally got around to it. I went ahead and made it extensible for other links besides Last.fm, so it can do links to iLike and Wikipedia, too; others are easy to add if you're reasonably familiar with Javascript. The script adds the links right next to the album artwork, right below the links to Emusic, digg, del.icio.us, and so on.

I posted it on userscripts.org. I currently have a hundred or so back reviews to read, so hopefully I'll have saved net keystrokes by the time I catch up.

Update: added links to IsoHunt, Mininova, and the Pirate Bay, by request.  I can't test right now because I'm on Firefox 3 RC2 and Greasemonkey doesn't work there yet.  But you can get the new version right here for now.  I will update it on userscripts.org as soon as I get it tested.


Tags: , , , , , , , , , , ,
Comments (2)

Audio tagging, Web 2.0-style.

I decided I want to be able to tag my audio files. Not just tagging, like with ID3 tags, but you know, tagging, like you tag a flickr photo or a del.icio.us bookmark. Web 2.0 tagging.

I have a digital music collection of close to 800 albums. There are nearly 300 different artists represented across almost 9,000 individual Ogg and MP3 files. I typically listen to this collection over the network, using DAAP (see a previous post), or occasionally through a Samba share from my Windows machine.

It's getting a little hard to find things with so much music to look through. So I've built some playlists with mt-daapd that divide things up in various ways. It goes a long way - you can specify playlists based on any combination of metadata fields, date added, filename, bitrate, etc.

There are a few problems with this approach. First, they're hard to maintain; even if your files are scrupulously tagged (I use MusicBrainz, which handles everything except, inexplicably, genre), you usually have to remember to add new things to your playlists.

Second, it's not very flexible; if you want to group music by anything other than genre (say, region of origin, or "driving songs"), you're out of luck. This issue is complicated by the perverse decision to limit genres in ID3v1 to a predetermined list of 126 (often dubious) choices.

Third, it's not portable. Your carefully constructed playlists are only available to DAAP clients accessing your share. This defeats the main reason for building audio metadata right into the files themselves.

After struggling with this for a while, it seems clear that what I really want to do is to associate small bits of arbitrary metadata with each file, so that I can create playlists based on whether those bits are present or not. And it should be up to me to determine what the groupings are. I should be able to create playlists of my wife's favorite songs, songs written by Lennon/McCartney, songs that came out while I was in high school, songs by artists from other countries, songs that I've seen performed live… anything I can think of should be possible. In other words, I want to be able to tag — and I mean Web 2.0-style, baby — my music.

So I began to commandeer the "comment" metadata field for this purpose. It works beautifully - I fill in the comment field with a space-separated list of tags for a file. In mt-daapd, and in library-based clients like Winamp, I can create a playlist based on whether a particular string occurs in the comment field. And the tags stay with the file, where they belong.

Still, it's a little daunting to tag 9,000 audio files. So — and here's the fun part — I wrote a couple of tools in Perl to help me out.

The first one doesn't actually tag anything. I use it to help me figure out what tags I might want to add to a particular artist. Given a list of artists, it will go over to last.fm and get a list of the top tags for an artist using their excellent XML services. If you don't give it any artists, it will use the name of the current directory (a convenience for me, since I'm doing all this from the command line). It's called lastfmtags, it uses LWP, and if you love the GPL, you can download it right here.

lastfmtags:
$ lastfmtags C*
Fetching tags for CAKE...
alternative
rock
indie
alternative rock
indie rock
seen live
Cake
pop
favorites
fun
Fetching tags for Cage...
Hip-Hop
hip hop
rap
Def Jux
heavy metal
underground hip hop
underground hip-hop
hiphop
Power metal
metal
...

'Nuff said. Okay, the other one is called commentify, and it's the tool I use to bend the audio comment field to my will. At its core is Audio::TagLib, which is a Perl wrapper around the nifty taglib library. It's a format-independent audio metadata library, which means that it goes and figures out what kind of audio file it's dealing with and handles each type in its own special way, so you don't have to. And it means that this script should work, not only for MP3 and Ogg, but also, apparently, APE, FLAC, and Musepack.

commentify can do five different tagging operations: set, append, delete, clear, and list. And it can act on multiple files or directories. If you give it a directory, it'll perform that operation on all files it finds underneath that directory (including all subdirectories). So it's easy to tag a whole lot of files, especially in a well-organized library. It's GPL, too, and you can get it right here.

Note that it will not attempt to preserve tag order. If it does, it's by accident. And it will not tag a file with duplicate tags.

commentify:
# set tags for all files within multiple directories
# (replaces all comment fields)
commentify -s "rock indie canadian" Arcade\ Fire/ Metric/

# add a new tag to some files
# (leaves existing tags intact)
commentify -a "favorite" dir1 dir2 file1 file2

# delete a couple of tags from some files
# (leaves others intact)
commentify -d "blah yadda" dir1 file1

# clear all comment fields
commentify -D dir1 dir2

# list comment fields for all files found
commentify -l dir1 dir2

Ah, that's good stuff. Now I think I'll go create a playlist from albums with green on the cover, bands that are side projects, and songs about cheese.


Tags: , , , , , , ,
Comments (9)

33 seconds of RAM

Today I listened to my computer's memory. Here's a sample. Kind of interesting, actually; I expected it to be all static, but some patterns do actually emerge. All in all, I think it sounds pretty much like what it is.

You can try this, too…. here's how:
sudo cat /dev/mem > /dev/audio

To record it:
sudo cat /dev/mem | oggenc -rq 1 -o mem.ogg -

oggenc assumes the raw data is 44.1khz at 16 bits per sample, so, if I calculate correctly, each second of audio represents 689K of RAM.

Update: IBM DeveloperWorks has an article on monitoring your system with audio. The idea is that you use the numeric values from a monitoring program like vmstat or top to synthesize musical tones using MIDI. When the CPU, memory, or I/O activity on the system increases, you can hear certain tones increase in intensity. I'm picturing a sysadmin sitting in the data center with all the machines humming along, occasionally going to investigate the occasional outburst of strings or horns…


Tags: , ,
Comments (1)

Get It Together, mt-daapd, and Ogg Vorbis

A couple of months ago, I got mt-daapd, the open-source iTunes music server, running at home. I don't use iTunes, but sharing my music collection with Samba or NFS seemed like a lot of overhead. It was very easy to do, and thanks to the Zeroconf/Bonjour/Rendevous support, even easier to use. It was pretty satisfying to fire up Banshee and see my server just pop up in the list without doing anything.

My music collection is a mix of Ogg Vorbis and MP3, which is no problem for mt-daapd, or Banshee for that matter. So I was all set on my Linux notebook. Then I started to look around for a way to connect to the server from Windows. iTunes was out - it doesn't support Ogg, and even if it did, it's too big and proprietary for just this one project. But it turns out that, beyond iTunes, there's not much available on the Windows platform that does DAAP. Even VLC, which normally plays anything you throw at it, doesn't have DAAP support yet.

I did find Get It Together, though, which is an open-source Java DAAP client. It worked great - it found and connected to mt-daapd just like Banshee did. MP3s worked flawlessly, but the Ogg files were grayed out, and wouldn't play.

Kinda makes sense - it's supposed to be an iTunes client, so why would it ship with Ogg support? I decided to get the source and see if I could make it play my precious Oggs.

Step one was to keep the Ogg entries from being disabled in the playlist.  In JavaPlayer.java, I added "ogg" to the SUPPORTED_FORMATS constant, recompiled that class, and replaced the ones in git.jar with the new files. No problems - GIT would now try to play the Ogg files. Of course, it failed. But it was a start.

So next, I had to figure out how to build Ogg support into the program. And here's where I got lucky. GIT uses the JavaZoom SPI to provide MP3 support. This is nifty because it works at runtime - if it's in the program's classpath, then the program can play MP3s just like any built-in format like WAV or AIFF, without caring whether it's an MP3 or not. JavaZoom also maintains a Vorbis SPI, and there are additional ones available for FLAC, Speex, Monkey's Audio, and probably more. (OnJava.com has links to these in an article.)

So I downloaded the Vorbis SPI from JavaZoom, and moved it and its supporting library JARs into Get It Together's classpath. I had to modify the launch script for Get It Together to include these four JARs. And it worked… GIT would now play both the Oggs and the MP3s in my mt-daapd library. Sweet.

This isn't enough to get GIT to include Oggs in its local media library, but since I only need to use it as a DAAP client, I'm happy. And if I ever end up with files in other formats, I'll be able to extend GIT in the same way. Nice to see it all come together like that.


Tags: , , , , , , , ,
Comments (11)

RSS feeds for Pitchfork

I wanted to find an RSS feed for Pitchfork's Best New Music section, but I couldn't find one… turns out they don't have any on the whole site. Thankfully, I found someone who took matters into his own hands. He hosts feeds for a couple of different sections of Pitchfork, generated by a Perl script. Awesome… but the Best New Music section isn't in there. I decided to try to modify his work to generate one for this section as well.

So it worked. Here's the Perl script and the RSS feed itself, which contains all of the reviews listed on this page. I'll set up a cron job to generate it every day.

Update: Never mind. Pitchfork has their own RSS feeds now. Fun while it lasted…


Tags: , , ,
Comments (3)

Bad Behavior has blocked 53 access attempts in the last 7 days.