August 23 2017 12:48:38
Navigation
· Home
· CV
· Articles
· Links
· News Categories
· Media Gallery
· Search
Login
Username

Password



Forgotten your password?
Request a new one here.
Java, MP3s and Lyrics
SoftwareI recently discovered that my iPhone is capable of displaying music lyrics whilst my songs are playing. I thought it'd be a good idea to get all of my MP3s tagged up with Lyrics to take advantage of this. Having previously tagged them all with album art, I knew this would be a rather daunting task (in fact, it's much worse, multiple songs share album art where as each song has its own lyrics!)...

My first idea was to find some existing software that did this automatically. I found something called "Corripio" for the Mac, which lets you code your own script to scrape a website for lyrics. This seemed perfect except that it meant learning a bit of Ruby (the creator's language of choice). After the program crashed a couple of times, I decided it wasn't stable enough to use. At this point I ported the Ruby scraper that I wrote to Java with the intention of using an ID3 library from the internet. The scraper hit lyrc.com.ar for song lyrics. It worked fine, but the quality of lyrics was pretty terrible (I swear most people are deaf), because of this, I decided to rewrite the scraper to scrape LyricWiki (a great site!).

I tried the JavaMusicTag ID3 library which I soon found to be buggy and horribly structured (try using it on an ID3v2.4 tag, it'll tell you that it can't cast new frames from ID3v2.3 to ID3v2.4 frames due its the horrible use of inheritance).

As the old adage goes, "If you want something doing right, do it yourself". So I wrote my own ID3 library for Java which copes with most of the ID3 features that I'd care about. Everything seemed to work fine until I tried editing the ID3 tag in iTunes, at which point I could no longer alter the lyric tags after saving in iTunes. It turned out that when iTunes saves the ID3 tags it checks for the ID3 version. If it finds version 2.4, it saves the album art with a synchSafe integer size but DOESN'T flag that it has done so in the frame header. This means that my tool would mis-read the album art frame and corrupt the header.

My solution for now (though inelegant) is to not support ID3v2.4 tags with my tool.

Anyway, I'm happy to say that all 2211 of my MP3s are now fully title, artist, album, artwork, track number and max track number tagged!
658,977 unique visits