Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / desktop / WinForms

Professional Tag Editor for MP3 (ID3) and WMA

4.85/5 (24 votes)
31 May 2009CPOL6 min read 121.4K   987  
Provide libraries and application to manage tagging of ID3 and WMA

Introduction

ProTagEditor/MainDialog.jpg

Now a days, all audio files contain some type of content descriptions. Tagging feature adds some extra information to files, such as, title of song, album name, band logo, artist picture, etc. Each file type has its own structure to store these types of information.

MP3 files use ID3 (Identify an MP3) tagging. ID3 saves at the beginning or end of MP3 files and contains so much information about that. ID3 standard have some versions that each version is different from others. The last version until now is ID3v2.4. But ID3v2.3 is more common.

WMA files contain a specification for storing additional information such as Title, Album, picture, etc. The difference between ID3 and WMA tagging is that WMA natively supports additional information but MP3 file does not. MP3 files just support audio and need additional structure.

In this article, I have some libraries to read and write some WMA objects and ID3. My libraries support:

  • ID3v1
  • ID3v2.2
  • ID3v2.3
  • ID3v2.4
  • WMA Branding Object
  • WMA Content Description
  • WMA Extended Content Description

Because they are additional information to audio and they are not audio signals, we call them Tag information.

The .NET solution contains four projects:

  1. Tag: This project contains classes needed to read and write tag information.
  2. TagInfoControls: Provides many controls to view and edit Tag information and these controls can be used to design a professional Tag editor in just a minute.
  3. TagEditor: This is an application used in both previous projects to make a complete and professional ID3 and WMA tag editor.
  4. Setup: Makes setup to install and enjoy everything.

There are some samples for each type of project and how to use them. Here I have explained how this class works and how everyone can use it to view or edit tag information.

Some main features of current Editor are: 

  • Edit many files together 
  • Easy lyric editor 
  • Rename Files automatically according to their tag information with formula
  • Save some information as template and set the template to many files
  • Support right-to-left languages

In fact, this is the improved version of my previous article about ID3v2 on CodeProject. This article is also available on SourceForge.

Background

MP3 files don't have any trick to store additional information with them. So there is a data structure named ID3 to store this type of information with MP3 files. The story about the WMA files is different. They have a structure to store this type of information with them.

ID3 has different versions and the main reference for ID3 is www.ID3.org. The web site provides all information about all versions of ID3 and is available for everyone to download.

In fact, WMA files are ASF files. WMA is just an extension for ASF audio files. The ASF was developed by Microsoft and you can download the specification here.

To understand codes of this article, it is necessary to at least have basic information about ID3 and WMA files. But to use the codes of design tag editor with controls, there is no need to understand how ID3 and WMA files work.

Also there is some global information about both WMA and ID3 structure in my previous article on CodeProject and Sourceforge.

How TagEditor Works

As I read the specification of ID3 structure, I understood that there is so much likeness between ID3 different frames. As an example, all ID3 text information like "Title", "Artist Name", "Band Name" and so many other data don't have different structures.

Some tags have inheritable structure. One tag has information that the second one has the same in addition with another parts.

So it's rational to use classes to read and write ID3 information. For those tags that have similar structure, we use one class and for those that have inheritable structure, we use inheritance in classes.

The picture below shows the class structure of ID3v2.X tag editor. As you can see, all classes inherits Frame class as the main. Frame class is the heart of ID3v2 reading and writing.

ProTagEditor/InheritedDirectly.png

ProTagEditor/InherisUndirect.png

The same way is used for WMA files, but WMA has less classes.

Professional Tag Editor Features

Ready Controls

This library lets you create Full feature professional tag editor in just a minute because it contains many ready controls that can be used to make a tag editor.

For example, the picture below shows the TextInformation dialog of Professional Tag Editor application. This dialog just used ready TextInformation control in the controls project.  

ProTagEditor/TextInformation.jpg

ProTagEditor/AttachedPictures.jpg

Picture editor control that lets you manage attached image of MP3 files.

Automatic Rename

As it's very common to manage MP3 files, it's common to rename them. Sometimes renaming file is a time consuming work. So this application and classes let you rename files according to a special formula and the tag information of file. You can say rename file to "Artist Name - Track Number" as an example.

Loading Filter

There are so many times that you just want to read a special part of tag info. For example, you have an MP3 player application and you just want to read Title of song and Album name and there is no need to read every other information that the file includes. Professional Tag Editor lets you filter name of frames that you want to read or you don't want to read.

Template Support

The code supports using templates. You can store special ID3 or WMA information as a template and load it to every file you need. For example a publishing company always needs to add publisher text so they can use a template to store publisher information such as name, logo, pictures, web address, etc. and always copy that template to their release files.

Template is supported by professional tag editor application and all classes.

The picture below shows the template dialog of professional tag editor application:

ProTagEditor/TemplateEditor.jpg

Lyric

There is special support for lyric editing. There is a special control to manage synchronized and unsynchronized lyric. The picture shows a synchronized lyric editor control that is used inside a professional tag editor application.

ProTagEditor/Lyric.png

Unicode Support

I've tried to support right to left languages in every place of the application. Everywhere you can use Unicode as text. The application saves information in minimum length, or you can select encoding type.

Anywhere that you can use long text such as lyrics, there are features to user RTL languages and controls remember that language as RTL.

Try to Support Everything

ID3 contains many aspects that are not used with most applications. One of them is a general encapsulated file. This ID3 feature lets you add additional files to your MP3 file without concern about file type. These features are supported by my libraries but I really don't know the usage. One of my friends said if you attach too many images to an MP3 file, you can make a video extension! This feature is like that, I think.

Error Management

Some times tags contains some error and can't read properly. In this situation, classes let you know the occurred error and manage the errors.

Sample Code

Sample codes let you know how to use this library and they provide most aspects of using Professional Tag Editor.

More.........

For more information about this application and libraries, you can visit http://professionaltag.sourceforge.com.

History

  • 31st May, 2009: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)