Author Topic: Tags Library  (Read 62482 times)

3delite

  • Posts: 895
Re: NEW: Tags Library
« Reply #150 on: 22 Feb '15 - 23:05 »
Yes, from the official home page.

Ok.

BTW. forgot that WavPack and MusePack attribute parsing is off by default. It can be enabled with:

Code: [Select]
Const
    TAGSLIBRARY_PARSE_WAVPACK_AUDIO_ATTRIBUTES                      = 5;
    TAGSLIBRARY_PARSE_MUSEPACK_AUDIO_ATTRIBUTES                     = 6;

    TagsLibrary_SetConfig(nil, 1, TAGSLIBRARY_PARSE_WAVPACK_AUDIO_ATTRIBUTES, ttAutomatic);
    TagsLibrary_SetConfig(nil, 1, TAGSLIBRARY_PARSE_MUSEPACK_AUDIO_ATTRIBUTES, ttAutomatic);

before creating a tags instance.

EWeiss

  • Posts: 342
Re: NEW: Tags Library
« Reply #151 on: 22 Feb '15 - 23:28 »
good to hear ;)

i'm testing TMPEGAudioAttributes after i give a Feedback.

greets

EWeiss

  • Posts: 342
Re: NEW: Tags Library
« Reply #152 on: 22 Feb '15 - 23:43 »
please see Picture

Position is different from Delphi
should be 465542 by me 46,5542 (DWord? instead of Int64) so i can use Long for that

Header is different from Delphi
ModeExtension are wrong (Forget set it to 4 Bites?) hmmm. works and not, dependent on files see 2.png

all other from TMPEGAudioAttributes works.

anyway any misstake in CoverArt..
i can do it with GDI+ or the best way give me a Array of Bytes so i can draw the Picture
over scanline without any Picture Types like bmp, jpg, png.

greets
« Last Edit: 27 Feb '15 - 02:26 by EWeiss »

3delite

  • Posts: 895
Re: NEW: Tags Library
« Reply #153 on: 23 Feb '15 - 00:59 »
About the cover art: I can not do any decoding of pictures, I don't want to add dependencies for various picture file formats.
But I added 2 new functions:

  • TagsLibrary_GetCoverArtToFile()
  • TagsLibrary_SetCoverArtFromFile()

So it is hopefully possible now for VB to extract cover arts to a temporary file and load them from there. Yes I know it's not that nice but at least possible.
The functions are not tested, finished them just now.

The functions are not added to the VB header, I'm waiting for a currently working one, so I can add these then.

The package can be downloaded from the first post (had to update the release, because I forgot to update the Delphi units :))

The TagsLibrary_SetCoverArtFromFile() function is to be used by:

Quote
       Set cover art specified by 'Index' from file specified by 'FileName'
   Before calling this function add a cover art with the TagsLibrary_AddCoverArt() function with CoverArt.Data = nil and CoverArt.DataSize = 0 and use the 'Index' returned.
       Try to fill in all the attributes in 'CoverArt', although not all are needed for all the tag types.

EWeiss

  • Posts: 342
Re: NEW: Tags Library
« Reply #154 on: 23 Feb '15 - 01:16 »
Quote
So it is hopefully possible now for VB to extract cover arts to a temporary file and load them from there. Yes I know it's not that nice but at least possible.
should better then add GDI+ only for handle the CoverArt with VB
the best Temporary File should be *.bmp convert is this possible?

Quote
The functions are not added to the VB header, I'm waiting for a currently working one, so I can add these then.
should been remove TagsLibrary_GetAudioAttribute? or leave it.

thanks

greets

EWeiss

  • Posts: 342
Re: NEW: Tags Library
« Reply #155 on: 23 Feb '15 - 01:41 »
Quote
I'm waiting for a currently working one, so I can add these then.

Add..

TagsLibrary_GetCoverArtToFile()
TagsLibrary_SetCoverArtFromFile()
TagsLibrary_GetTagSize()
TagsLibrary_GetAudioFormat()
TagsLibrary_GetAudioFormatMemory()
TAudioFileFormat

please..

if that correctly?
Code: [Select]
If TagsLibrary_GetCoverArtToFile(Tags.LngTags, ttAutomatic, Tags.CoverArtIndex, Tags.CoverArtName) Thenif so how can get now the Picture?or ist the Filename include Path ?
ok i see your save the Picture to the same path as read the tag from it.
only one Problem without Extension.

why CoverArtData.Width and CoverArtData.Height allways 0?
that is hard use CoverArtData.Data for read the Picture from Memory

and please Change TMPEGAudioAttributes
Position: Int64; to DWord so i can use Long

File remove

greets
« Last Edit: 25 Feb '15 - 06:09 by EWeiss »

EWeiss

  • Posts: 342
Re: NEW: Tags Library
« Reply #156 on: 23 Feb '15 - 04:28 »
CoverArt works on this way

Code: [Select]
       If Tags.CoverArtData <> 0 Then
            If Tags.GetCoverArtToFile(ttAutomatic, Tags.CoverArtIndex, Tags.CoverArtName) Then
                Path = Tags.GetPath(txtFilename.Text) + LPWSTRtoBSTR(Tags.CoverArtName)
                Name Path As Path & ".bmp"
                Path = Path + ".bmp"
                Image1.Picture = LoadPicture(Path)
                Kill Path
            End If
        End If

i can remove this line if you add the Extension to the FileName bevor saving (should be *.bmp) ;)
Code: [Select]
               Name Path As Path & ".bmp"
                Path = Path + ".bmp"

on the other hand
can I load without extension
no Problem

File Remove

greets
« Last Edit: 27 Feb '15 - 02:26 by EWeiss »

Steve Grant

  • Posts: 136
Re: NEW: Tags Library
« Reply #157 on: 23 Feb '15 - 09:30 »
Everything seems to be working for me except:

Just occasionally I am getting an 'Out Of Memory' error. If I go back to an earlier TagsLib.dll then, although I lose the new functions, I don't get the error.

My TagsLib.dll is in the Program Files\My Application\Decoders folder. That is where TagsLib is saving the Picture to. If the user has User Account Control on (and they should) then we should not be writing to this area. Can we have a SetPictureFilePath function please.

@Emil: For me the format of the picture is always jpg (checked with IrfanView) and the picture loads fine into both an Image Control and a PictureBox.

I will do more testing regards the 'Out Of Memory' error. I will also do a reboot in case some code writing errors have accumulated.

Regards - Steve.

Steve Grant

  • Posts: 136
Re: NEW: Tags Library
« Reply #158 on: 23 Feb '15 - 11:39 »
Quite by chance, I've found a track that is so wrong with the bitrate, it may give you a chance to find out how other programmes do it.

TagLib.dll reports this file as 56Kbps when actually it is 228kbps. As reported by dbPA, FB2K, mp3Tag.

https://dl.dropboxusercontent.com/s/teuylglnqay6jm4/TestTrack.zip?dl=1

I've had no more occurrences of the 'Out Of Memory' error, but I am very busy and cannot be on here all the time.

Regards - Steve.
« Last Edit: 23 Feb '15 - 11:48 by Steve Grant »

3delite

  • Posts: 895
Re: NEW: Tags Library
« Reply #159 on: 23 Feb '15 - 14:24 »
An alternative solution for loading cover arts came to my mind without need for temporary files.

There is a FreeImage library which comes with a VB header, which can load pictures from memory. I use it in many of my projects, I can recommend it, it's one of the fastest JPEG loading engines, and instantly gives support of all the cover art file formats.

Using freeimage to bring in a picture but a reduced version into a picture box
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_21205357.html

There's one thing, that you have to use the memory loading functions, not the file related, something like:

Code: [Select]
Dim MemoryHandle As Long
Dim ImageFormat As Long
Dim pDIB As Long

MemoryHandle = FreeImage_OpenMemory(CoverArt.Data, CoverArt.DataSize);
ImageFormat = FreeImage_GetFileTypeFromMemory(MemoryHandle, 0);
pDIB = FreeImage_LoadFromMemory(ImageFormat , MemoryHandle, 0);
... rest according to links

Regarding the MPEG VBR issue: In case the file is reported as VBR then you can calculate the average bit rate yourself, something like:

Code: [Select]
Dim MPEGAudioAttributes As TMPEGAudioAttributes
Dim MPEGBitRate As Long
Dim TagsSize As Long

TagsSize = TagsLibrary_GetTagSize(Tags, ttAutomatic)
TagsLibrary_GetAudioAttributes(Tags, atMPEG, VarPtr(MPEGAudioAttributes))
if MPEGAudioAttributes.VBR then
    MPEGBitRate = ((FileSize - TagsSize) / PlayTime / 125) + 0.5
end;

I would recommend, as I already did, getting the PlayTime with BASS as it's more reliable.
Note that TagsLibrary_GetTagSize() is not yet defined in the VB header, as it was added recently, it should be something like:

Code: [Select]
Public Declare Function TagsLibrary_GetTagSize Lib "TagsLib.dll" (ByVal Tags As Long, ByVal TagType As TTagType) As Long
« Last Edit: 23 Feb '15 - 14:32 by 3delite »

Steve Grant

  • Posts: 136
Re: NEW: Tags Library
« Reply #160 on: 23 Feb '15 - 15:14 »
New Method for Bitrate works perfectly. So far it is in complete alignment with my other programmes. It is surprising sometimes just how big the tag is!

Haven't tried the load from memory picture yet. I will wait for code from Emil. However I must say there is nothing wrong with writing and then reading from disk - it is instant!

All we need now is the ability to tell the dll where to store the image.

3delite (I wish I knew your name) ,many thanks for your work on this. The library is superb.

Best Regards - Steve.

EWeiss

  • Posts: 342
Re: NEW: Tags Library
« Reply #161 on: 23 Feb '15 - 15:51 »
Quote
I will wait for code from Emil.

i have upload it here
http://www.un4seen.com/forum/?topic=15754.msg114272#msg114272
and the new VB TagsLibraryDefs here
http://www.un4seen.com/forum/?topic=15754.msg114271#msg114271

Quote
@Emil: For me the format of the picture is always jpg

yes  ;D

Quote
There is a FreeImage library which comes with a VB header
that will not work if you not Change Int64 to DWord = Long

CoverArt.DataSize = Currency = 6,312
should be 6312
i tell you for this mistake many often without a answer from you

same Trouble with Int64 on other place


Quote
Note that TagsLibrary_GetTagSize() is not yet defined in the VB header, as it was added recently, it should be something like:
Boahh.. you read my Post ?
I have upload the new VB Header  :o
http://www.un4seen.com/forum/?topic=15754.msg114271#msg114271

ok. I'm out of the thread.. sorry

greets
« Last Edit: 25 Feb '15 - 06:12 by EWeiss »

Steve Grant

  • Posts: 136
Re: NEW: Tags Library
« Reply #162 on: 23 Feb '15 - 21:02 »
Hi 3delite, it looks like we have lost Emil :( . I hope it wasn't me.

I have downloaded FreeImage. 2 things, 1) It is HUGE. It is actually bigger than my distro. 2) The wrapper is full of errors. This surprises me as there are people on their forum who are clearly using VB6. I am sure I could contact them and get a working module, but, due to the size, I don't want to. Are you able to provide a function to tell the dll where to save the picture?

Just found that no Tag of any kind is written to MusePack. (mpc)

Thanks once again - Steve.
« Last Edit: 23 Feb '15 - 23:24 by Steve Grant »

EWeiss

  • Posts: 342
Re: NEW: Tags Library
« Reply #163 on: 24 Feb '15 - 06:47 »
@Steve Grant
I wanted to help
but it does not seem to be desirable.

I have given a lot of Information (as @None, as @EWeiss and so on)
so that his library is compatible with VB.
He seems not to understand (or will not)

Int64 is not compatible to VB
Quote
currency is abused
and operates under VB6 with INT64/UInt64 only as Container
so that the size of the record remains the same
he does not seem to understand it

Width and Height is return always 0 for CoverArt
ModeExtension on any Files are more then 0 so Fails
and many other Errors.

If one has no knowledge of Vb6 and Delphi
Then you should close support for vb6
My Opinion (without help it will not work)

My time is too precious than that I was wasting
if my help is not wanted. sorry

greets
« Last Edit: 24 Feb '15 - 07:22 by EWeiss »

