When playing a CD, there are often two pieces of information you'd like to keep: the track name and a scan of the cover art. The former is more readily available and incorporated into most ripping software, while the latter isn't (although a lot of new media center-based software is including it).
What happens to determine the track names is that the start position and length of each song on the CD is determined and used to compute a single "fingerprint" number by way of a hashing algorithm. Since every CD in production has a different number of songs and each song has a different length, this number should be unique. (In reality, it's almost unique because some duplicates exist, but it's close enough.) This number is then compared against a database of known albums7 to retrieve the list of track names, which have been entered manually by human volunteers around the world. These track names and titles are then added to the ID tag of the MP3 or OGG file by the ripping software for later reference.
If you are using the CD itself, as opposed to a ripped version, then this information has to be retrieved manually each time you want to know what's playing. A part-time solution can be employed by using the cdcd package, which allows you to retrieve the number of the disc, the name, its tracks, and their durations.
The previous example will produce output that begins like this:
Trying CDDB server http://www.freedb.org:80/cgi-bin/cddb.cgi
Retrieving information on 2f1078l3.
CDDB query error: cannot parseAlbum name:
Total tracks: 19 Disc length: 70:18
Track Length Title
Although this lets you see the current track (indicated by the >), it is no more useful than what's provided by any other media player. However, if you've installed the abcde ripper, you will have also already (and automagically) installed the cddb-tool components, which will perform the CD hashing function and the database queries for you. Consequently, you can determine the disc ID, its name, and the names of each track with a small amount of script code:
TITLE=~cddb-tool query http://freedb.freedb.org/~cddb/cddb.cgi 6 $(app) $(host) $ID~
7 This was originally stored at CDDB but more recently at FreeDB.
The app and host parameters refer to the application name and the host name of the current machine. Although their contents are considered mandatory, they are not vital and are included only as a courtesy to the developers so they can track which applications are using the database. The magic number 6 refers to the protocol in use. From this string, you can extract the genre:
and the disc's ID and name:
DISC_ID='echo $TITLE | cut -d ' ' -f 3' DISC_TITLE='echo $TITLE | cut -d ' ' -f 4-'
Using the disc ID and genre, you can determine a unique track listing (since the genre is used to distinguish between collisions in hash numbers) for the disc in question, which allows you to retrieve a parsable list of tracks with this:
cddb-tool read http://freedb.freedb.org/~cddb/cddb.cgi 6 $(app) $(host) ^ $GENRE $DISC_ID
The disc title, year, and true genre are also available from this output.8
A more complex form of data to retrieve is that of the album's cover art. This is something that rippers, especially text-based ones, don't do and is something of a hit-and-miss affair in the open source world. This is, again, because of the lack of available data sources. Apple owns a music store, where the covers are used to sell the music and are downloaded with the purchase of the album. If you rip the music yourself, you have no such option.
One graphical tool that can help here is albumart. You can download this package from www.unrealvoodoo.org/hiteck/projects/albumart and install it with the following:
dpkg -i albumart_1.6.6-1_all.deb
This uses the ID tags inside the MP3 file to perform a search on various web sites, such as Buy.com, Walmart.com, and Yahoo! The method is little more than screen scraping, but provided the files are reasonably well named, the results are good enough and include very few false positives. When it has a problem determining the correct image, however, it errs on the side of caution and assigns nothing, waiting for you to manually click Set as Cover, which can take some time to correct. Once it has grabbed the art files, it names them folder.jpg in the appropriate directory, where it is picked up and used by most operating systems and media players. As a bonus, however, because the album art package uses the ID tags from the file, not the CD fingerprint, it can be used to find images for music that you've already ripped.
8 There is one main unsolved problem with this approach. That is, if there are two discs with the same fingerprint or two database entries for the same disc, it is impossible to automatically pick the correct one. Consequently, a human needs to untangle the mess by selecting one of the options.
■ Note Unlike track listings, the cover art is still copyrighted material, so no independent developer has attempted to streamline this process with their own database.
Correctly finding album covers without any IDs or metadata can be incredibly hard work. There is a two-stage process available should this occur. The first part involves the determination of tags by looking at the audio properties of a song to determine the title and the artist. MusicBrainz is the major (free) contender in this field. Then, once you have an ID tag, you can retrieve the image as normal. These steps have been combined in software like Jaikoz, which also functions as a mass-metadata editing package that may be of use to those who have already ripped your music, without such data.
Was this article helpful?