Results 1 to 34 of 34

Thread: ID3 Info code that actually works

  1. #1

    Thread Starter
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336

    ID3 Info code that actually works

    Hi all. I have this ID3 code that gets the Khz, Kbps, and Stereo/Mono among other info. But it almost always returns incorrect info. I really dont know where it gets these numbers from(just makes them up i think).


    Does anyone have any ID3 code that really works?


    Thanks!
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  2. #2

    Thread Starter
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    Anyone know?
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  3. #3
    Addicted Member mr_metal_hed's Avatar
    Join Date
    Aug 2002
    Location
    NC
    Posts
    149
    The mp3 information you are after isn't stored in the id3 tag. You have to get information from the mpeg frame and calculate some of it. I think variable bitrates may be causing some calculations to come out wrong, or at least appear wrong. I *had* a module that would get what you are after. I'll see if I can locate it.

  4. #4
    Addicted Member mr_metal_hed's Avatar
    Join Date
    Aug 2002
    Location
    NC
    Posts
    149
    Here's the one I use. I hope it's not the same as the one you are using. Good luck.
    Attached Files Attached Files

  5. #5

    Thread Starter
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    Actually it's not the same bas. But it does give the exact same inccorect bitrate and Freq info.


    Anyone have code that actually works?
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  6. #6
    Addicted Member mr_metal_hed's Avatar
    Join Date
    Aug 2002
    Location
    NC
    Posts
    149
    Are these variable bitrate mp3's? Or do you get bad results for all of your files?

  7. #7

    Thread Starter
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    I have no idea if they are variable bitrate.

    All i know is, the mp3's i am testing the code on are mp3's that i made and recorded and converted. So i know exactly what the bitrate and Freq is. I then test it in Winamp to make double sure. Winamp always returns the correct info.... These Bas's almost never do.


    For instance, i have one mp3 that was converted to mp3 at 32kbps/32000Khz and the Bas returns 256Kbps/64000Khz...
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  8. #8
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    The BitRate depends on a table. If you have the table information wrong... then, it will always answer a wrong bitrate.
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  9. #9
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    VB Code:
    1. 'BitRate
    2.             '           MPEG-1,     MPEG-1,     MPEG-1,     MPEG-2,     MPEG-2,     MPEG-2,
    3.             'Value      layer I     layer II    layer III   layer I     layer II    Layer III
    4.             '0 0 0 0
    5.             '0 0 0 1    32          32          32          32          32          8
    6.             '0 0 1 0    64          48          40          64          48          16
    7.             '0 0 1 1    96          56          48          96          56          24
    8.             '0 1 0 0    128         64          56          128         64          32
    9.             '0 1 0 1    160         80          64          160         80          64
    10.             '0 1 1 0    192         96          80          192         96          80
    11.             '0 1 1 1    224         112         96          224         112         56
    12.             '1 0 0 0    256         128         112         256         128         64
    13.             '1 0 0 1    288         160         128         288         160         128
    14.             '1 0 1 0    320         192         160         320         192         160
    15.             '1 0 1 1    352         224         192         352         224         112
    16.             '1 1 0 0    384         256         224         384         256         128
    17.             '1 1 0 1    416         320         256         416         320         256
    18.             '1 1 1 0    448         384         320         448         384         320
    19.             '1 1 1 1
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  10. #10

    Thread Starter
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    yah, this bas has the right tables... it has all those values, but for some reason its picking the wrong ones..
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  11. #11
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    I can't test it now because I don't have any MP3 on this machine.
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  12. #12
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    Anyway... I've got it working already. Have a look at this:

    http://www.vbforums.com/showthread.p...hlight=bitrate
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  13. #13
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    You forget. Some mp3s don't even have ID tags.

  14. #14
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    Originally posted by DiGiTaIErRoR
    You forget. Some mp3s don't even have ID tags.
    it doesn't mind at all.... the header is not saved in the ID tags.
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  15. #15

    Thread Starter
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    Cool Mcbrain. I could see form the Final Pic in that thread that you figured it out. But you never gave the final code you used to make it work.

    Any chance i could snag that from you ?

    Would really appreciate it Thanks.
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  16. #16
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    Originally posted by Arc
    Cool Mcbrain. I could see form the Final Pic in that thread that you figured it out. But you never gave the final code you used to make it work.

    Any chance i could snag that from you ?

    Would really appreciate it Thanks.
    Yes, I did.. it's all in there. Just read the thread. All you have to do is copy the code, and Bazza's suggestion.
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  17. #17
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    This is the code:

    http://www.vbforums.com/showthread.p...450#post994450

    And you have to change the line: Get #fn, 11 + Len(Tag2), sHeader taking into account Bazza's code:
    VB Code:
    1. For lCount = 1 To 5000
    2.         Get #1, lCount, bHead(0)
    3.         If bHead(0) = 255 Then
    4.             Get #1, lCount + 1, bHead(1)
    5.             If bHead(1) = 250 Or bHead(1) = 251 Then
    6.                 FirstFrame = lCount
    7.                 Exit For
    8.             End If
    9.         End If
    10.     Next lCount
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  18. #18

    Thread Starter
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    Ok, i am trying to follow you here. I see the 2 peices of code but i am not sure how to innertwine them. Since i didnt write the code and havent done much research into decoding MP3 headers i'm not sure exactly what is going on.


    But if i had to guess i would say that where you have the
    VB Code:
    1. Get #fn, 11 + Len(Tag2), sHeader
    2.  
    3.  
    4. I would put
    5.  
    6. For lCount = 1 To 5000
    7.         Get #1, lCount, sHeader(0)
    8.         If sHeader(0) = 255 Then
    9.             Get #1, lCount + 1, sHeader(1)
    10.             If sHeader(1) = 250 Or sHeader(1) = 251 Then
    11.                 FirstFrame = lCount
    12.                 Exit For
    13.             End If
    14.         End If
    15.     Next lCount


    Usualy i am real good at interpretting other peoples code.. but in this case i'm a bit lost.....
    Last edited by Arc; Sep 1st, 2002 at 07:26 PM.
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  19. #19

    Thread Starter
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    Hmm then i was thinking it was that the Bhead() array was trhe Bitrate array, but your Bitrate array id multi dimentional so that can't be it....
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  20. #20
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    Here are the changes:
    VB Code:
    1. Dim bHead(1) As String * 1
    2.         Dim lCount As Integer
    3.         For lCount = 1 To 5000
    4.             Get #fn, lCount, bHead(0)
    5.             If Asc(bHead(0)) = 255 Then
    6.                 Get #fn, lCount + 1, bHead(1)
    7.                 If Asc(bHead(1)) = 250 Or Asc(bHead(1)) = 251 Then
    8.                     lngHeaderPosition = lCount
    9.                     Exit For
    10.                 End If
    11.             End If
    12.         Next lCount
    13.  
    14.         Get #fn, lngHeaderPosition, sHeader
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  21. #21

    Thread Starter
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    I'm sorry man, but those are the chnages to what? That code wasnt in your original code... and i have know idea where that is suppost to go. Do i take out all the Bitrate() Array code? Do i sqeeze it in the middle there somewhere? At the beggining? At the end? I have no idea where that is supposed to go.


    I've tried it several ways and i've gotten several different results...none of which have been accurate..


    This is what i currently have...

    VB Code:
    1. Public Type MP3Header
    2.     MP3Length As Long
    3.     Position As Long
    4.     Duration As Integer
    5.     ID As String
    6.     Layer As String
    7.     SampleRate As String
    8.     Mode As String
    9.     Emphasis As String
    10.     Padding As Boolean
    11.     FrameSize As Long
    12.     FrameCount As Long
    13.     CopyRighted As Boolean
    14.     Original As Boolean
    15.     BitRate As String
    16.     CRC As Boolean
    17. End Type
    18.  
    19.  
    20. Public Version As Byte
    21.  
    22. Public Sub ReadFile(strFilename As String, mHeader As MP3Header)
    23.  
    24.     Static BitRate(11 To 23, 1 To 14) As String
    25.     Dim bHead(1) As String * 1
    26.     Dim lCount As Integer
    27.     Dim fn As Integer
    28.     Dim lngHeaderPosition As Long
    29.     Dim lngFilesize As Long
    30.     Dim BitLine As Integer
    31.     Dim i As Byte
    32.    
    33.     Dim Tag2 As String
    34.     Dim TagSize As String * 4
    35.     Dim ID3Tag As String * 3
    36.     Dim sHeader As String * 4
    37.    
    38. If BitRate(11, 1) = "" Then
    39.         BitRate(11, 1) = "32"
    40.         BitRate(11, 2) = "64"
    41.         BitRate(11, 3) = "96"
    42.         BitRate(11, 4) = "128"
    43.         BitRate(11, 5) = "160"
    44.         BitRate(11, 6) = "192"
    45.         BitRate(11, 7) = "224"
    46.         BitRate(11, 8) = "256"
    47.         BitRate(11, 9) = "288"
    48.         BitRate(11, 10) = "320"
    49.         BitRate(11, 11) = "352"
    50.         BitRate(11, 12) = "384"
    51.         BitRate(11, 13) = "416"
    52.         BitRate(11, 14) = "448"
    53.         BitRate(12, 1) = "32"
    54.         BitRate(12, 2) = "48"
    55.         BitRate(12, 3) = "56"
    56.         BitRate(12, 4) = "64"
    57.         BitRate(12, 5) = "80"
    58.         BitRate(12, 6) = "96"
    59.         BitRate(12, 7) = "112"
    60.         BitRate(12, 8) = "128"
    61.         BitRate(12, 9) = "160"
    62.         BitRate(12, 10) = "192"
    63.         BitRate(12, 11) = "224"
    64.         BitRate(12, 12) = "256"
    65.         BitRate(12, 13) = "320"
    66.         BitRate(12, 14) = "384"
    67.         BitRate(13, 1) = "32"
    68.         BitRate(13, 2) = "40"
    69.         BitRate(13, 3) = "48"
    70.         BitRate(13, 4) = "56"
    71.         BitRate(13, 5) = "64"
    72.         BitRate(13, 6) = "80"
    73.         BitRate(13, 7) = "96"
    74.         BitRate(13, 8) = "112"
    75.         BitRate(13, 9) = "128"
    76.         BitRate(13, 10) = "160"
    77.         BitRate(13, 11) = "192"
    78.         BitRate(13, 12) = "224"
    79.         BitRate(13, 13) = "256"
    80.         BitRate(13, 14) = "320"
    81.         BitRate(21, 1) = "32"
    82.         BitRate(21, 2) = "64"
    83.         BitRate(21, 3) = "96"
    84.         BitRate(21, 4) = "128"
    85.         BitRate(21, 5) = "160"
    86.         BitRate(21, 6) = "192"
    87.         BitRate(21, 7) = "224"
    88.         BitRate(21, 8) = "256"
    89.         BitRate(21, 9) = "288"
    90.         BitRate(21, 10) = "320"
    91.         BitRate(21, 11) = "352"
    92.         BitRate(21, 12) = "384"
    93.         BitRate(21, 13) = "416"
    94.         BitRate(21, 14) = "448"
    95.         BitRate(22, 1) = "32"
    96.         BitRate(22, 2) = "48"
    97.         BitRate(22, 3) = "56"
    98.         BitRate(22, 4) = "64"
    99.         BitRate(22, 5) = "80"
    100.         BitRate(22, 6) = "96"
    101.         BitRate(22, 7) = "112"
    102.         BitRate(22, 8) = "128"
    103.         BitRate(22, 9) = "160"
    104.         BitRate(22, 10) = "192"
    105.         BitRate(22, 11) = "224"
    106.         BitRate(22, 12) = "256"
    107.         BitRate(22, 13) = "320"
    108.         BitRate(22, 14) = "384"
    109.         BitRate(23, 1) = "8"
    110.         BitRate(23, 2) = "16"
    111.         BitRate(23, 3) = "24"
    112.         BitRate(23, 4) = "32"
    113.         BitRate(23, 5) = "64"
    114.         BitRate(23, 6) = "80"
    115.         BitRate(23, 7) = "56"
    116.         BitRate(23, 8) = "64"
    117.         BitRate(23, 9) = "128"
    118.         BitRate(23, 10) = "160"
    119.         BitRate(23, 11) = "112"
    120.         BitRate(23, 12) = "128"
    121.         BitRate(23, 13) = "256"
    122.         BitRate(23, 14) = "320"
    123.     End If
    124.  
    125.    
    126.  
    127.     fn = FreeFile
    128.     Open strFilename For Binary As #1
    129.     lngFilesize = LOF(fn)
    130.          
    131.     Get #fn, 1, ID3Tag
    132.  
    133.  
    134.     If ID3Tag = "ID3" Then
    135.         lngHeaderPosition = 1
    136.         Dim R As Long
    137.         Get #fn, 4, Version
    138.         Get #fn, 7, TagSize
    139.  
    140.         R = CVL(TagSize, 128)
    141.         If R > lngFilesize Or R > 2147483647 Then
    142.             Exit Sub
    143.         End If
    144.         Tag2 = Space$(R)
    145.         Get #fn, 11, Tag2
    146.         lngHeaderPosition = R + 11
    147.     End If
    148.  
    149.  
    150. '#########################
    151. '%%%%%%%%%%%%%%%%%%%
    152. ' I put the new code here
    153.         For lCount = 1 To 5000
    154.             Get #fn, lCount, bHead(0)
    155.             If Asc(bHead(0)) = 255 Then
    156.                 Get #fn, lCount + 1, bHead(1)
    157.                 If Asc(bHead(1)) = 250 Or Asc(bHead(1)) = 251 Then
    158.                     lngHeaderPosition = lCount
    159.                     Exit For
    160.                 End If
    161.             End If
    162.         Next lCount
    163.  
    164.         Get #fn, lngHeaderPosition, sHeader
    165.  
    166. '#########################
    167. '%%%%%%%%%%%%%%%%%%%
    168.  
    169.        
    170.  
    171.        
    172.         With mHeader
    173.             .MP3Length = FileLen(strFilename)
    174.             .Position = 11 + Len(Tag2)
    175.            
    176.             '*** Second Byte ***
    177.             sHeader = Mid$(sHeader, 2)
    178.            
    179.             'MPEG Audio version ID
    180.             '00 - MPEG Version 2.5
    181.             '01 - reserved
    182.             '10 - MPEG Version 2 (ISO/IEC 13818-3)
    183.             '11 - MPEG Version 1 (ISO/IEC 11172-3)
    184.             i = (Asc(sHeader) And 24) / 8
    185.             .ID = IIf(i = 0, "MPEG-2.5", IIf(i = 1, "reserved", _
    186.                  IIf(i = 2, "MPEG-2", "MPEG-1")))
    187.             BitLine = IIf(i = 3, 10, 20)
    188.            
    189.             'Layer description
    190.             '0 0 Not defined
    191.             '0 1 Layer III
    192.             '1 0 Layer II
    193.             '1 1 Layer I
    194.             i = (Asc(sHeader) And 6) / 2
    195.             .Layer = IIf(i = 0, "Not defined", IIf(i = 1, "Layer 3", _
    196.                  IIf(i = 2, "Layer 2", "Layer 1")))
    197.             BitLine = BitLine + (4 - i)
    198.            
    199.             'CRC
    200.             '0 = No
    201.             '1 = Yes
    202.             i = (Asc(sHeader) And 1)
    203.             .CRC = Not (-i)
    204.            
    205.             ' *** Third Byte ***
    206.             sHeader = Mid$(sHeader, 2)
    207.            
    208.              i = (Asc(sHeader) And 240) / 16
    209.             On Error Resume Next
    210.             .BitRate = "Not defined"
    211.             .BitRate = BitRate(BitLine, i) & "kbit"
    212.          
    213.            
    214.             'Frequency
    215.             'value MPEG-1 MPEG-2
    216.             '0 0 44100 Hz 22050 Hz
    217.             '0 1 48000 Hz 24000 Hz
    218.             '1 0 32000 Hz 16000 Hz
    219.             '1 1
    220.             i = (Asc(sHeader) And 12) / 4
    221.             If .ID = "MPEG-1" Then
    222.                 .SampleRate = IIf(i = 0, "44100 Hz", _
    223.                      IIf(i = 1, "48000 Hz", "32000 Hz"))
    224.             Else
    225.                 .SampleRate = IIf(i = 0, "22050 Hz", _
    226.                      IIf(i = 1, "24000 Hz", "16000 Hz"))
    227.             End If
    228.            
    229.             'Padding Bit
    230.             '0 - frame is not padded
    231.             '1 - frame is padded with one extra slot
    232.             i = (Asc(sHeader) And 2) / 2
    233.             .Padding = i
    234.            
    235.             ' *** Forth Byte ***
    236.             sHeader = Mid$(sHeader, 2)
    237.            
    238.             'Mode value mode
    239.             '0 0 Stereo
    240.             '0 1 Joint stereo
    241.             '1 0 Dual channel
    242.             '1 1 Mono
    243.             i = (Asc(sHeader) And 192) / 64
    244.             .Mode = IIf(i = 0, "Stereo", IIf(i = 1, "Joint Stereo", _
    245.                  IIf(i = 2, "Dual channel", "Mono")))
    246.  
    247.             'Copyright
    248.             '0 - Audio is not copyrighted
    249.             '1 - Audio is copyrighted
    250.             i = (Asc(sHeader) And 8) / 8
    251.             .CopyRighted = i
    252.            
    253.             'Original
    254.             '0 - Copy of original media
    255.             '1 - Original media
    256.             i = (Asc(sHeader) And 4) / 4
    257.             .Original = i
    258.            
    259.             'Emphasis value Emphasis method
    260.             '0 0 none
    261.             '0 1 50/15ms
    262.             '1 0
    263.             '1 1 CCITT j.17
    264.             i = (Asc(sHeader) And 3)
    265.             .Emphasis = IIf(i = 0, "None", IIf(i = 1, "50/15ms", _
    266.                  IIf(i = 2, "reserved", "CCITT j.17")))
    267.            
    268.             .FrameSize = IIf(.Layer = "Layer 1", _
    269.                12 * Val(.BitRate) * 1000 \ Val(.SampleRate) - .Padding, _
    270.                144 * Val(.BitRate) * 1000 \ Val(.SampleRate) - .Padding)
    271.                
    272.             .FrameCount = (.MP3Length - .Position - 4) \ .FrameSize
    273.             .Duration = ((.MP3Length - .Position - 4) * 8 \ Val(.BitRate)) / 1000
    274.         End With
    275.         Close
    276. End Sub
    277.  
    278. Public Function CVL(ByVal Cadena As String, Optional Valor As Integer = 256) _
    279.   As Long
    280.     Dim i As Integer
    281.     CVL = 0
    282.    
    283.     For i = 3 To 0 Step -1
    284.         CVL = CVL + (Valor ^ i) * Asc(Cadena)
    285.         Cadena = Mid$(Cadena, 2)
    286.     Next i
    287.    
    288. End Function


    Thanks! For your help
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  22. #22
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    That's exactly where it should be. What's the problem with the code as it is?
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  23. #23

    Thread Starter
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    Well im not getting any errors, its just returning bogus info.

    Its saying this mp3 is at 256Kbps and 64Hz when in reality it is 40Kbps and 22Khz.
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  24. #24
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    Are all the rest values OK? It seems that the BitLine is 13, and the "i" = 13 when it should be 2. Can you debug it and see what's going on with the values....
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  25. #25

    Thread Starter
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    Bitline=13
    i =1


    All the info that is being returned is way off. Its saying the Lenght is 24secs when its really 154secs. Its saying its mono when its stereo etc...

    I'm not sure what else you need me to check.
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  26. #26
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    (13, 1) = 32 not 256. What's what you're getting??

    Anyway... Most probable is that thhçe code is checking wherever but where it should. Check if the Header starts at the same position as it should.... if it's not, that's the cause.
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  27. #27

    Thread Starter
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    Your code is saying Header found at 11 bytes..winamp is saying it was found at 0 bytes
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  28. #28
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    Check the value of the lngHeaderPosition variable.
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  29. #29

    Thread Starter
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    lngHeaderPosition =3773
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  30. #30
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    Ok... I've found that there are some differences with the actual code. Check what happens with this:
    VB Code:
    1. Dim bHead(1) As String * 1
    2.         Dim lCount As Integer
    3.         For lCount = 1 To 5000
    4.             Get #fn, lCount, bHead(0)
    5.             If Asc(bHead(0)) = 255 Then
    6.                 Get #fn, lCount + 1, bHead(1)
    7.                 If Asc(bHead(1)) = 250 Or Asc(bHead(1)) = 251 Then
    8.                     lngHeaderPosition = lCount
    9.                     Exit For
    10.                 End If
    11.             End If
    12.         Next lCount
    13.  
    14.         Get #fn, lngHeaderPosition, sHeader
    15.        
    16.         With mHeader
    17.             .MP3Length = FileLen(strFilename)
    18.             .Position = lngHeaderPosition - 1
    19.            
    20.             '*** Second Byte ***
    21.             sHeader = Mid$(sHeader, 2)
    22.            
    23.             'MPEG Audio version ID
    24.             '00 - MPEG Version 2.5
    25.             '01 - reserved
    26.             '10 - MPEG Version 2 (ISO/IEC 13818-3)
    27.             '11 - MPEG Version 1 (ISO/IEC 11172-3)
    28.             i = (Asc(sHeader) And 24) / 8
    29.             .ID = IIf(i = 0, "MPEG-2.5", IIf(i = 1, "reserved", IIf(i = 2, "MPEG-2", "MPEG-1")))
    30.             BitLine = IIf(i = 3, 10, 20)
    31.            
    32.             'Layer description
    33.             '0 0 Not defined
    34.             '0 1 Layer III
    35.             '1 0 Layer II
    36.             '1 1 Layer I
    37.             i = (Asc(sHeader) And 6) / 2
    38.             .Layer = IIf(i = 0, "Not defined", IIf(i = 1, "Layer 3", IIf(i = 2, "Layer 2", "Layer 1")))
    39.             BitLine = BitLine + (4 - i)
    40.            
    41.             'CRC
    42.             '0 = No
    43.             '1 = Yes
    44.             i = (Asc(sHeader) And 1)
    45.             .CRC = Not (-i)
    46.            
    47.             ' *** Third Byte ***
    48.             sHeader = Mid$(sHeader, 2)
    49.            
    50.             'BitRate
    51.             '           MPEG-1,     MPEG-1,     MPEG-1,     MPEG-2,     MPEG-2,     MPEG-2,
    52.             'Value      layer I     layer II    layer III   layer I     layer II    Layer III
    53.             '0 0 0 0
    54.             '0 0 0 1    32          32          32          32          32          8
    55.             '0 0 1 0    64          48          40          64          48          16
    56.             '0 0 1 1    96          56          48          96          56          24
    57.             '0 1 0 0    128         64          56          128         64          32
    58.             '0 1 0 1    160         80          64          160         80          64
    59.             '0 1 1 0    192         96          80          192         96          80
    60.             '0 1 1 1    224         112         96          224         112         56
    61.             '1 0 0 0    256         128         112         256         128         64
    62.             '1 0 0 1    288         160         128         288         160         128
    63.             '1 0 1 0    320         192         160         320         192         160
    64.             '1 0 1 1    352         224         192         352         224         112
    65.             '1 1 0 0    384         256         224         384         256         128
    66.             '1 1 0 1    416         320         256         416         320         256
    67.             '1 1 1 0    448         384         320         448         384         320
    68.             '1 1 1 1
    69.             i = (Asc(sHeader) And 240) / 16
    70.             On Error Resume Next
    71.             .BitRate = "Not defined"
    72.             .BitRate = BitRate(BitLine, i) & "kbit"
    73.             On Error GoTo errorhandler
    74.            
    75.             'Frequency
    76.             'value MPEG-1 MPEG-2
    77.             '0 0 44100 Hz 22050 Hz
    78.             '0 1 48000 Hz 24000 Hz
    79.             '1 0 32000 Hz 16000 Hz
    80.             '1 1
    81.             i = (Asc(sHeader) And 12) / 4
    82.             If .ID = "MPEG-1" Then
    83.                 .SampleRate = IIf(i = 0, "44100 Hz", IIf(i = 1, "48000 Hz", "32000 Hz"))
    84.             Else
    85.                 .SampleRate = IIf(i = 0, "22050 Hz", IIf(i = 1, "24000 Hz", "16000 Hz"))
    86.             End If
    87.            
    88.             'Padding Bit
    89.             '0 - frame is not padded
    90.             '1 - frame is padded with one extra slot
    91.             i = (Asc(sHeader) And 2) / 2
    92.             .Padding = i
    93.            
    94.             ' *** Forth Byte ***
    95.             sHeader = Mid$(sHeader, 2)
    96.            
    97.             'Mode value mode
    98.             '0 0 Stereo
    99.             '0 1 Joint stereo
    100.             '1 0 Dual channel
    101.             '1 1 Mono
    102.             i = (Asc(sHeader) And 192) / 64
    103.             .Mode = IIf(i = 0, "Stereo", IIf(i = 1, "Joint Stereo", IIf(i = 2, "Dual channel", "Mono")))
    104.  
    105.             'Copyright
    106.             '0 - Audio is not copyrighted
    107.             '1 - Audio is copyrighted
    108.             i = (Asc(sHeader) And 8) / 8
    109.             .CopyRighted = i
    110.            
    111.             'Original
    112.             '0 - Copy of original media
    113.             '1 - Original media
    114.             i = (Asc(sHeader) And 4) / 4
    115.             .Original = i
    116.            
    117.             'Emphasis value Emphasis method
    118.             '0 0 none
    119.             '0 1 50/15ms
    120.             '1 0
    121.             '1 1 CCITT j.17
    122.             i = (Asc(sHeader) And 3)
    123.             .Emphasis = IIf(i = 0, "None", IIf(i = 1, "50/15ms", IIf(i = 2, "reserved", "CCITT j.17")))
    124.            
    125.            
    126.             .FrameSize = IIf(.Layer = "Layer 1", _
    127.                12 * Val(.BitRate) * 1000 \ Val(.SampleRate) - .Padding, _
    128.                144 * Val(.BitRate) * 1000 \ Val(.SampleRate) - .Padding)
    129.                
    130.             .FrameCount = (.MP3Length - .Position - 4) \ .FrameSize
    131.             .Duration = ((.MP3Length - .Position - 4) * 8 \ Val(.BitRate)) / 1000
    132.         End With
    133.         Close
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  31. #31

    Thread Starter
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    Thanks alot for the help man. But it's still returning the same incorrect info. Except now where it says Header position found at.. it says 3772 instead of 11.


    The lngHeaderPosition=3773

    The first time Bitline is accesed it returns 10 and i returns 3

    The second time Bitline = 13 and i = 1


    I would be glad to send you the MP3 i'm using to get these results if you think it would figure this out.


    Thnaks!
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  32. #32
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    Send it to [email protected]
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  33. #33
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    ***?? That MP3 is not MPEG1- Layer 3 as all the MP3s. Maybe that's the reason why it's not reading it properly.

    BTW, my "working code" doesn't work either.
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  34. #34
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    Ok... I found a solution, and not so quite. In this page: http://www.mp3-tech.org/programmer/frame_header.html we can see that the table that I got from another place is wrong.

    Even if I force to start reading the header at 0, it says it's MPEG2-Layer 3 but it says it's 64KB instead of 40KB. This page shows that (if it's correct), the proper value if 40KB (because the byte we get if 5). I'd think that the correct value is this one because Winamp says that also.

    Anyway, I'm still wondering why we got an MPEG2 MP3.
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width