Copyright © 2001-2019 MultiMedia Soft

How to read TAG information in sound files

Previous pageReturn to chapter overviewNext page

The majority of audio formats allows the insertion of metadata, also known as "tags", which helps describing the content of the audio file by inserting information such as the title, artist, album, track number and other information about the audio file to be stored in the file itself.

 

The TagsReader COM object of Active DJ Studio allows reading the most common tag formats (in case you should need both reading and writing you may consider using our Active Sound Editor component): this can be accomplished by analyzing the audio file loaded inside an editing session, through the TagsReader.ALL_AnalyzeSoundOnPlayer method, or by accessing a sound file directly on the local disk through the TagsReader.ALL_AnalyzeSoundFile method.

 

Both methods return a combination of flags which allow determining the specific tag formats embedded inside the audio file; certain audio formats allow embedding more than one tag format; for example, the MP3 format could contain ID3V1, ID3V2 and LYRICS3 formats: the combination of flags allows discriminating which of them are effectively available inside the audio file and to manage them separately; if the returned value should be 0, this would mean that no known tag format is embedded inside the audio file. A small example can be see inside the following code snippets:

 

Visual Basic 6

 

' perform tags analysis

Dim nTagFormat As enumTagAvailable

nTagFormat = Amp3dj1.TagsReader.ALL_AnalyzeSoundOnPlayer(0)

If nTagFormat = TAG_FLAG_NONE Then

   ' no tag detected

   Exit Sub

End If

 

' check tags availability: we use bitwise operators because more than one type of tag format could be available

If nTagFormat And TAG_FLAG_ID3V1 Then

   ...

 do something with ID3V1

   ...

End If

If nTagFormat And TAG_FLAG_ID3V2 Then

   ...

 do something with ID3V2

   ...

End If

If nTagFormat And TAG_FLAG_WMA Then

   ...

 do something with WMA

   ...

End If

If nTagFormat And TAG_FLAG_MP4 Then

   ...

 do something with MP4

   ...

End If

 

 

Visual C++

 

// perform tags analysis

long nTagFormat = Amp3dj1.GetTagsReader().ALL_AnalyzeSoundOnPlayer(0);

if (nTagFormat == TAG_FLAG_NONE)

   // no tag detected

   return;

 

// check tags availability: we use bitwise operators because more than one type of tag format could be available

if (nTagFormat & TAG_FLAG_ID3V1)

{

   ...

   do something with ID3V1

   ...

}

if (nTagFormat & TAG_FLAG_ID3V2)

{

   ...

   do something with ID3V2

   ...

}

if (nTagFormat & TAG_FLAG_WMA)

{

   ...

   do something with WMA

   ...

}

if (nTagFormat & TAG_FLAG_MP4)

{

   ...

   do something with MP4

   ...

}

 

 

Some of the tag fields, such as artist, title and album, are common to all of the tag formats so Active DJ Studio exposes a set of methods that allows accessing these common frames without the need to know the specific format of the audio file being edited: TagsReader.ALL_CommonFrameGet method allows reading these common frames.

 

IMPORTANT NOTE:When using the TagsReader.ALL_AnalyzeSoundOnPlayer and TagsReader.ALL_AnalyzeSoundFile methods, subsequent calls to other methods of the TagsReader COM object will be related to that specific analysis.

If for example you have an instance of Active DJ Studio with 2 players, named Player_A and Player_B respectively and you want to obtain the title of the loaded song, after the following call

 

Dim nTagFormat As enumTagAvailable

nTagFormat = Amp3dj1.TagsReader.ALL_AnalyzeSoundOnPlayer(Player_A)

Dim strTitle as String

strTitle = Amp3dj1.TagsReader.ALL_CommonFrameGet (TAG_FIELD_TITLE)

 

the returned title will be about the sound file loaded inside Player_A while after the following call

 

nTagFormat = Amp3dj1.TagsReader.ALL_AnalyzeSoundOnPlayer(Player_B)

strTitle = Amp3dj1.TagsReader.ALL_CommonFrameGet (TAG_FIELD_TITLE)

 

