Tuesday, October 24, 2006

Note to Self

Investigate iPod Suite and Satellite devices.

MeToo: How To Get an iPod Nano (2nd Gen) working with Ubuntu Dapper

Here's a quick round-up of things I did to get the iPod Nano 2nd Generation working with Ubuntu Dapper. Note that all other iPods work out of the box with Ubuntu Dapper, but this one seems to have firmware changes that cause major problems with auto-detection and auto-mounting. Coupled with the fact that this is barely a month old (it was released on 12 September), it means some software doesn't even know it exists! To the best of my knowledge, HAL detects the iPod correctly, but the GNOME Volume Manager refuses to take any action. Debug messages show "No sensible filesystem found". Given that dd and file both show a valid boot sector and filesystem, and mount has no problems mounting the partitions (there are two -- for the firmware and for the data), I wonder what exactly is the problem. Since I had little time to investigate this is detail, here's what I did to get it mounted and unmounted:
  1. Mounting: Use the pmount command. In case you're not aware, pmount is what allows non-privileged users to mount and unmount hardware given that certain conditions are met (must not be in /etc/fstab, must be removable, etc.). An invocation of this command looks like:

    pmount /dev/sda2 ipod

    This will mount the iPod at /media/ipod.

  2. Unmounting: The pumount command unmounts the iPod, and is similar to "Eject" in iTunes. However, it does not send a message to the iPod that it's been disconnected, and as a result the iPod continues to show a "Do not Disconnect" message even when it is safe to remove it. The correct command therefore is the eject command, which (surprise) ejects SCSI-like devices too. The command is:

    eject -s ipod

    Note that the -s is not necessary, but is given for completeness. The pumount command, for reference only, is pumount ipod.
