Emacs and id3

I rip all CDs, vinyl and cassettes to flac for easier listening, but I also convert the files to mp3 for listening in the car, which has an mp3 CD player.  This is what the display normally looks like:

DSC01582But all the files that I’ve ripped from vinyl are displayed like this:

DSC01583I’ve been assuming that my vinyl ripping tool chain just hasn’t been inserting id3 tags into the mp3 files for years, and that the car mp3 player was just displaying random data.  But yesterday I finally remembered to check the tool chain, and it does insert id3 tags into those files, too.

So, while pondering this deeply serious and puzzling issue, I started looking at id3 tools.  I wanted one that could just output all the id3 data in a machine-readable format, so that I could, perhaps, figure out what it was about certain files that made the car stereo not like them.

And I couldn’t find a single one.  I installed at least five different ones, and they were all so charmingly human oriented.  Phooey.

id3-2If I managed to discover what the problem was, I was going to have to re-tag all the problematic mp3 files, and I wanted that to be a process that could be automated, so I need machine-readable output.

Instead of continuing down that rabbit hole, I just wrote an id3 parser in Emacs instead.  And what the problem was because obvious on the first file I parsed:

id3-1The group name starts with “\377\376M^@”…  That’s utf-16 (or ucs-2) with a Byte Order Mark!

Interpreted as the iso-8859-1 Latin-1 charset, that would just be “ÿþM”, because it would think the string terminated at the first nul byte.

D’oh.

So the version of the Lame mp3 encoder on my vinyl ripping computer writes utf-16 tags, while the CD ripping computer writes iso-8859-1 tags.  And my car only understands the latter.

Mystery solved.

But when I’ve written the id3 parser, I thought I could just finish the job and write an id3 mode, too, to allow viewing and editing the id3 data.  It’s a bit scary, altering the mp3 files themselves, so I’d handle this with care.  In fact, I would recommend not actually testing this mode for writing data.  But it kinda seems to work for me.  Slightly.

Here’s what it looks like on an mp3 file that has an embedded image inside:

id3-3Kinda basic, but should be a starting point if somebody wants to experiment more…

 

5 thoughts on “Emacs and id3”

  1. could you please share the xlfd for the font in those screenshots? i’ve been trying to switch to core fonts, but can’t seem to settle on a combination that works for me.

      1. xlfd is x logical font description, it’s the x’s font naming convention -*-foo- etc. you can get it with emacs (font-xlfd-name (font-at (point))), and i assume that’s what was there after # before your comment filters ate it.

Leave a Reply