12.1.1 ID3V1 Tags

The id3v1 pickle provides abstractions in order to edit the metadata stored in a MP3 file.

12.1.1.1 Song Genres

The ID3V1 tags support the notion of song genre. The space for genres is from 0 to 254. The genre code 255 is reserved to mean “no genre”.

The table id3v1_genres can be indexed with a code in order to get the corresponding genre name:

(poke) id3v1_genres[14]
"rhythm and blues"

Conversely, the function id3v1_search_genre gives us the code of a genre, given its name. The prototype of this function is:

fun id3v1_search_genre = (string name) uint<8>:

For example:

(poke) id3v1_search_genre ("rock")
17UB

If id3v1_search_genre is given a name that doesn’t correspond with any genre in the genres table, then E_inval is raised.

12.1.1.2 The ID3V1_Tag Type

The main data structure defined in the id3v1 pickle is ID3V1_Tag, which corresponds to a ID3V1 tag (surprise!).

Tags comprise the following information:

The specification does not mention any specific encoding for the entries that store text (such as title or artist), but it is safe to assume some ASCII-compatible encoding is used.

The text entries are stored as arrays of characters, and they are not finished by NULL characters. Instead the arrays of characters are filled with whitespaces (ASCII code 0x20) at the right. For example, the artist name Picasso encoded in ID3V1 would be:

['P','i','c','a','s','s','o',' ',' ', ..., ' ']

In order to ease the manipulation of the text fields, setters and getters are provided in order to handle these values as strings and not as whitespace-filled arrays of characters. Example:

(poke) tag.title
[48UB,49UB,32UB,45UB,32UB,...]
(poke) tag.get_title
"01 - Eclipse De Mar"

Also for setters:

(poke) tag.set_title ("Join us Now")
(poke) tag.title
[74UB,111UB,105UB,110UB,32UB,...]

Setters and getters are also provided in order to manipulate the year as an integer value:

(poke) tag.year
[0x31UB,0x39UB,0x38UB,0x30UB]
(poke) tag.get_year
1980
(poke) tag.set_year (1988)