Steve Grant

  • Posts: 136
Re: NEW: Tags Library
« Reply #164 on: 24 Feb '15 - 08:54 »
Hi Emil,

I think your input is highly desirable and perhaps you have not realised the significant contribution you have already made to this project.

Were 3delite to abandon support for VB6, what would we use that gave this level of tagging abilities? I used to be in favour of AudioGenie and collaborated with Stefan on the Wavpack format. However once he decided to pass it onto Sourceforge, it has become stagnant with no support for modern formats. Picture support is almost non-existent!

I believe 3delite will get there, after all, he is charging for a license for this product and the better it is, with the widest support, the more he will sell.

Remember he openly says he knows nothing about VB, so you are teaching him at the same time you are teaching me.

Why not stay around a little longer and see how things play out?

Greets - Steve.

EWeiss

  • Posts: 342
Re: NEW: Tags Library
« Reply #165 on: 24 Feb '15 - 09:24 »
Quote
Why not stay around a little longer and see how things play out?

ok still in the Background
come back after reported mistake are fixed

you can see on the Picture what is wrong

greets
« Last Edit: 26 Feb '15 - 03:43 by EWeiss »

Steve Grant

  • Posts: 136
Re: NEW: Tags Library
« Reply #166 on: 24 Feb '15 - 15:21 »
Hi , I am no longer able to read tags from mp3 in ttAutomatic mode. I am sure I could previously. Do I need to turn these on as well.

Steve.

UPDATE. The coding I am currently working on has not yet been converted to an .exe. So I ran yesterdays .exe which still uses the up-to-date dll (1.0.37.68) and that is reading mp3's fine.

I am just calling a function called GetTags with the filename. So no differences between formats there other than the extension. I will experiment some more and come back to you.

OK forget this post. I am trying to do too many things today. Everything is fine.
« Last Edit: 24 Feb '15 - 16:37 by Steve Grant »

Steve Grant

  • Posts: 136
Re: NEW: Tags Library
« Reply #167 on: 24 Feb '15 - 21:58 »
I think I can help a little further with MusePack. It is detected by the dll as 4 - MPEG.

The Vorbis bitrate is returned as 132,000 instead of 132.

MPEG still shows an mp3 with a sampling rate of 32000. Instead of 44100. (All my test files are conversions from the same 44100 16 bit Wave.)

Steve.

3delite

  • Posts: 895
Re: NEW: Tags Library
« Reply #168 on: 24 Feb '15 - 22:04 »
No offense! You are writing a lot of posts, I try to understand and fix everything I can.

When extracting the cover art to file, you should use the Windows default temp folder: GetTempPath
Append the desired file name to it. Tags Library supports a complete path with file name.

To determine the format of the cover art (to append a proper extension) use the TagsLibrary_GetCoverArt() function before TagsLibrary_GetCoverArtToFile().
TCoverArtData.PictureFormat reports the format if it's JPEG, PNG, GIF or BMP (these are most common) and you can append the proper extension.

TCoverArtData.Width and TCoverArtData.Height is only reported for certain formats, like Flac, it is read from the tag, not the picture itself. But I think it's rarely needed. You can get the dimensions after loading the picture anyway.

About the Int64 problem: I added an Int64 data type to the VB header (thank you very much for posting it!).
It's a record with a 'LowPart As Long' and a 'HighPart As Long' values. In most cases you can use the LowPart. HighPart will only contain non-zero value if the Int64 value is larger then 2^32 (for huge files).
There some helper function and more info at the end of the VB header.
Hopefully this solves the In64 problem.

TMPEGAudioAttributes.ModeExtension is hopefully fixed in the update. If there was no ModeExtension the variable contained a random number (as it was not filled).

TMPEGAudioAttributes.Header is the raw MPEG header, it seems as a random number when displayed, there's no need to display it, all the information it contains are available from the rest of the structure.

The VB demo can't start, I get an error 'MSCOMCTL.OCX' can not be found, but I put the demo in the release.

EWeiss thank you for yor help, I try to fix all that's possible, please understand, it's much code (41200 lines) of course there are bugs in it, sorry for that!

The update 1.0.38.69 can be downloaded from the link in the first post.

Steve Grant

  • Posts: 136
