My musical tastes, according to iTunes, Last.fm, and ColdFusion

I submit to you a map of my musical tastes, according to the history data in iTunes, prepared entirely with ColdFusion. The relative sizes of the covers represent the relative replay frequency.

Interestingly enough, my last.fm profile paints a different picture:

Yes it was prepared entirely with ColdFusion. I’ve been mulling over doing some data mining visualization with CF, so this was sort of a dry run for that. In a nutshell:

iTunesMusicLibrary.cfc

Read in the iTunes Music Library.xml file that iTunes provides for interoperability. Convert it into a giant query of tracks and their play count and most recent play date. Get a list of the top 80 most-played albums, where the album play count is the maximum of its tracks’ play counts.

LastFmUser.cfc

Fetch my weekly play chart via the Last.fm API and convert it to a query. Also fetch cover art.

AmazonCoverArt.cfc

Query and fetch the cover art from Amazon’s XML web service, assuming we couldn’t find it on Last.fm.

TreemapList.cfc

Do some basic treemapping work to figure out how big each album cover should be, relative to all of the others.

SquarifiedTreemap.cfc

Do some more advanced decision-making based on trying to keep the album covers as square as possible. This component decides exactly where each cover fits in the image. Based on the idea by J.J. van Wijk and, loosely, on the Java code by Martin Wattenberg and Ben Bederson.

TreemapRenderer.cfc

First draft generated plain HTML with absolute CSS layout. Second draft used cfimage to make a single composite image.

Along the way I made heavy use of WDDX to checkpoint my progress and keep me from slamming Amazon’s web service, or having to re-parse my 5MB iTunes XML over and over again. It’s about 900 lines of code in total, probably triple that once you count in code that I refactored and deleted.

A fun exercise, to be sure, but also very frustrating. I forget that Query-of-Queries is still not much more than a toy when it comes to doing anything truly useful. I want to believe that it can do even the basic stuff, but it chokes all to easily. Several hours of development were spent working around QoQ bugs.

And don’t get me started on the sad state of affairs that is album cover art.

I must say that I’m pleased with the results of the cfimage portion. It’s still too slow to do lots of image compositing for a busy site, but for non-sustained use it’s workable.

I’ve been considering doing something like this as a visualizer for Banshee. For that version, though, I’d want to have an Invert button that inverted the play counts for each, highlighting music that you haven’t listened to in a while. If I work on my treemap-fu, I might even get it to where it will group all of an artists albums next to each other. (Though I have doubts that this would look as nice.)

Published by

Rick Osborne

I am a web geek who has been doing this sort of thing entirely too long. I rant, I muse, I whine. That is, I am not at all atypical for my breed.