0

i'm using taglib-sharp to read BPM tag in a mp3 music folder. The code is like this:

Dim f As TagLib.File = TagLib.File.Create(File)
Dim bpm As String = f.Tag.BeatsPerMinute 

The files BPM tag contains decimal numbers but the code returns an integer.

What can i do to solve?

  • What datatype is `BeatsPerMinute`? If you look at the Property in the Object Browser, you should be able to see the datatype. – Mary Feb 07 '21 at 18:49
  • Its a UInteger, so a tag value of 190.00 results in a string like 19000. I want to know if exists an option to read the tag like a custom tag, and store the value like a string or decimal and not loose the decimal position. – boisterious Feb 07 '21 at 19:00

1 Answers1

0

I really don't think a value of 190.00 would be possible for an UInteger. It would have to be a whole number. If the number is consistently 100 times higher then just divide by 100.

Private Sub Test()
    Dim i = 19000UI / 100
    Dim bpm = i.ToString("N2")
    Debug.Print(bpm)
End Sub

Private Sub OPCode()
    Dim f As TagLib.File = TagLib.File.Create(File)
    Dim bpm As String = f.Tag.BeatsPerMinute / 100.ToString("N2")
End Sub
Mary
  • 14,926
  • 3
  • 18
  • 27
  • Sorry, my English is very bad and you didn't understand me. The mp3 has a value of 190'00 stored in its "BPM" tag. The code returns 19000. A division by 100 would be valid if all the files had 2 decimals in the "BPM" tag but this is not the case. Some have values with only 1 decimal place or even without them. – boisterious Feb 07 '21 at 20:36
  • @boisterious Can you provide a few more examples of the raw data you are getting back form the `BeatsPerMinute` property? I presume the values are not consistent. – Mary Feb 07 '21 at 22:03
  • In all cases, the value obtained is the one stored in the id3tag but eliminating the decimal separator. In my music library, i have files with values in the "bpm" tag like: xxx or xxx.x or xxx.xx – boisterious Feb 08 '21 at 09:41
  • Temporary solution: recalculate all bpm with MixMeister BPM Analyzer. This application always inserts 2 decimal places. It is then possible to retrieve the label information with BeatsPerMinute and divide by 100. – boisterious Feb 11 '21 at 08:21