Re: NEW: Tags Library
« Reply #169 on: 24 Feb '15 - 22:09 »
Well if I don't report things as I find them, you won't be able to fix them. Don't worry you won't hear from me again.

3delite

  • Posts: 895
Re: NEW: Tags Library
« Reply #170 on: 24 Feb '15 - 22:13 »
Sorry, I see there's a new post while I was answering.

Tried just now the TagsLibrary_GetAudioFormat() reported 'affMusePack' for an .mpc file. Please post a download link for the file you are having problem with.

I fix the Vorbis bit rate in the next release, sorry.

Please also post a download link for the MP3 file if possible.

3delite

  • Posts: 895
Re: NEW: Tags Library
« Reply #171 on: 24 Feb '15 - 22:19 »
I don't think the Vorbis bit rate needs adjustments. It is reported as the current value, which is more precise then for other formats (it's extracted from the Vorbis header).
If you want to convert to kbps, just divide it by 1000.

EDIT: Or are you using TagsLibrary_GetAudioAttributes() with 'atAutomatic'? Then yes, sorry I fix that for the next release, it should be always reporting kbps. Ok.
« Last Edit: 24 Feb '15 - 22:25 by 3delite »

EWeiss

  • Posts: 342
Re: NEW: Tags Library
« Reply #172 on: 24 Feb '15 - 22:38 »
Quote
I try to fix all that's possible, please understand, it's much code (41200 lines) of course there are bugs in it, sorry for that!
yes sorry ;)

I should give you more time..
i will load latest Version a test again.

Quote
To determine the format of the cover art (to append a proper extension) use the TagsLibrary_GetCoverArt() function before TagsLibrary_GetCoverArtToFile().
is not a Problem and works

Quote
When extracting the cover art to file, you should use the Windows default temp folder: GetTempPath
Append the desired file name to it. Tags Library supports a complete path with file name.
i have do it on my way ;)

Quote
TCoverArtData.PictureFormat reports the format if it's JPEG, PNG, GIF or BMP (these are most common) and you can append the proper extension.
works with StrPtr..

Quote
TMPEGAudioAttributes.ModeExtension is hopefully fixed in the update. If there was no ModeExtension the variable contained a random number (as it was not filled).
yes is fixed, now i can remove my own ckecking for this error.
    
Code: [Select]
If MPGAttributesModeExtension > 0 Then
    MPGAttributesModeExtension = tmpegmeUnknown
End If

Quote
TMPEGAudioAttributes.Header is the raw MPEG header, it seems as a random number when displayed, there's no need to display it, all the information it contains are available from the rest of the structure.
Ok i will remove then from my Sample..

Quote
but I put the demo in the release.
Thank you..

With Int64, working on it is not to simply.

greets
« Last Edit: 25 Feb '15 - 06:07 by EWeiss »

EWeiss

  • Posts: 342
Re: NEW: Tags Library
« Reply #173 on: 25 Feb '15 - 06:01 »
Int64 works now

see Picture
Attach latest Tutorial for VB6


can anyone attach files for all available File Extension to?
so i can add the rest from the Tags Library

greets
« Last Edit: 26 Feb '15 - 00:12 by EWeiss »

Steve Grant

  • Posts: 136
Re: NEW: Tags Library
« Reply #174 on: 25 Feb '15 - 08:52 »
Please find download link for MusePack file. It seems that TagsLib is tagging the file but MP3Tag, dbPA, FB2K cannot see it.

Note that it is recognised as an Mpeg file, the bitrate and the samplerate are wrong. Mp3's are correctly recognised as Mpeg

https://dl.dropboxusercontent.com/s/8if4z9nc3x7xx4d/CD2Track08.mpc?dl=1

Be advised that I ONLY use Automatic for Tags & Attributes.

@Emil I can supply a set of short Jingles in all the formats I support. Would that help?

*.wav;*.flac;*.wv;*.aif;*.ape;;*.ogg;*.mp3;*.aac;*.mp4;*.m4a;*.opus;*.mpc.

https://dl.dropboxusercontent.com/s/40kjjhav55jcyk3/Files.zip?dl=1
« Last Edit: 25 Feb '15 - 09:05 by Steve Grant »