Click here to Skip to main content
12,510,594 members (46,231 online)
Click here to Skip to main content
Add your own
alternative version


72 bookmarked

CMP3Info - implementation for retrieving information about MP3 files

, 11 Jun 2002
Rate this:
Please Sign up or sign in to vote.
CMP3Info is a class which makes it simple for an application to gain easy access to an MP3's information (not its actual data) and its ID3 v1 tag

Example Screenshot


Ever wanted to make a program to organize your MP3's, 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 = "");   // constructor, calls Open if 
virtual ~CMP3Info();              //    strFile is not ""

// operations
BOOL Open(CString strFile);	      // opens a file

// writes or clears the ID3v1 tag to (the/a) file
BOOL WriteID3V1(CString strDestFile, BOOL bClear...);	

void Clear();

void SetArtist(CString strArtist);    // self-explanatory, eh?
void SetTitle(CString strTitle);
void SetAlbum(CString strAlbum);
void SetComment(CString strComment);
void SetYear(CString strYear);
void SetTrack(int nTrack);

// see the global array in MP3Info.h for a list of genre
void SetGenreIndex(int nGenre); 

// attributes
// get the name of the file that was Open'd
CString GetFileName() const; 

// retrieve a bitmask of valid parts of the MP3 (frames/ID3 tag)
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;

// see the enumerations for more info
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;

// functions
// get string for a genre index in the array
static CString GetGenreString(int nIndex);

// create a string 'mm:ss' from the length
static CString GetLengthString(int nSeconds);

As you can see, the class is pretty simple, and is rather small.


  • A Unicode version hasn't yet been implemented
  • The algorithm for retrieving the MP3 frame information is mostly taken from: MPEG Audio Frame Header


12 June 2002 - updated demo to include missing .rc file.


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


About the Author

Roman Nurik
Web Developer
United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