the returned title will be about the sound file loaded inside Player_B. This means that, in order to read further information about tags stored inside Player_A, for example the author's name, you will have to perform a new analysis of the sound loaded in Player_A as seen below:

 

Dim strAuthor as String

nTagFormat = Amp3dj1.TagsReader.ALL_AnalyzeSoundOnPlayer(Player_A)

strAuthor = Amp3dj1.TagsReader.ALL_CommonFrameGet (TAG_FIELD_ARTIST)

 

 

When dealing with specific audio formats, Active DJ Studio allows reading the following kind of tags:

 

ID3V1
ID3V2
LYRICS3
WMA
OGG Vorbis
MP4
APE
FLAC
WAV Chunks

 

 

ID3V1

 

The ID3V1 tag, intended for usage with MP3 files, occupies 128 bytes beginning with the string TAG and is placed at the end of the file. This tag allows 30 bytes each for the title, artist, album, and a "comment", four bytes for the year, and a byte to identify the genre of the song from a predefined list of 80 values (Winamp later extended this list to 148 values).

One improvement to ID3V1 uses the last two bytes of the comment field to store the track number. Such tags are referred to as ID3V1.1.

A full description of this tagging format can be found on this link.

 

You can know if the ID3V1 tag is available by checking the value returned by the TagsReader.ALL_AnalyzeSoundOnPlayer or TagsReader.ALL_AnalyzeSoundFile methods: if it should contain the flag TAG_FLAG_ID3V1 this would mean that the ID3V1 tag is available.

 

ID3V1 fields can be read through the TagsReader.ID3V1_FieldGet method.

 

 

ID3V2

 

ID3V2 is a tagging system that lets you put enriching and relevant information about your audio files within them. ID3V2 is a chunk of data prepended to the binary audio data. Each ID3V2 tag holds one or more smaller chunks of information, called frames. These frames can contain any kind of information and data you could think of such as title, album, performer, website, lyrics, equalizer presets, pictures etc.

A full description of this tagging format can be found on this link.

 

Active DJ Studio supports 3 different versions of ID3V2:

 

ID3V2.2
ID3V2.3
ID3V2.4

 

All of them are currently supported in read mode only. This system allows the use of UNICODE characters in UTF-16 format and, when dealing with version ID3V2.4, in UTF-8 format as well.

 

You can know if the ID3V2 tag is available by checking the value returned by the TagsReader.ALL_AnalyzeSoundOnPlayer or TagsReader.ALL_AnalyzeSoundFile methods: if it should contain the flag TAG_FLAG_ID3V2 this would mean that the ID3V2 tag is available.

 

The list of supported ID3V2 frames, with related identifiers and methods to access stored information, can be found on the table below:

 

Supported frame types

Frame identifiers

Multiple

Related methods

Text-based frames

TIT1, TIT2, TIT3, TALB, TOAL, TRCK, TPOS, TSST, TSRC, TPE1, TPE2, TPE3, TPE4, TOPE, TEXT, TOLY, TCOM, TMCL, TIPL, TENC, TBPM, TLEN, TKEY, TLAN, TCON, TFLT, TMED, TMOO, TCOP, TPRO, TPUB, TOWN, TRSN, TRSO, TOFN, TDLY, TDEN, TDOR, TDRC, TDRL, TDTG, TSSE, TSOA, TSOP, TSOT

No

TagsReader.ID3V2_TextFrameGet

User text frames

TXXX

Yes

TagsReader.ID3V2_UserTextFrameDescriptionGet

TagsReader.ID3V2_UserTextFrameGet

URL-based frames

WCOM, WCOP, WOAF, WOAR, WOAS, WORS, WPAY, WPUB

No

TagsReader.ID3V2_URLFrameGet

User URL frames

WXXX

Yes

TagsReader.ID3V2_UserURLFrameDescriptionGet

TagsReader.ID3V2_UserURLFrameGet

Comment frames

COMM

Yes

TagsReader.ID3V2_CommentFrameGet

TagsReader.ID3V2_CommentFrameInfoGet

Commercial frames

COMR

Yes

TagsReader.ID3V2_CommercialFrameInfoGet