Once the iPod is mounted, there are a number of software available for GNU/Linux that allow you to fully use the iPod's various non-song features. For example, you can store contacts (just save/sync vCards to a folder on the iPod), store notes, photographs (see below), and a lot more. Here I'll just talk about songs and photographs.
  1. GtkPod: GtkPod is the de facto application for managing songs with the iPod. In its latest incarnation (0.99.8, which I had to compile) it supports the new iPod Nano completely. As a bonus, it also supports the various iTunes-supporting mobile phones like those from the Motorola stable.

    In recent incarnations, GtkPod has split into two parts -- the UI application, and the library called libgpod. Most of the software that support the iPod tend to use libgpod internally. As of v0.4, libgpod supports all the song-related features of the iPod, but does not support Photos. The good news is that it does support cover art, which it did not in the previous versions.

    GtkPod should've ended my search, but its UI is a bit clunky, it supports only the file formats supported natively by the iPod (MP3, AAC, WAV), does not automatically search for cover art, does not show song lyrics, does not connect to Wikipedia to show information about the artist, etc. As you can see, these features are really extras, and GtkPod does the job very well. My brother uses it with his Motorola phone without any complaints.
  2. Amarok: This is my first serious introduction to Amarok, the player I'd heard is the do-all, end-all music player. I must say, I concur. Amarok is KDE's default player, and puts all competition to shame. It's also built for the power user, so that means no more running mounting and unmounting commands individually: there's a preference that automatically allows you to run commands before and after using the iPod. And then you simply click buttons! It also talks to HAL (I think) and automatically mounts the iPod if you've connected it.

    It scanned the music library, allowed me to edit and change tags to my heart's content, downloaded cover art automatically (including those for some Hindi films!), lyrics (including for Hindi songs!), Wikipedia connectivity and what not, exported it to my folder (with plugins), and transcoded files when and as necessary (with plugins). This was my application of choice to use with the iPod. It's complete.

    Unfortunately, Amarok had one serious lacking --- it failed to sync cover art. This is understandable because it probably uses an older version of libgpod, but this spurred me to look at other players (or "music management" applications) as well. I did try to dynamically use libgpod 0.4, but that broke a lot of other things in Amarok, so I let it be. I would've recompiled, but I didn't. For now. It's also a lot heavier on the memory, but that's a trait it shares with all the other players with similar abilities that I looked at.

    I used Amarok 1.4.3, the latest version, which isn't in the Ubuntu Dapper default distribution. However, Ubuntu Backports has a nice backported version. You'll also need the CopyCover (to export cover art) and transKode plugins, along with support for M4A (faac) installed.
  3. Banshee: To be honest, I looked at Banshee before I turned to Amarok. Banshee is a GNOME-native application written using Mono. In earlier times, the Mono bit would've turned me off, but I don't care anymore. Unfortunately, while Banshee looks like an exceedingly capable application, I wasn't able to use it with the iPod. Firstly, Ubuntu ships with a older version of Banshee. There are no backports available. Secondly, to get a newer version requires a dist-upgrade with an archive maintained by the Banshee developers. Needless to say, there were complications, which left Banshee 0.11.1 un-installable, un-compilable, and my patience with it ran out. I had limited time, and perhaps I'll come back to this player in some time, but for now, Banshee wasn't what I would use.

    Interestingly, Banshee does not use libgpod. It uses its own internal libraries, which is why I tried rather hard to get it working. Maybe some other time.
  4. Listen: When traversing various lists and forums looking for solutions to my problems, I stumbled upon a reference to the Listen player. It, too, is a native GNOME application and is written in Python. It uses python-gpod (i.e., libgpod) internally. Though its stable (which I used throughout) version advertises that it works with libgpod >= 0.3.2, I was a bit skeptical after Amarok's experiences with the new libgpod. But I decided I'd give it a try.

    Listen ships with Ubuntu Edgy, so I had to use the developer's backports for Ubuntu. They installed perfectly, but I quickly ran into a major problem. Even with the iPod mounted manually, Listen would not show it in its UI. Like most GNOME applications these days, there is absolutely no manual override.

    It turned out that Listen directly talks to HAL and the GNOME Volume Manager. In ideal circumstances, this is very good, since everything would Just Work. But of course, Murphy's law demands that HAL/G-V-M be broken. Sigh.

    Thankfully, the Listen code is well-written, and in Python, so I was able to code a manual override for detection (and since stable Listen is pre-iPod Nano 2nd Gen, that detection had to be coded too). Now came the acid test: would it work with libgpod 0.4? Of course not. There have been some changes to the libgpod API, and that caused it to fail. A simple change to the relevant line of code and it worked!

    Listen is a player that is still evolving, and while it's leagues away from Amarok's functionality, it did everything I wanted it to. It managed my music library, supported minimal tag editing, could download lyrics, had Wikipedia functionality and automatic cover art support, and also transcoded songs when necessary. And best of all, its sync cover art function works beautifully thanks to libgpod 0.4!

    Listen is not perfect, however, in that it often freezes up when doing lengthy operations, which multi-threaded multi-tasking Amarok has no problems with. Also, while Listen's transcoding works out of the box (it uses GStreamer and outputs MP3 instead of M4A), it's slow. Very very slow. I don't have a clue of why this is so, but an hour for transcoding a 8-minute Ogg/Vorbis song is too much. Moreover, it gives you no features like transKode's profiles that let you control quality (and therefore encoding speed). It does the right thing by attempting to maintain the same quality as the Ogg/Vorbis file, but perhaps this is simplicity taken to its extremes. Whatever.

    With Listen wrapped up in a script that automatically mounts and unmounts the iPod, said iPod's user is surprisingly happy with Listen's simple interface and uses it exclusively. Maybe the GNOME guys are onto something?
I did not look at YamiPod, Rhythmbox, Exaile, GNUpod or any of the other players out there due to lack of time. Do let me know if I missed something. Rhythmbox 0.9.6, in particular, seems to be very featureful.

