Introduction
Ever wanted to make a program to organize your MP3s, or just wanted to implement a feature in your existing application for viewing details about an MP3 file? If so, then the CMP3Info
class is for you. It provides a simple method of accessing an MP3's ID3 tag (artist, title, album...) as well as several details concerning the MP3 data itself--the length of the song, the MPEG encoding type, bit rate, sample rate, channel mode, etc. Simply put, you can retrieve all the information you need about an MP3 file, except for the MP3 data itself... :), by using the intuitive interface provided by the CMP3Info
class.
An excerpt from the header is shown below, describing the main functions of the class:
CMP3Info(CString strFile = "");
virtual ~CMP3Info();
BOOL Open(CString strFile);
BOOL WriteID3V1(CString strDestFile, BOOL bClear...);
void Clear();
void SetArtist(CString strArtist);
void SetTitle(CString strTitle);
void SetAlbum(CString strAlbum);
void SetComment(CString strComment);
void SetYear(CString strYear);
void SetTrack(int nTrack);
void SetGenreIndex(int nGenre);
CString GetFileName() const;
DWORD GetValidity() const;
CString GetArtist() const;
CString GetTitle() const;
CString GetAlbum() const;
CString GetComment() const;
CString GetYear() const;
int GetTrack() const;
int GetGenreIndex() const;
UINT GetNumFrames() const;
UINT GetLength() const;
ENMPEGVER GetMPEGVersion() const;
int GetMPEGLayer() const;
BOOL HasCRC() const;
int GetBitRate() const;
int GetSampleRate() const;
ENCHANNELMODE GetChannelMode() const;
ENEMPHASIS GetEmphasis() const;
BOOL IsCopyrighted() const;
BOOL IsOriginal() const;
static CString GetGenreString(int nIndex);
static CString GetLengthString(int nSeconds);
As you can see, the class is pretty simple, and is rather small.
Notes
- A Unicode version hasn't yet been implemented
- The algorithm for retrieving the MP3 frame information is mostly taken from MPEG Audio Frame Header
- NOT ALL TYPES OF MP3 FILES HAVE BEEN THOROUGHLY TESTED
- USE AT YOUR OWN RISK, I AM NOT LIABLE FOR DAMAGES
History
- 12th June, 2002 - Updated demo to include missing .rc file
License
This article has no explicit license attached to it, but may contain usage terms in the article text or the download files themselves. If in doubt, please contact the author via the discussion board below.
A list of licenses authors might use can be found here.