TagsReader.ID3V2_CommercialFramePictureBitmapGet

TagsReader.ID3V2_CommercialFramePictureFileGet

TagsReader.ID3V2_CommercialFramePictureMemoryFileGet

TagsReader.ID3V2_CommercialFramePictureSizeGet

TagsReader.ID3V2_CommercialFrameReceivedAsGet

Event timings (cue points) frame

ETCO

No

TagsReader.ID3V2_EventTimingsFrameEventCountGet

TagsReader.ID3V2_EventTimingsFrameEventInfoGet

General objects frames

GEOB

Yes

TagsReader.ID3V2_GeneralObjectFrameFileGet

TagsReader.ID3V2_GeneralObjectFrameInfoGet

TagsReader.ID3V2_GeneralObjectFrameMemoryFileGet

TagsReader.ID3V2_GeneralObjectFrameSizeGet

Music CD identifier frames

MCDI

No

TagsReader.ID3V2_MusicCdIdentifierFrameGet

TagsReader.ID3V2_MusicCdIdentifierFrameSizeGet

Ownership frame

OWNE

No

TagsReader.ID3V2_OwnershipFrameInfoGet

Picture frames

APIC

Yes

TagsReader.ID3V2_PictureFrameBitmapGet

TagsReader.ID3V2_PictureFrameFileGet

TagsReader.ID3V2_PictureFrameInfoGet

TagsReader.ID3V2_PictureFrameMemoryFileGet

TagsReader.ID3V2_PictureFrameSizeGet

TagsReader.ID3V2_PictureFrameTypeGet

Play counter frame

PCNT

No

TagsReader.ID3V2_PlayCounterFrameCountGet

Popularimiter frame

POPM

Yes

TagsReader.ID3V2_PopularimeterFrameCounterGet

TagsReader.ID3V2_PopularimeterFrameEmailGet

TagsReader.ID3V2_PopularimeterFrameRatingGet

Private frame

PRIV

Yes

TagsReader.ID3V2_PrivateFrameFileGet

TagsReader.ID3V2_PrivateFrameMemoryFileGet

TagsReader.ID3V2_PrivateFrameOwnerGet

TagsReader.ID3V2_PrivateFrameSizeGet

Synchronized lyrics frames

SYLT

Yes

TagsReader.ID3V2_SynchLyricsFrameGet

TagsReader.ID3V2_SynchLyricsFrameInfoGet

TagsReader.ID3V2_SynchLyricsFrameInfoNumGet

Terms of use frames

USER

Yes

TagsReader.ID3V2_TermsOfUseFrameGet

TagsReader.ID3V2_TermsOfUseFrameLanguageGet

Unsynchronized lyrics frames

USLT

Yes

TagsReader.ID3V2_UnsynchLyricsFrameGet

TagsReader.ID3V2_UnsynchLyricsFrameInfoGet

 

Support for other frames not available in the list above may be added in future versions of the component so, in case you should need the support of a specific frame, feel free to contact our technical support team.

 

The "Multiple" column specifies if more than one frame, having the same identifier, can be available inside the tag; in order to know how many frames are available for a specific identifier, you should use the ID3V2_FrameCountGet method. If for example you should need enumerating pictures stored inside the tag, you could do something similar:

 

Visual Basic 6

 

' perform tags analysis

Dim nTagFormat As enumTagAvailable

nTagFormat = Amp3dj1.TagsReader.ALL_AnalyzeSoundOnPlayer(0)

If nTagFormat And TAG_FLAG_ID3V2 Then

   ' check the availability of embedded pictures through the search of "APIC" frames

   Dim nAvailablePictures as Long

   nAvailablePictures = Amp3dj1.TagsReader.ID3V2_FrameCountGet("APIC")

 

   ' output each picture's description

   Dim nIndex as Long

   For nIndex = 0 to nAvailablePictures - 1

      Debug.Print Amp3dj1.TagsReader.ID3V2_PictureFrameInfoGet (nIndex, ID3V2_FRAME_INFO_DESCRIPTION)

   Next nIndex

End If

 

 

Visual C++

 

