0
0

Hi all,

Is there a function, sample code to extract tags informations from a mp3 for example?
If someone has it in c++ or a c++ builder project it will be perfect!! 😆

Thanks in advance,

Rangdalf

  • You must to post comments
0
0

Since you are using C++ Builder, you can easily use Delphi code. Here is an example on reading ID3 tags that was posted recently on a Delphi mailing list.
[code:3m2yerm5]
type
TID3Tag = record
ID: string[3];
Titel: string[30];
Artist: string[30];
Album: string[30];
Year: string[4];
Comment: string[30];
Genre: Byte;
end;

const
Genres : array[0..146] of string =
(’Blues’,’Classic Rock’,’Country’,’Dance’,’Disco’,’Funk’,’Grunge’,
‘Hip- Hop’,’Jazz’,’Metal’,’New Age’,’Oldies’,’Other’,’Pop’,’R&B’,
‘Rap’,’Reggae’,’Rock’,’Techno’,’Industrial’,’Alternative’,’Ska’,
‘Death Metal’,’Pranks’,’Soundtrack’,’Euro-Techno’,’Ambient’,
‘Trip-Hop’,’Vocal’,’Jazz+Funk’,’Fusion’,’Trance’,’Classical’,
‘Instrumental’,’Acid’,’House’,’Game’,’Sound Clip’,’Gospel’,’Noise’,
‘Alternative Rock’,’Bass’,’Punk’,’Space’,’Meditative’,’Instrumental
Pop’,
‘Instrumental
Rock’,’Ethnic’,’Gothic’,’Darkwave’,’Techno-Industrial’,’Electronic’,
‘Pop-Folk’,’Eurodance’,’Dream’,’Southern
Rock’,’Comedy’,’Cult’,’Gangsta’,
‘Top 40′,’Christian Rap’,’Pop/Funk’,’Jungle’,’Native US’,’Cabaret’,’New
Wave’,
‘Psychadelic’,’Rave’,’Showtunes’,’Trailer’,’Lo-Fi’,’Tribal’,’Acid Punk’,
‘Acid Jazz’,’Polka’,’Retro’,’Musical’,’Rock & Roll’,’Hard Rock’,’Folk’,
‘Folk-Rock’,’National Folk’,’Swing’,’Fast
Fusion’,’Bebob’,’Latin’,’Revival’,
‘Celtic’,’Bluegrass’,’Avantgarde’,’Gothic Rock’,’Progressive Rock’,
‘Psychedelic Rock’,’Symphonic Rock’,’Slow Rock’,’Big Band’,’Chorus’,
‘Easy Listening’,’Acoustic’,’Humour’,’Speech’,’Chanson’,’Opera’,
‘Chamber Music’,’Sonata’,’Symphony’,’Booty Bass’,’Primus’,’Porn Groove’,
‘Satire’,’Slow Jam’,’Club’,’Tango’,’Samba’,’Folklore’,’Ballad’,
‘Power Ballad’,’Rhytmic Soul’,’Freestyle’,’Duet’,’Punk Rock’,’Drum
Solo’,
‘Acapella’,’Euro-House’,’Dance Hall’,’Goa’,’Drum & Bass’,’Club-House’,
‘Hardcore’,’Terror’,’Indie’,’BritPop’,’Negerpunk’,’Polsk Punk’,’Beat’,
‘Christian Gangsta’,’Heavy Metal’,’Black
Metal’,’Crossover’,’Contemporary C’,
‘Christian Rock’,’Merengue’,’Salsa’,’Thrash
Metal’,’Anime’,’JPop’,’SynthPop’);

var
Form1: TForm1;

implementation

{$R *.dfm}

function readID3Tag(FileName: string): TID3Tag;
var
FS: TFileStream;
Buffer: array [1..128] of Char;
begin
FS := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite);
try
FS.Seek(-128, soFromEnd);
FS.Read(Buffer, 128);
with Result do
begin
ID := Copy(Buffer, 1, 3);
Titel := Copy(Buffer, 4, 30);
Artist := Copy(Buffer, 34, 30);
Album := Copy(Buffer, 64, 30);
Year := Copy(Buffer, 94, 4);
Comment := Copy(Buffer, 98, 30);
Genre := Ord(Buffer[128]);
end;
finally
FS.Free;
end;
end;

procedure TfrmMain.Button1Click(Sender: TObject);
begin
if OpenDialog1.Execute then
begin
with readID3Tag(OpenDialog1.FileName) do
begin
LlbID.Caption := ‘ID: ‘ + ID;
LlbTitel.Caption := ‘Titel: ‘ + Titel;
LlbArtist.Caption := ‘Artist: ‘ + Artist;
LlbAlbum.Caption := ‘Album: ‘ + Album;
LlbYear.Caption := ‘Year: ‘ + Year;
LlbComment.Caption := ‘Comment: ‘ + Comment;
if (Genre >= 0) and (Genre <=146) then
LlbGenre.Caption := ‘Genre: ‘ + Genres[Genre]
else
LlbGenre.Caption := ‘N/A’;
end;
end;
end;
[/code:3m2yerm5]
If you want to use components, then a quick search of [url=http://www.torry.net:3m2yerm5]Torry’s[/url:3m2yerm5] for ‘id3’ comes up with four components that suit both ID3 and ID3v2. Or go to [url=http://www.id3.org/implement.html:3m2yerm5]id3.org[/url:3m2yerm5] and take a look at their links to sample implementations, including this [url=http://id3lib.sourceforge.net/:3m2yerm5]open-source C++ library[/url:3m2yerm5].

[url=http://www.google.com:3m2yerm5]Google[/url:3m2yerm5] is your friend. :)

  • You must to post comments
0
0

Hi Thanks for your answer,

There is no function include in the fmod library?
Ok i will use the torry’s component

Rangdalf

  • You must to post comments
0
0

There is no functionality in FMOD to process ID3 tags.

  • You must to post comments
0
0

Nope. Understand that FMOD is a sound library geared, for the most part, for game development. Knowing this, the answer is logical; what use does a game engine have for ID3 tags?

  • You must to post comments
0
0

EA’s Need for Speed: Hot Pursuit 2 displayed track name, artist and publisher in the lower left corner of the screen for music tracks. That was kinda neat and is a perfect use for ID3 tags.

  • You must to post comments
0
0

Hé sly since you’re using C++ Builder there are some problems reading ID3 tags with above code.

Sometimes it reads the tags wrong.
I solved the problems and made a C++ VCL component to read and write ID3v1 tags.
It also supports v2 tags by calling a DLL which i made in Delphi with the [url:3857bres]http://www.audioxl.com/[/url:3857bres] component.

If you need it just contact me the_djmaze@hotmail.com

  • You must to post comments
0
0
  • You must to post comments
0
0

If you go to http://www.id3.org, theres a section there with components to allow reading / editing of ID3, ID3v2 tags. Windows Media Format SDK has functionality in it to do so.

  • You must to post comments
Showing 8 results
Your Answer

Please first to submit.