Monday, October 24, 2005

ID3 Tags in Mp3

Finally im blogging after week. Actually i was busy with my diwali purchases and tightly engaged with office work. Yea, finally we are going to release our DVD player. Now the finishing touches are going on.

Today i written code to parse ID3 tag from mp3 files. Actually the format of ID3 tag varies from its version. The first and basic version is v1.0. According to this version the ID3 tag appears at the end of the mp3 file. It begins from 128th byte from the end of file, from this place we have to read the following structure

struct ID3v1Tag
char Signature[3]; // Should be 'TAG'
char SongName[30];
char Artist[30];
char Album[30];
char Year[4];
char Comment[30];
char Genre[1];

After reading this we need to check whether the Signature contains 'TAG' or not. This is signature of ID3v1 tag. All other fields are self explainary except the Genre. The Genre is 8 bit number denotes the Genre index. We can populate a array with list of genres and use this to retrieve the string form of genre.

The ID3v1.1 tag is slightly varies from v1.0. The difference is the byte before last byte in Comment field is used as a field to denote the track's index in original Audio CD.

The ID3v2 and its variation revision 3(not sure is this a revision or minor no) varies completely from its first version. Actually this version of ID3 tag can be found at any place inside mp3 file. But usually it can be located at the begining or end of the file. The data structure of this tag is pretty complex and you need to do few clicks in google to get info/sample for this.

I also started learning linux device driver last week. It seems to be complex but anyway im studying. I hope i will gain some knowledge atleast to write a simple driver. Actually i planned to write a simple driver which hijacks keyboard and modifies the scancode for keys. But for that i have to learn more chapters from "Linux Device Drivers".

No comments: