ID3 tags library :)

BlitzMax Forums/Brucey's Modules/ID3 tags library :)

Filax(Posted 2009) [#1]
Hi Brucey :)

Just an idea :)

http://www.3delite.hu/Object%20Pascal%20Developer%20Resources/id3v2library.html

Others :
http://www.3delite.hu/Object%20Pascal%20Developer%20Resources/download.html#id3


Regards


Brucey(Posted 2009) [#2]
It's Windows-only, unfortunately...


Brucey(Posted 2009) [#3]
As part of the "Make a Mod in an Evening" festival which was held here today, you may be interested in a new module in the maxmods SVN repository : BaH.TagLib

It supports both ID3v1 and ID3v2 for MP3 files, Ogg Vorbis comments and ID3 tags and Vorbis comments in FLAC, MPC, Speex, WavPack and TrueAudio files.... amongst others.

Sample output from the included example :
******************** "Pink Floyd - 03 Time.mp3" ********************
-- TAG --
title   - "03 Time"
artist  - "Pink Floyd"
album   - "Dark Side Of The Moon"
year    - "0"
comment - ""
track   - "3"
genre   - "Psychedelic Rock"
-- AUDIO --
bitrate     - 128
sample rate - 44100
channels    - 2
length      - 7:05


Only the generic API has been implemented for now, which provides the basic information as above.

Currently tested on Windows and Mac.
License is MPL.

<edit>
NOTE : This requires the lastest SVN-version of BlitzMax, since it uses some of the new Unicode conversion functions.
(At some point I will also be converting all of my own-module unicode functions to use these "official" ones instead, but I'll probably hold off until we get a 1.32 release)
</edit>

As usual, comments, critique and suggestions welcome.

Enjoy.

:o)


Retimer(Posted 2009) [#4]
Heh, I saw this post, then it seemed like only an hour after your first response that the svn had a new treat. Nice work!

Edit: nice choice of music =p


Thareh(Posted 2009) [#5]
I can't get it to compile, I get this error.
"Compile Error: Identifier 'bbStringToUTF8String' not found"
Do I need any other module or something else? :)

Thanks :)


plash(Posted 2009) [#6]
Hmm.. Do you have MinGW installed? Was this module built for the SVN version? (I think it has UTF string support now)


Thareh(Posted 2009) [#7]
Yes I have MinGW installed etc, I downloaded the code from the latest SVN rev :P


Glenn Dodd(Posted 2009) [#8]
same problem here. i download bruceys svn stuff every day.


Brucey(Posted 2009) [#9]
"Compile Error: Identifier 'bbStringToUTF8String' not found"

Ah... yes, you also need to use the latest BlitzMax SVN too, since I'm using BlitzMax's new Unicode friendly functions here - rather than having to duplicate my own as I have done for most of my modules in the past.

If you want to "hack" a fix without having to get all that stuff, you could, in theory add the following code to the bottom of BlitzMax/mod/brl.mod/blitz.mod/blitz.bmx :



Thareh(Posted 2009) [#10]
Oh alright, I'll go get the latest BlitzMax SVN rev, Thanks Brucey :)


plash(Posted 2009) [#11]
That is the SVN I was referring to :D


Brucey(Posted 2009) [#12]
Oh alright, I'll go get the latest BlitzMax SVN rev, Thanks Brucey :)

I realise it's not ideal to rely on "unreleased" additions to BlitzMax, but I if it makes my life a little easier, it's not a terribly bad thing... and I figure many folks who might dabble with my SVN-only modules may be likely to have the SVN-only BlitzMax updates too :-p

Apologies for the confusion anyway... I'll make a note in the post above :-)


Filax(Posted 2009) [#13]
Hi

The start for ID3TAG V1, for ID3TAG V2 i don"'t understand very well the 'frame' stuff



example :




Brucey(Posted 2009) [#14]
If you use BaH.TagLib, you won't need an external DLL, as the library is compiled into your app (MPL instead of LGPL).

As for the 'frame' stuff, I'll get round to implementing that in the module too. Might be nice to be able to extract album covers from the files :-)


Filax(Posted 2009) [#15]
I'll take a look :) Many thanks Brucey :)


Thareh(Posted 2009) [#16]
It appears that I can't load tags with non-english letters, Is there anything I can do about that? :)


Brucey(Posted 2009) [#17]
Are you getting any specific errors?
It should be able to handle conversions on-the-fly.
(not that I've tested this of course...)


Brucey(Posted 2009) [#18]
I just tested this by adding some cyrillic to the comment field of an mp3, and loaded back using the example.
On the console it prints unreadable characters, but if I show the text using Notify, it looks fine - because the IDE's console isn't wide-char friendly. (or perhaps Print isn't....)

So, as far as I am concerned, it is working as expected.
But, I am always ready to be shown otherwise ;-)


Thareh(Posted 2009) [#19]
I'm loading MP3s with 'ÅÄÖ' these characters in the title, but the title returns null. And also if I tried loading a file with any of these characters in the filepath, the file couldn't get read. (Using TTLFileRef.Create( filepath ).
So it's not just that the console prints the characters a bit odd :)


Brucey(Posted 2009) [#20]
Okay, I've committed a fix Win32 which lets you open files with non-ASCII path/filenames.

(Yes... you'd think after my crusade to get Unicode files working in core BlitzMax I'd check it worked in my modules too ;-)


Thareh(Posted 2009) [#21]
Hehe, Thanks a bunch Brucey! :D


Thareh(Posted 2009) [#22]
I seem to get some random crashes using Release mode with this module, When I'm using debug mode it works just fine.

Here's the error message:


Any idea on what might cause this? :)


Thareh(Posted 2009) [#23]
Oh, I didn't release the file after using it.
Also, Rename the Delete method to Remove or something, cause Delete were causing some problems with BlitzMax :P


Brucey(Posted 2009) [#24]
Nothing off the top of my head, although "pure virtual method called" indicates that something may be called in the library that shouldn't be.

There isn't much of the API that I'm currently using.

Any idea what function you might be calling at the time, or if it is a specific file/type?


Thareh(Posted 2009) [#25]
If you didn't see, I found the problem one post up :)


Brucey(Posted 2009) [#26]
Ooops... missed that.. I answered without refreshing, after checking the code.

Oh, I didn't release the file after using it.

Ah... I'll add a Free() method which you can call to release the resource, and remember once it is freed related tag objects etc will be invalidated (by the library, BlitzMax will clean up the references itself when the GC picks them up).


Brucey(Posted 2009) [#27]
Okay, I've added the Free() method to TTLFileRef. You can call this when you are done with the file.

If you don't call it, the file will be freed eventually, once the object goes out of scope and is GC'd, but that time is undetermined...