// perform tags analysis

long nTagFormat = Amp3dj1.GetTagsReader().ALL_AnalyzeSoundOnPlayer(0);

if(nTagFormat & TAG_FLAG_ID3V2)

{

   // check the availability of embedded pictures through the search of "APIC" frames

   long nAvailablePictures = Amp3dj1.GetTagsReader().ID3V2_FrameCountGet(_T("APIC"));

 

   // output each picture's description

   for (long nIndex = 0; nIndex < nAvailablePictures; nIndex++)

      TRACE (Amp3dj1.GetTagsReader().ID3V2_PictureFrameInfoGet (nIndex, ID3V2_FRAME_INFO_DESCRIPTION) + _T("\r\n"));

}

 

 

Identifiers of frames available inside the ID3V2 tag can be enumerated using the combination of the TagsReader.ID3V2_UniqueFramesCountGet and TagsReader.ID3V2_UniqueFramesIdGet methods.

 

 

LYRICS3

 

The Lyrics3 v2.00 tag resides between the audio and the ID3V1 tag, which must be present. The tag uses only text for everything from content to size descriptors, which are represented as numerical strings.

A full description of this tagging format can be found on this link.

 

You can know if the Lyrics3 tag is available by checking the value returned by the TagsReader.ALL_AnalyzeSoundOnPlayer or TagsReader.ALL_AnalyzeSoundFile methods: if it should contain the flag TAG_FLAG_LYRICS3 this would mean that the Lyrics3 tag is available.

 

Text fields of the Lyrics3 tag can be read through the TagsReader.LYRICS3_TextFieldGet method.

The lyrics text can be read through the TagsReader.LYRICS3_LyricsGet method.

The link to the image field can be read through the TagsReader.LYRICS3_ImageLinkGet method.

 

 

WMA
 

You can know if the WMA tag is available by checking the value returned by the TagsReader.ALL_AnalyzeSoundOnPlayer or TagsReader.ALL_AnalyzeSoundFile methods: if it should contain the flag TAG_FLAG_WMA this would mean that the WMA tag is available.

 

The list of supported WMA frames, with related identifiers and methods to access stored information, can be found on the table below:

 

Supported frame types

Frame identifiers

Multiple

Related methods

Text-based frames

You can use predefined identifiers or, in alternative, your own custom ones: a list of predefined identifiers can be found inside the Windows Media Format SDK.

No

TagsReader.WMA_TextFrameGet

Picture frames

WM/Picture

Yes

TagsReader.WMA_PictureFrameBitmapGet

TagsReader.WMA_PictureFrameCountGet

TagsReader.WMA_PictureFrameFileGet

TagsReader.WMA_PictureFrameInfoGet

TagsReader.WMA_PictureFrameMemoryFileGet

TagsReader.WMA_PictureFrameSizeGet

TagsReader.WMA_PictureFrameTypeGet

 

The "Multiple" column specifies that there may be more than one picture frame available inside the tag; you can know how many picture frames are available through the TagsReader.WMA_PictureFrameCountGet method.

 

Identifiers of frames available inside the WMA tag can be enumerated using the combination of the TagsReader.WMA_UniqueFramesCountGet and TagsReader.WMA_UniqueFramesIdGet methods.

 

 

OGG Vorbis

 

Vorbis metadata, called Vorbis comments, supports metadata tags similar to those implemented in the ID3 standard for MP3. All strings are encoded as UTF-8. Music tags are typically implemented as strings of the form "[TAG]=[VALUE]", for instance, "ARTIST=The big band". The tags are case-insensitive, thus typing "ARTIST=The big band" would be the same as "artist=The big band".

 

You can know if the OGG Vorbis tag is available by checking the value returned by the TagsReader.ALL_AnalyzeSoundOnPlayer or TagsReader.ALL_AnalyzeSoundFile methods: if it should contain the flag TAG_FLAG_OGG this would mean that the OGG Vorbis tag is available.

 

Predefined text frames can be read through the TagsReader.OGG_TextFrameGet method.

User defined text frames can be read through the TagsReader.OGG_UserFrameGet method.

 

Identifiers of frames available inside the OGG tag can be enumerated using the combination of the TagsReader.OGG_UniqueFramesCountGet and TagsReader.OGG_UniqueFramesIdGet methods.

 

 

MP4

 

There is no official MPEG standard on how to embed metadata tags in MP4 files. Apple iTunes therefore started to use their own solution in order to be able to store metadata tags. Those iTunes tags quickly became the de-facto standard for metadata tags within MP4 files. Metadata tags within MP4 files are stored within so-called "boxes" (also known as "atoms").

 

You can know if the MP4 tag is available by checking the value returned by the TagsReader.ALL_AnalyzeSoundOnPlayer or TagsReader.ALL_AnalyzeSoundFile methods: if it should contain the flag TAG_FLAG_MP4 this would mean that the MP4 tag is available.

 

The list of supported MP4 frames, with related identifiers and methods to access stored information, can be found on the table below:

 

Supported frame types

Frame identifiers

Multiple

Related methods

Text-based frames

©alb, ©ART, ©aut, aART, tmpo, catg, dsk, disk, ©cmt, ©wrt, cpil, ©day, ©cpy, ©day, ©des, ©inf, ©dir, ©dis, ©too, ©grp, keyw, ©lyr, ©nam, ©url, ©ope, ©fmt, ©src, ©prf, rate, ©prd, ©wrn

No

TagsReader.MP4_TextFrameGet

Picture frames

 

Yes

TagsReader.MP4_PictureFrameBitmapGet

TagsReader.MP4_PictureFrameCountGet

TagsReader.MP4_PictureFrameFileGet

TagsReader.MP4_PictureFrameMemoryFileGet

TagsReader.MP4_PictureFrameMimeGet

TagsReader.MP4_PictureFrameSizeGet

 

The "Multiple" column specifies that there may be more than one picture frame available inside the tag; you can know how many picture frames are available through the TagsReader.MP4_PictureFrameCountGet method.

 

Identifiers of frames available inside the WMA tag can be enumerated using the combination of the TagsReader.MP4_UniqueFramesCountGet and TagsReader.MP4_UniqueFramesIdGet methods.

 

 

APE

 

APE tags are closer to Vorbis comments than ID3 tags. Like Vorbis comments, they are unstructured key/value pairs.

 

You can know if the APE tag is available by checking the value returned by the TagsReader.ALL_AnalyzeSoundOnPlayer or TagsReader.ALL_AnalyzeSoundFile methods: if it should contain the flag TAG_FLAG_APE this would mean that the APE tag is available.

 

Predefined text frames can be read through the TagsReader.APE_TextFieldGet method.

User defined text frames can be read through the TagsReader.APE_UserFieldGet method.

 

Identifiers of frames available inside the APE tag can be enumerated using the combination of the TagsReader.APE_UniqueFramesCountGet and TagsReader.APE_UniqueFramesIdGet methods.

 

 

FLAC

 

FLAC has it's own native tagging system which is mostly identical to that of OGG Vorbis described above, indeed they are sometime called alternately "FLAC tags" and "Vorbis comments". Respect to the Vorbis tagging system, FLAC allows embedding pictures as well as seen for the ID3V2, WMA and MP4 formats.

 

You can know if the FLAC tag is available by checking the value returned by the TagsReader.ALL_AnalyzeSoundOnPlayer or TagsReader.ALL_AnalyzeSoundFile methods: if it should contain the flag TAG_FLAG_FLAC this would mean that the FLAC tag is available.

 

The list of supported FLAC frames can be found on the table below:

 

Supported frame types

Multiple

Related methods

Text-based frames

No

TagsReader.FLAC_TextFrameGet

Picture frames

Yes

TagsReader.FLAC_PictureFrameBitmapGet

TagsReader.FLAC_PictureFrameCountGet

TagsReader.FLAC_PictureFrameFileGet

TagsReader.FLAC_PictureFrameInfoGet

TagsReader.FLAC_PictureFrameMemoryFileGet

TagsReader.FLAC_PictureFrameSizeGet

TagsReader.FLAC_PictureFrameTypeGet

 

