Author Topic: Tags Library  (Read 62660 times)

EWeiss

  • Posts: 342
Re: NEW: Tags Library
« Reply #125 on: 20 Feb '15 - 23:31 »
new Sample code

'Attribute' method. not work
'Attributes' method. work

how why use two function for the self result?

File remove add new on if the DLL error fixed
greets
« Last Edit: 21 Feb '15 - 23:03 by EWeiss »

Steve Grant

  • Posts: 136
Re: NEW: Tags Library
« Reply #126 on: 20 Feb '15 - 23:36 »
This was done for me because all I was getting was 0,0,0,0,0,0 using 'Attributes'. We thought 'Attributes' was not working for me. Anyway I downloaded your first test vbp and you used 'Attribute' in that ok.

Can you download the test files I posted above and report your findings please.

Regards - Steve.

EWeiss

  • Posts: 342
Re: NEW: Tags Library
« Reply #127 on: 20 Feb '15 - 23:47 »
This was done for me because all I was getting was 0,0,0,0,0,0 using 'Attributes'. We thought 'Attributes' was not working for me. Anyway I downloaded your first test vbp and you used 'Attribute' in that ok.

Regards - Steve.

Hmmm Attributes work or not?
Channels wrong..  ::)

See Pictures

Quote
Can you download the test files I posted above and report your findings please.
what your mean?

greets
« Last Edit: 21 Feb '15 - 23:04 by EWeiss »

EWeiss

  • Posts: 342
Re: NEW: Tags Library
« Reply #128 on: 20 Feb '15 - 23:54 »
Quote
Can you download the test files I posted above and report your findings please.
ahh ok ... your file

Channels missing  ::)
the order of Channels, SamplesPerSec and BitsPerSample wrong  ???
should work
type of TAudioAttributes different  ???

Code: [Select]
Public Sub GetAudioAttributes(ByVal AudioType As TAudioType)

Dim AudioAttributes As TAudioAttributes

    TagsLibrary_GetAudioAttributes LngTags, AudioType, VarPtr(AudioAttributes)

    AttributesChannels = AudioAttributes.Channels
    AttributesSamplesPerSec = AudioAttributes.SamplesPerSec
    AttributesBitsPerSample = AudioAttributes.BitsPerSample
    AttributesPlayTime = AudioAttributes.PlayTime
    AttributesSampleCount = AudioAttributes.SampleCount
    AttributesBitrate = AudioAttributes.Bitrate

End Sub

CD2Track08.wv not work all Attributes are 0
« Last Edit: 21 Feb '15 - 23:06 by EWeiss »

3delite

  • Posts: 895
Re: NEW: Tags Library
« Reply #129 on: 21 Feb '15 - 07:19 »
First of all WavPack files are not supported for audio attributes parsing, only the tags, APEv2, ID3v1 and ID3v2 are parsed. I may add this functionality if it's needed, that's why it returns all 0s.

I still not understand what your problem is, I mean I made a little C++ console application one for TagsLibrary_GetAudioAttributes() and one for TagsLibrary_GetAudioAttribute() and both work as expected, although there's a typo in the C++ header, the return value of TagsLibrary_GetAudioAttribute() is a double not a BOOL.
It works fine in Delphi, it works in C++, there must be some problem with the VB header, which I can not test. Steve wrote that a test VB app. works, and only the app. he is working on doesn't work. ???

Please always use the latest version from the first post. The test apps. I posted are built with the latest version, if you use an older version, TagsLibrary_GetAudioAttribute() is not available which will cause the test app. to fail with error loading the .dll.

MPEG (MP3) files are always reported as 32bit, now days everybody should decode MP3s to 32bit mode, as far as I know MP3 doesn't have a bit depth, that's why I decided to always report 32bit.
Also note that sample count is always 0 for MPEG files.

About that attributes mixed up: check that the variable order is the same in the VB header as in TagsLibraryDefs.pas. The C++ test parsed the attributes fine, so again, the VB header must be wrong.  :-\