Photographs on the iPod are of two types, the thumbnails for viewing on the iPod itself, and full-size photographs for transfer to other computers (via a copy from the Photos folder). GPixPod had no problems with storing thumbnails with very good support for albums and such, though I couldn't check out the full-size features (I wasn't aware of it, until I read the iPod manual). I compiled it from source.

How does all this compare with Apple's iTunes? Well, I also installed Apple's iTunes (on Windows, of course), and found a few things that you'll probably still need it for.
  • You still need Apple's iTunes to update your iPod's firmware (I'm sure the iPodLinux and Rockbox guys can do this too, but no application I looked at did this, understandably).
  • Importing photographs using iTunes is rather non-intuitive. You need to have everything organized on your hard disk, and then drop that folder onto a minimal "Sync Photograph Folders" UI. Or you need to have iPhoto installed. GPixPod has no such hang-ups, and works as you'd expect it to. GPixPod had a problem reading a photograph created from within iTunes, but I didn't worry too much about it, since the iPod itself has no problems with GPixPod.
  • Cover Art finds little mention in the manual, but my understanding is that you'd require access to the iTunes store to add cover art. Of course, there are freeware applications for doing this, but the fact that most Linux applications can do this directly is fantastic!
  • iTunes Song statistics and Smart playlists are probably best supported only with iTunes, but Amarok does support song statistics, and though it has Smart Playlists of its own, I don't know if they work for the iPod (though libgpod does support them).
There a lot of other iPod features that I've missed like Lyrics support and such, but I'll re-visit this article a few months down the line. Libgpod's new features seem very exciting. While Rockbox doesn't yet work with the new iPod Nanos, hopefully they'll be ready too by that time.

There are a lot of itches above, many of which I can competently scratch. Sadly I don't have access to the iPod Nano here so I'll just have to wait.

Thursday, October 12, 2006

Of Little Things that Matter Much

Often you encounter good programs that would be good as they are, but are much better due to very small features. You wouldn't notice these features unless you looked very hard, but their presence boosts the utility of the original progam greatly.

Take Emacs, my favorite text editor, for example. It has tons of these small refinements. Suppose you decide to replace "xyz" with "xen ya zen". During the search/replace if it encounters "XYZ", it will replace it with "XEN YA ZEN", and if "Xyz" then "Xen ya zen". Pretty nifty.

And then there is an "Artist Mode" in Emacs that allows users to draw ASCII art. When lines intersect each other, the code takes care to replace the intersection points with either X or +, as the case may be.

Gmail has this feature that tells you that the mail was sent, for example, "11 hours ago", that is more valuable and useful information than the DD-MM-YYYY HH:MM +OFFSET format followed elsewhere.

In Inkscape, an open source vector drawing program, that I occasionally use, copying and pasting a object has a feature I wonder why no other such program has (or if they have, why haven't I discovered it yet?). After you copy and paste, most programs will paste the object either:
  1. On top of the object you copied or,
  2. In some random location.
Inkscape will paste the object where your mouse cursor actually is. This is such a handy feature in drawing programs! Pressing Ctrl+V with the keyboard, while moving the mouse cursor around.

These features are not likely to be highlighted in advertising material for the program. Then why do programmers spend so much time coding these features? Agreed, some of these features are trivial to implement, but that's not always true for others (Emacs).

We had a lesson/text in school that probably explains this best. During the construction of a big and grand temple, a visitor finds one of the sculptors hard at work in one of the darkest corners, where no sunlight will ever illuminate the sculptor's work. "Why?" asks the visitor of the sculptor, "are you pouring so much work into something no one will ever see?"

"He will see," answers the sculptor, pointing to where the diety will be installed.

We computer programmers do not believe God uses our programs, but it shows how passionate both these types of artists are. They do not want beauty that is only skin deep, but one that survives even the most piercing glance. May their tribe live on!

Sunday, October 08, 2006

The NetFlix Prize

It's a very good time to be a machine learning researcher.