The "Multiple" column specifies that there may be more than one picture frame available inside the tag; you can know how many picture frames are available through the TagsReader.FLAC_PictureFrameCountGet method.

 

Identifiers of frames available inside the FLAC tag can be enumerated using the combination of the TagsReader.FLAC_UniqueFramesCountGet and TagsReader.FLAC_UniqueFramesIdGet methods.

 

 

WAV Chunks

 

WAV files are based upon the RIFF format which consists entirely of "chunks"; some of these chunks allows storing metadata; Active DJ Studio supports reading the following types of chunks:

 

CART
BEXT
DISP
LIST INFO

 

You can know if any of the chunks above are available by checking the value returned by the TagsReader.ALL_AnalyzeSoundOnPlayer or TagsReader.ALL_AnalyzeSoundFile methods: if it should contain the combination of any of the following flags, this would mean that the chunks are available: TAG_FLAG_WAV_CART, TAG_FLAG_WAV_BEXT, TAG_FLAG_WAV_DISP and TAG_FLAG_WAV_LIST_INFO.

 

 

CART Chunk

 

The CART chunk contains fields and attributes that a large number of broadcast systems use to describe an audio file. Its full specifications can be found inside the CartChunk.org web site.

 

You can know if the CART chunk is available by checking the value returned by the TagsReader.ALL_AnalyzeSoundOnPlayer or TagsReader.ALL_AnalyzeSoundFile methods: if it should contain the flag TAG_FLAG_WAV_CART this would mean that the CART chunk is available.

 

Text fields can be read through the TagsReader.WAV_CartChunkTextFieldGet method.

Time markers can be read through the TagsReader.WAV_CartChunkTimeMarkerFieldGet method.

 

 

BEXT Chunk

 

The BEXT chunk (“Broadcast Audio Extension”) adds to the RIFF format extra parameters needed for the exchange of material between broadcasters.

 

You can know if the BEXT chunk is available by checking the value returned by the TagsReader.ALL_AnalyzeSoundOnPlayer or TagsReader.ALL_AnalyzeSoundFile methods: if it should contain the flag TAG_FLAG_WAV_BEXT this would mean that the BEXT chunk is available.

 

Text fields can be read through the TagsReader.WAV_BextChunkTextFieldGet method.

Binary fields can be read through the TagsReader.WAV_BextChunkBinaryFieldGet method.

 

 

DISP Chunk

 

The DISP chunk allows entering a text string to display on the user interface when the WAV file is loaded.

 

You can know if the DISP chunk is available by checking the value returned by the TagsReader.ALL_AnalyzeSoundOnPlayer or TagsReader.ALL_AnalyzeSoundFile methods: if it should contain the flag TAG_FLAG_WAV_DISP this would mean that the DISP chunk is available.

 

The text field can be read through the TagsReader.WAV_DisplayChunkTextGet method.

 

 

LIST INFO Chunk

 

The LIST chunk can contain a list of frames (sub-chunks) of type INFO, each of them containing a different text string. As for other kinds of chunks, each INFO frame is defined by a four characters identifier (FOURCC). Some identifier has already been standardized by the EXIF 2.3 specification (for esample 'IART' for 'Artist', 'ICMT' for 'Comments' or 'ICOP' for 'Copyright'), but the user may create new custom ones.

 

You can know if the LIST INFO chunk is available by checking the value returned by the TagsReader.ALL_AnalyzeSoundOnPlayer or TagsReader.ALL_AnalyzeSoundFile methods: if it should contain the flag TAG_FLAG_WAV_LIST_INFO this would mean that the LIST INFO chunk is available.

 

Identifiers of INFO frames available inside the LIST chunk can be enumerated using the combination of the TagsReader.WAV_ListInfoChunkUniqueFramesCountGet and TagsReader.WAV_ListInfoChunkUniqueFramesIdGet methods.

 

Single INFO frames can be read through the TagsReader.WAV_ListInfoChunkFrameGet method.

 

 

 

Samples of usage of tags editing through the TagsReader object in Visual C++ and Visual Basic 6 can be found inside the following samples installed with the product's setup package:

- TagsReader