Thursday 23 February 2012

ID3 Tag Specification C++ Code Implementation

ID3 Tag is used to store information about the MP3 sound track.

ID3v1 - ID3 version 1

Specification
Last 128 bytes of MP3 file contain ID3v1 Tag.

struct ID3v1
{
    char szTAG[3]; // Contains "TAG"
    char szSongTitle[30]; // Title of sound track
    char szSongArtist[30]; // Artist Name
    char szAlbumName[30]; // Album Name
    char szYear[4]; // Year of publishing
    char szComment[30]; // Any user comments
    char cGenre; // Type of music
};



Based on value of "Genre" byte it can be interpreted as
 0. Blues 
  1. Classic Rock
  2. Country
  3. Dance
  4. Disco
  5. Funk
  6. Grunge
  7. Hip-Hop
  8. Jazz
  9. Metal
 10. New Age
 11. Oldies
 12. Other
 13. Pop
 14. R&B
 15. Rap
 16. Reggae
 17. Rock
 18. Techno
 19. Industrial
 20. Alternative
 21. Ska
 22. Death Metal
 23. Pranks
 24. Soundtrack
 25. Euro-Techno
 26. Ambient
 27. Trip-Hop
 28. Vocal
 29. Jazz+Funk
 30. Fusion
 31. Trance
 32. Classical
 33. Instrumental
 34. Acid
 35. House
 36. Game
 37. Sound Clip
 38. Gospel
 39. Noise
 40. AlternRock
 41. Bass
 42. Soul
 43. Punk
 44. Space
 45. Meditative
 46. Instrumental Pop
 47. Instrumental Rock
 48. Ethnic
 49. Gothic
 50. Darkwave
 51. Techno-Industrial
 52. Electronic
 53. Pop-Folk
 54. Eurodance
 55. Dream
 56. Southern Rock
 57. Comedy
 58. Cult
 59. Gangsta
 60. Top 40
 61. Christian Rap
 62. Pop/Funk
 63. Jungle
 64. Native American
 65. Cabaret
 66. New Wave
 67. Psychadelic
 68. Rave
 69. Showtunes
 70. Trailer
 71. Lo-Fi
 72. Tribal
 73. Acid Punk
 74. Acid Jazz
 75. Polka
 76. Retro
 77. Musical
 78. Rock & Roll
 79. Hard Rock
 
Pseudo code -
1. Just open the MP3 file with fopen(...)
 
2. Seek to 128 bytes from end of file 
    fseek( fp, -128, SEEK_END ); 
 
3. Now read all 128 bytes into struct
    struct ID3v1 id3v1; 
    fread(&id3v1, sizeof(char), sizeof( id3v1 ), fp);
 
4. While displaying structure members
    Note that the strings id3v1.szSongTitle are required to be NULL terminated.
    They are not NULL terminated by default.

ID3v2 - ID3 tag version 2
 


ID3v2.3 - ID3 tag version 2.3.0


References:
http://www.id3.org/id3v2-00
http://www.id3.org/id3v2.3.0

Tags:
ID3 Tag, ID3v1, ID3 version 1 specification , ID3 v1 c++, C++ code for ID3 version 1,C++ Code ID3 tag

No comments:

Post a Comment