QuestionHow can I retrieve a mp3 file's duration time? Pin
congcong.zhao23-Sep-12 20:04
membercongcong.zhao23-Sep-12 20:04 
QuestionHow can i add a new field? Pin
k1488_sk8erboy14-Jul-08 2:18
memberk1488_sk8erboy14-Jul-08 2:18 
Generalusing on eVC++ [modified] Pin
kimhoontae15-Nov-07 19:36
memberkimhoontae15-Nov-07 19:36 
GeneralRe: using on eVC++ Pin
Roman Nurik15-Nov-07 22:03
memberRoman Nurik15-Nov-07 22:03 
GeneralInsert message digest in id3 tag Pin
Anonymous4-Feb-04 23:54
sussAnonymous4-Feb-04 23:54 
GeneralRe: Insert message digest in id3 tag Pin
Roman Nurik15-Nov-07 22:04
memberRoman Nurik15-Nov-07 22:04 
QuestionHow to judge Bit Rate is constant or variable? Pin
LinusWu12-Nov-03 20:53
memberLinusWu12-Nov-03 20:53 
Generalsorry, about ID3V2 Pin
Roman Nurik31-Jan-03 11:50
memberRoman Nurik31-Jan-03 11:50 
GeneralError in de demo project and Pin
BoscoW30-Jan-03 23:44
memberBoscoW30-Jan-03 23:44 
GeneralRe: Error in de demo project and Pin
Roman Nurik31-Jan-03 11:45
memberRoman Nurik31-Jan-03 11:45 
GeneralRe: Error in de demo project and Pin
Edwina25-Apr-03 3:55
memberEdwina25-Apr-03 3:55 
GeneralRe: Error in de demo project and Pin
Roman Nurik25-Apr-03 6:07
memberRoman Nurik25-Apr-03 6:07 
GeneralRe: Error in de demo project and Pin
edwina25-Apr-03 12:57
memberedwina25-Apr-03 12:57 
GeneralRe: Error in de demo project and Pin
lucy4-May-04 3:26
memberlucy4-May-04 3:26 
GeneralRe: Error in de demo project and Pin
wangxiaosmile31-Aug-06 3:19
memberwangxiaosmile31-Aug-06 3:19 
QuestionBug in BitRate matrix? Pin
pci3-Dec-02 18:55
memberpci3-Dec-02 18:55 
Questionhow to read ID3V2?? Pin
NeverGrief30-Nov-02 10:22
memberNeverGrief30-Nov-02 10:22 
AnswerRe: how to read ID3V2?? Pin
Christian Graus30-Nov-02 10:34
memberChristian Graus30-Nov-02 10:34 
GeneralRe: how to read ID3V2?? Pin
NeverGrief30-Nov-02 12:27
memberNeverGrief30-Nov-02 12:27 
GeneralRe: how to read ID3V2?? Pin
Christian Graus30-Nov-02 12:40
memberChristian Graus30-Nov-02 12:40 
GeneralRe: how to read ID3V2?? Pin
NeverGrief30-Nov-02 12:48
memberNeverGrief30-Nov-02 12:48 
GeneralRe: how to read ID3V2?? Pin
NeverGrief30-Nov-02 12:50
memberNeverGrief30-Nov-02 12:50 
GeneralRe: how to read ID3V2?? Pin
Christian Graus30-Nov-02 13:06
memberChristian Graus30-Nov-02 13:06 
GeneralRe: how to read ID3V2?? Pin
Anonymous4-Dec-02 10:46
sussAnonymous4-Dec-02 10:46 
AnswerRe: how to read ID3V2?? Pin
whizer31-May-03 2:04
memberwhizer31-May-03 2:04 
GeneralRe: test Pin
18-Jul-02 20:44
suss18-Jul-02 20:44 
Questionhow can i... Pin
HJ Kim19-Jun-02 20:25
memberHJ Kim19-Jun-02 20:25 
AnswerRe: how can i... Pin
Roman Nurik30-Jul-02 7:04
memberRoman Nurik30-Jul-02 7:04 
GeneralRe: how can i... Pin
Nnamdi Onyeyiri30-Aug-02 23:39
memberNnamdi Onyeyiri30-Aug-02 23:39 
GeneralSpeed Pin
Yury Goltsman14-Jun-02 2:44
memberYury Goltsman14-Jun-02 2:44 
GeneralRe: Speed Pin
TomM21-Jul-02 4:32
memberTomM21-Jul-02 4:32 
GeneralRe: Speed Pin
TomM21-Jul-02 5:07
memberTomM21-Jul-02 5:07 
GeneralRe: Speed Pin
TomM23-Jul-02 10:02
memberTomM23-Jul-02 10:02 
GeneralRe: Speed Pin
Anonymous8-Nov-02 5:51
sussAnonymous8-Nov-02 5:51 
GeneralRe: Speed Pin
pierrec29-May-03 6:18
susspierrec29-May-03 6:18 
GeneralID3 V2 TAG Pin
piwee13-Jun-02 20:47
memberpiwee13-Jun-02 20:47 
GeneralRe: ID3 V2 TAG Pin
Gile13-Jun-02 21:05
memberGile13-Jun-02 21:05 
GeneralMP3Pro Pin
Albert van Peppen13-Jun-02 3:13
memberAlbert van Peppen13-Jun-02 3:13 
GeneralRe: MP3Pro Pin
Roman Nurik13-Jun-02 9:26
memberRoman Nurik13-Jun-02 9:26 
QuestionBackward compatibility?? Pin
TomM10-Jun-02 7:09
memberTomM10-Jun-02 7:09 
AnswerRe: Backward compatibility?? Pin
Roman Nurik10-Jun-02 13:44
memberRoman Nurik10-Jun-02 13:44 
QuestionWhat I'd really like... Pin
Simon Hughes21-Apr-02 23:15
memberSimon Hughes21-Apr-02 23:15 
AnswerRe: What I'd really like... Pin
Alexander Wiseman12-Jun-02 16:43
memberAlexander Wiseman12-Jun-02 16:43 
GeneralRe: What I'd really like... Pin
Simon Hughes21-Jun-02 2:07
memberSimon Hughes21-Jun-02 2:07 
QuestionAutomation interface? Pin
Daniel Desormeaux18-Apr-02 10:44
memberDaniel Desormeaux18-Apr-02 10:44 
GeneralMP3 Pal Pin
Ravi Bhavnani17-Apr-02 18:50
memberRavi Bhavnani17-Apr-02 18:50 
GeneralRe: MP3 Pal Pin
Geert Delmeiren18-Apr-02 0:57
memberGeert Delmeiren18-Apr-02 0:57 
GeneralRe: MP3 Pal Pin
Matt Newman18-Apr-02 14:34
memberMatt Newman18-Apr-02 14:34 
GeneralRe: MP3 Pal Pin
Minis29-Sep-02 3:21
sussMinis29-Sep-02 3:21 
QuestionID3 V2 ??? Pin
Christian Graus17-Apr-02 18:24
memberChristian Graus17-Apr-02 18:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160929.1 | Last Updated 12 Jun 2002
Article Copyright 2002 by Roman Nurik
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid