Handling multiple genres in id3v2?

Sander Jansen s.jansen at gmail.com
Fri Jan 7 18:45:25 CET 2011


In my music player I started implementing generic tagging support (add
one or multiple tags to a song), and I was looking on how to set and
retrieve multiple genres from a music file through taglib.

The xiphcomment implementation seems pretty straightforward, the
default genre() method just returns the first one found in the file
and if you want to get the rest, you just iterate over it yourself.

I'm slightly confused about the id3v2 implementation though. Perhaps
somebody can clarify.

When calling the default genre() method it does:

1) It will only look at the first TCON frame. Quite similar to the
xiphcomment implementation. But since the frame may contain multiple
strings, it's highly doubtful, we need to look at other TCON frames.

2) It goes over all strings in the TCON frame and adds them to a
stringlist (also removes duplicates. nice!)

3) Concatenate all strings in the list (space separator) and returns
it as one string.

The following questions come to mind:

* Current genre() implementation seems to imply multiple genres can be
returned separated by spaces, but this seems incompatible with the
i3dv1 genres, many that contain spaces ("Acid Punk", "Native
American", "Easy Listening").
* Perhaps the id3v2 genre() method should just return the first string
instead of the concatenated string list?
* So how do we store multiple genres/tags, one TCON frame with
multiple strings or multiple TCON frames with one string each.

Cheers,

Sander

P.S. Perhaps I shouldn't be (re)using the genre field for generic
tagging, in that case, suggestion to what field I need to use instead
would be welcome


More information about the taglib-devel mailing list