Skip to contents

Reads the ID3 tag of an MP3 file, or the one a wave file holds in an "id3 " chunk. Versions 2.2, 2.3 and 2.4 are read, as is the older version 1 tag at the end of a file where there is no version 2 tag to read instead. A file holding no tag gives an empty result rather than an error.

Usage

id3(x)

Arguments

x

Path to an audio file, a Wave object with ID3 metadata attached, a raw vector holding a file, or an id3 object

Value

An id3 object, which is a named list of fields

Details

Fields are named by the identifiers the frames themselves carry, such as TIT2 for a title, TPE1 for an artist and COMM for a comment, rather than being renamed, so that a frame this package has never heard of reads as readily as the ones it has. A frame that carries a description, which is any comment or user-defined frame, is named by it as well, as in TXXX|Recordist; a name that would otherwise repeat gets a number, as in COMM.2. A version 1 tag has no frames and its fields are named title, artist, album, year, comment, track and genre, the last being the numeric code the format defines rather than its name.

The version of the tag is kept on the result as its "version" attribute. The languages of any frames that declared one are kept as "languages", and the sizes of the frames whose values this package does not read, which is artwork, counters, identifiers and anything else that is not text, as "skipped".

Text declared as ISO-8859-1 that is in fact valid UTF-8 is read as UTF-8, which is what xeno-canto writes into the comment frame of its recordings.

A version 1 tag is marked by nothing more than the three letters "TAG" at a fixed distance from the end of the file, which the audio of a wave file can spell by chance, so one is only looked for in an MP3 file or in a file of no format this package recognises. A wave file keeps its tag in a chunk, where there is no guessing involved.

References

Nilsson, M. (2000). ID3 tag version 2.4.0. https://id3.org/id3v2.4.0-structure

See also

readMetadata() reads this and every other metadata format a file carries at once.

Examples

if (FALSE) { # \dontrun{
m <- id3("XC428067.mp3")
m[["TIT2"]]
attr(m, "version")
} # }