Steve Grant

  • Posts: 136
Re: NEW: Tags Library
« Reply #130 on: 21 Feb '15 - 09:53 »
Hi 3delite, I may have read you incorrectly but WavPack uses APEv2 tags  ;). As to the problem, the reports I gave above are all from TutorialDLLAudioAttributes1 & TutorialDLLAudioAttributes2. So VB is not involved. I think that if you are going to offer Audio File Attributes, then that should be for all the formats that Tags Library supports!

Now mp3. Mp3's are never decoded to 32bit unless for a special reason (Adobe Audition etc). They are always decoded to the bitdepth of the source and as this is either Redbook CD (16bit) or downloads, the few downloads (41) I have are all 16bit. Decoders may well work in 32bit float internally, but that's not the same thing. Also you will notice that the Bitrate was reported as 128kbps when it should be 193kbps. I will check the variable order again but seem to remember someone getting me to do this before and it was ok. I will report back.

Will you kindly list the formats that Tags Library will currently return valid Attribute(s) data on please.

Steve.

EWeiss

  • Posts: 342
Re: NEW: Tags Library
« Reply #131 on: 21 Feb '15 - 10:21 »
Quote
so again, the VB header must be wrong.

i think your should debug my Sample with Delphi so only you can tell me what is wrong.
i'm developing Bass_Vis with Delphi and make any Header Files also for developer-languages to.

i have no Trouble like you with your DLL. ;)
i have written many Application in VB6 (10 years) and Delphi 2009 to

think your DLL is not written for VB6 on this time.

that should work
'Module
Code: [Select]
Public Type TAudioAttributes
    Channels      As Long                   ' number of channels (i.e. mono, stereo, etc.)
    SamplesPerSec As Long                   ' sample rate
    BitsPerSample As Long                   ' number of bits per sample of mono data
    PlayTime      As Double                 ' duration in seconds
    SampleCount   As Currency               ' number of total samples
    Bitrate       As Long
End Type

'Class
Code: [Select]
Public Sub GetAudioAttributes(ByVal AudioType As TAudioType)

Dim AudioAttributes As TAudioAttributes

    TagsLibrary_GetAudioAttributes LngTags, AudioType, VarPtr(AudioAttributes)

    AttributesChannels = AudioAttributes.Channels
    AttributesSamplesPerSec = AudioAttributes.SamplesPerSec
    AttributesBitsPerSample = AudioAttributes.BitsPerSample
    AttributesPlayTime = AudioAttributes.PlayTime
    AttributesSampleCount = AudioAttributes.SampleCount
    AttributesBitrate = AudioAttributes.Bitrate

End Sub

that is correctly .. result not
I do not want to annoy you
only help

greets
« Last Edit: 21 Feb '15 - 10:25 by EWeiss »

Steve Grant

  • Posts: 136
Re: NEW: Tags Library
« Reply #132 on: 21 Feb '15 - 10:27 »
Here is the comparison of the two type declarations;

Code: [Select]
TAudioAttributes = Record
    Channels: DWord;                    // number of channels (i.e. mono, stereo, etc.)
    SamplesPerSec: DWord;               //sample rate
    BitsPerSample: DWord;               //number of bits per sample of mono data
    PlayTime: Double;
    SampleCount: UInt64;
    BitRate: Integer;
end;

Public Type TAudioAttributes
    Channels      As Long                   ' number of channels (i.e. mono, stereo, etc.)
    SamplesPerSec As Long                   ' sample rate
    BitsPerSample As Long                   ' number of bits per sample of mono data
    PlayTime      As Double                 ' duration in seconds
    SampleCount   As Currency               ' number of total samples
    BitRate       As Long
End Type
Seems ok to me.

Steve.

P.S. I've just realised that you refer the bitdepth to 'MONO' data. Does that mean 32 for Stereo would be 16?? If that is the case (to allow for multi-channel encodes???) then surely the way to present the data is bitdepth/channels.
« Last Edit: 21 Feb '15 - 10:31 by Steve Grant »

EWeiss

  • Posts: 342
Re: NEW: Tags Library
« Reply #133 on: 21 Feb '15 - 10:45 »
Quote
Seems ok to me.
@3delite should debug with my sample after that tell me what is wrong.

here my Application written in VB6 full Winamp Clone
And yes the Bitrate in your Lib is wrong.

greets
« Last Edit: 21 Feb '15 - 10:49 by EWeiss »

Steve Grant

  • Posts: 136
Re: NEW: Tags Library
« Reply #134 on: 21 Feb '15 - 11:07 »
@Emil, I love the look of your WinAmp clone. What are the sliders? Are the transport buttons a bitmap?

Greets

Steve.

Attached is a picture of the main form of my app, which is more geared towards Community/Hospital Radio. This is the Producer version - not for DJ.
« Last Edit: 21 Feb '15 - 11:12 by Steve Grant »

EWeiss

  • Posts: 342
Re: NEW: Tags Library
« Reply #135 on: 21 Feb '15 - 11:20 »
Quote
@Emil, I love the look of your WinAmp clone. What are the sliders? Are the transport buttons a bitmap?

from any Winamp Skin (bmp) called POSBAR.bmp
OK is OT now ;)

@3delite
other test add now ByVal to VarPtr.
Code: [Select]
TagsLibrary_GetAudioAttributes LngTags, AudioType, ByVal VarPtr(AudioAttributes)
after that the first tree Parameter are correctly the rest not!

sorry the source is not yet vb6 compliant
i can nothing more do
« Last Edit: 21 Feb '15 - 14:20 by EWeiss »

EWeiss

  • Posts: 342
Re: NEW: Tags Library
« Reply #136 on: 21 Feb '15 - 14:19 »
using packed Record instead of Record for VB6
So that Delphi doesn't add extra bytes for alignment.
For the record, VB UDTs use exactly the same packing convention as the Windows APIs

TagsLibrary_GetAudioAttribute works after change result Long to Double
TagsLibrary_GetAudioAttributes should work after Change to Packet Record.
VB6 is not Delphi and not C++

the samples in Delphi or C ++ can not be compared with VB6
if it works in C ++ or Delphi does not demand this be so in VB6
type in VB6 = not the same as in Delphi.

greets
« Last Edit: 21 Feb '15 - 14:25 by EWeiss »

EWeiss

  • Posts: 342
Re: NEW: Tags Library
« Reply #137 on: 21 Feb '15 - 15:51 »
Quote
About that attributes mixed up: check that the variable order is the same in the VB header as in TagsLibraryDefs.pas. The C++ test parsed the attributes fine, so again.
Quote
the VB header must be wrong
No your Header and i think not TAudioAttributes alone

what should i say?
i think a Picture say more then a Word

first VB6
second Delphi

your Delphi code never work correctly in collaboration with VB6
change it or leave it ;)

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

3delite

  • Posts: 895
Re: NEW: Tags Library
« Reply #138 on: 22 Feb '15 - 00:06 »
Ah, that explains it. Is there an option in VB to specify a non-packed record? If not I change all the records to packed records.

Here's a new beta version, it adds support of WavPack and MusePack audio attributes: Tags Library 1.0.36.62 beta.zip

Regarding the bit rate for MPEG files, the bit rate value is what the first MPEG frame reports. If the file is VBR then it won't be valid. I really don't want to add scanning of the whole file, as Tags Library is not an audio information library but a tags library.

EWeiss

  • Posts: 342
Re: NEW: Tags Library
« Reply #139 on: 22 Feb '15 - 00:15 »
Ah, that explains it. Is there an option in VB to specify a non-packed record? If not I change all the records to packed records.

Here's a new beta version, it adds support of WavPack and MusePack audio attributes: Tags Library 1.0.36.62 beta.zip

Regarding the bit rate for MPEG files, the bit rate value is what the first MPEG frame reports. If the file is VBR then it won't be valid. I really don't want to add scanning of the whole file, as Tags Library is not an audio information library but a tags library.

WavPack works with TAudioAttribute
thank you

for TAudioAttributes!
no i can not Change the Type Header to Packed record VB used Windows_API without alignment
i have a non-packed record with 32 Bytes
and you should pack it so the length of Record are the same.
 
your should do this in Delph :)

Please upload a File for testing only for TAudioAttributes if is working then Change all other ;)

greets
« Last Edit: 22 Feb '15 - 00:29 by EWeiss »

3delite

  • Posts: 895
Re: NEW: Tags Library
« Reply #140 on: 22 Feb '15 - 00:18 »
Ok thank you!

From the Delphi help:
Quote
Using packed is not a recommended practice, because it can prevent compatibility with other languages or platforms, it slows data access, and, in the case of a character array, it affects type compatibility.

I was aware of this, that's why I avoid using packed records, and only use it when memory usage requires it, but ok, then I change it.

EWeiss

  • Posts: 342
Re: NEW: Tags Library
« Reply #141 on: 22 Feb '15 - 00:23 »
Ok thank you!

From the Delphi help:
Quote
Using packed is not a recommended practice, because it can prevent compatibility with other languages or platforms, it slows data access, and, in the case of a character array, it affects type compatibility.

I was aware of this, that's why I avoid using packed records, and only use it when memory usage requires it, but ok, then I change it.

i have test this with Bass_Vis and no i can not see any different for other language Platforms.
c++,c#,vb.net,Delphi,vb6,powerbasic and so on..
i have no Problem use packed Record for compatibility

greets
« Last Edit: 22 Feb '15 - 00:31 by EWeiss »

3delite

  • Posts: 895
Re: NEW: Tags Library
« Reply #142 on: 22 Feb '15 - 01:11 »
Ok, here's an update with all records packed: Tags Library 1.0.36.63 beta.zip

Please try it and post a working VB header if managed to create one, that I can update the package with, if everything is fine now.

Thank you!

(Upload in progress please try 5 mins later!)

EWeiss

  • Posts: 342
Re: NEW: Tags Library
« Reply #143 on: 22 Feb '15 - 01:23 »
Ok, here's an update with all records packed: Tags Library 1.0.36.63 beta.zip

Please try it and post a working VB header if managed to create one, that I can update the package with, if everything is fine now.

Thank you!

(Upload in progress please try 5 mins later!)

thanks..
i will test it

greets

EWeiss

  • Posts: 342
Re: NEW: Tags Library
« Reply #144 on: 22 Feb '15 - 03:41 »
hmm...  ???

Code: [Select]
Public Declare Function TagsLibrary_GetAudioAttributes Lib "TagsLib.dll" (ByVal Tags As Long, ByVal AudioType As TAudioType, ByRef Attributes As Any) As Long
Code: [Select]
Public Sub GetAudioAttributes(ByVal AudioType As TAudioType)

Dim AudioAttributes As TAudioAttributes

    If AudioType = atAutomatic Then
        TagsLibrary_GetAudioAttributes LngTags, AudioType, AudioAttributes

        AttributesChannels = AudioAttributes.Channels
        AttributesSamplesPerSec = AudioAttributes.SamplesPerSec
        AttributesBitsPerSample = AudioAttributes.BitsPerSample
        AttributesPlayTime = AudioAttributes.PlayTime
        AttributesSampleCount = AudioAttributes.SampleCount
        AttributesBitrate = AudioAttributes.Bitrate
    End If

End Sub

that work.. see Picture

Not work!
Code: [Select]
Public Sub GetMPEGAudioAttributes(ByVal AudioType As TAudioType)

Dim MPGAudioAttributes As TMPEGAudioAttributes

    If AudioType = atMPEG Then
        TagsLibrary_GetAudioAttributes LngTags, AudioType, MPGAudioAttributes

        MPGAttributesPosition = MPGAudioAttributes.Position
        MPGAttributesHeader = MPGAudioAttributes.Header
        MPGAttributesFrameSize = MPGAudioAttributes.FrameSize
        MPGAttributesVersion = MPGAudioAttributes.Version
        MPGAttributesLayer = MPGAudioAttributes.Layer
        MPGAttributesCRC = MPGAudioAttributes.CRC
        MPGAttributesBitrate = MPGAudioAttributes.Bitrate
        MPGAttributesSampleRate = MPGAudioAttributes.SampleRate
        MPGAttributesPadding = MPGAudioAttributes.Padding
        MPGAttributesPrivate_ = MPGAudioAttributes.Private_
        MPGAttributesChannelMode = MPGAudioAttributes.ChannelMode
        MPGAttributesModeExtension = MPGAudioAttributes.ModeExtension
        MPGAttributesCopyrighted = MPGAudioAttributes.Copyrighted
        MPGAttributesOriginal = MPGAudioAttributes.Original
        MPGAttributesEmphasis = MPGAudioAttributes.Emphasis
        MPGAttributesVBR = MPGAudioAttributes.VBR
        MPGAttributesFrameCount = MPGAudioAttributes.FrameCount
        MPGAttributesQuality = MPGAudioAttributes.Quality
        MPGAttributesBytes = MPGAudioAttributes.Bytes
    End If

End Sub

that is hard convert your Def file to VB Header.
i can not see why  :-[  TMPEGAudioAttributes Fails (can you debug my ExeFile with your Lib?)
Add Sample as Attachment

greets
« Last Edit: 23 Feb '15 - 05:06 by EWeiss »

Steve Grant

  • Posts: 136
Re: NEW: Tags Library
« Reply #145 on: 22 Feb '15 - 09:02 »
Hi WavPack now working perfectly for me. Using Emil's last syntax and changing the call to 'ANY'. There is a difference between the Playtimes of different formats. CD2Track08.wav =140.02666666667. - CD2Track08.mp3 =139.412 - CD2Track08.m4a =140.08598. Flac is the same as WavPack. Do you want me to test all the formats?

They all show the correct bitrate except mp3 which is way out! Reported as 128kbps - actually 193kbps. I read that you do not want to have to scan the file, so I wonder how FB2K, MediaInfo and dbPA get the info so accurately and so fast!.

I have removed 'GetAttribute' as 'GetAttributes' is IMHO more elegant. In terms of VB programming, it is obvious that Emil knows a lot more than I. So I will leave all that between you both.

If you or Emil could now show me how to extract the Cover Art from the file and put it into a Picture Box/Image I would be very happy.

Best Regards to you both - Steve.

EWeiss

  • Posts: 342
Re: NEW: Tags Library
« Reply #146 on: 22 Feb '15 - 16:38 »
Hi Steve

i think the best solution is do use my Class.
so do not change any in the VB_API Module of Tags Library

for other question..
think should fixed before all other Problems with  'GetAttributes'
this can do only  3delite, i have not the source so can not Debug for the mistake

PS:
Read Datas from TagsLibrary_GetCoverArt works.

@3delite  question?
which entry from TCoverArtData holds the Data from Picture in Memory so i can Draw it?
if your want that your Lib is compatible to VB6 please check this https://msdn.microsoft.com/en-us/library/aa263420%28v=vs.60%29.aspx
and Change your DataType to that work with VB6 and other Developer.Language to.

Code: [Select]
       For IntI = 0 To Tags.CoverArtCount(ttAutomatic) - 1
            If Tags.GetCoverArt(ttAutomatic, IntI) Then
                Debug.Print Tags.CoverArtName, LPWSTRtoBSTR(Tags.CoverArtName)
                Debug.Print Tags.CoverArtData, VarPtr(Tags.CoverArtData)
                Debug.Print Tags.CoverArtDataSize
                Debug.Print Tags.CoverArtDescription, LPWSTRtoBSTR(Tags.CoverArtDescription)
                Debug.Print Tags.CoverArtCoverType
                Debug.Print Tags.CoverArtMIMEType, LPWSTRtoBSTR(Tags.CoverArtMIMEType)
                Debug.Print Tags.CoverArtPictureFormat, Tags.CoverArtPictureFormatToStr
                Debug.Print Tags.CoverArtWidth
                Debug.Print Tags.CoverArtHeight
                Debug.Print Tags.CoverArtColorDepth
                Debug.Print Tags.CoverArtNoOfColors
                Debug.Print Tags.CoverArtID3v2TextEncoding
                Debug.Print Tags.CoverArtIndex
            End If
        Next

result:

Quote

177181956    Cover art 1
233884624     1634720
6,312
177181996    Folder.jpg
3
177355084    image/jpeg
1            tpfJPEG
0
0
0
0
0
0  


greets
« Last Edit: 22 Feb '15 - 18:57 by EWeiss »

EWeiss

  • Posts: 342
Re: NEW: Tags Library
« Reply #147 on: 22 Feb '15 - 19:13 »
@3delite

anyway..
i think i have found the Trouble with TMPEGAudioAttributes.

Enum in Vb6 allways 4 Byte.
your should also add a dummy Enum to any enumeration that your enum has the same length as in VB6 also 4 Byte

Delphi Enum can has 1, 2 or 4 Byte

Sample.
Code: [Select]
type
     TMPEGVersion = (tmpegvUnknown, tmpegv1, tmpegv2, tmpegv25, tmpegdummy = $FFFFFFFF);


also your enum should have allways 4 Byte or your Record is not compatible to VB6

alternative you can set a switch {$Z4} or {$MINENUMSIZE 4} for Enums, Default is {$Z1} or {$MINENUMSIZE 1} also incompatible to vb6
see  http://docwiki.embarcadero.com/RADStudio/XE7/de/Mindestgröße_für_Enum-Typen_%28Delphi%29

greets
« Last Edit: 22 Feb '15 - 21:06 by EWeiss »

3delite

  • Posts: 895
Re: NEW: Tags Library
« Reply #148 on: 22 Feb '15 - 22:33 »
Ok. Changed all enums to 4 byte.

The package has been updated, available from the first post.

  • Added audio attributes parsing for WavPack and MusePack files
  • Added TagsLibrary_GetTagSize() for the .dll version
  • Added TagsLibrary_GetAudioFormat() and TagsLibrary_GetAudioFormatMemory() functions for the .dll version
  • All records are packed, as needed for VB
  • All enums are 4 bytes
  • Fixed ID3v2 POPM parsing with non-default value

Regarding the cover art strucutre: TCoverArtData.Data contains a pointer to the cover art picture's first byte (the raw picture data, JPEG, PNG, etc.). TCoverArtData.DataSize reports the size of this memory fragment. In Delphi (as in the tutorial), you can transfer this picture bytes into a TStream like this:

Code: [Select]
    PictureStream := TMemoryStream.Create;
    //* Transfer the memory bytes to a TStream
    PictureStream.Write(CoverArtData.Data^, CoverArtData.DataSize);

Please test the new package and tell me how you get on with it (I'm still waiting for a working VB header file though)!

Thank you!

EWeiss

  • Posts: 342
Re: NEW: Tags Library
« Reply #149 on: 22 Feb '15 - 22:37 »
Quote
   PictureStream := TMemoryStream.Create;
    //* Transfer the memory bytes to a TStream
    PictureStream.Write(CoverArtData.Data^, CoverArtData.DataSize);

i can not handle that in VB6 (work also for this later)

Quote
Please test the new package and tell me how you get on with it (I'm still waiting for a working VB header file though)!
i will do it
why your will have the Header?
after finish all mistake you can load my sample and put it to your VB (Tags Library Package)

Quote
The package has been updated, available from the first post.
your mean from your Homepage?

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