|
-
Aug 30th, 2002, 06:46 AM
#1
Thread Starter
PowerPoster
-
Aug 30th, 2002, 11:05 PM
#2
Thread Starter
PowerPoster
-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.

-
Aug 31st, 2002, 03:50 AM
#3
Addicted Member
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.
-
Aug 31st, 2002, 03:59 AM
#4
-
Aug 31st, 2002, 12:13 PM
#5
Thread Starter
PowerPoster
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.

-
Aug 31st, 2002, 12:45 PM
#6
Addicted Member
Are these variable bitrate mp3's? Or do you get bad results for all of your files?
-
Aug 31st, 2002, 09:42 PM
#7
Thread Starter
PowerPoster
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.

-
Aug 31st, 2002, 10:06 PM
#8
-
Aug 31st, 2002, 10:08 PM
#9
Need-a-life Member
VB Code:
'BitRate
' MPEG-1, MPEG-1, MPEG-1, MPEG-2, MPEG-2, MPEG-2,
'Value layer I layer II layer III layer I layer II Layer III
'0 0 0 0
'0 0 0 1 32 32 32 32 32 8
'0 0 1 0 64 48 40 64 48 16
'0 0 1 1 96 56 48 96 56 24
'0 1 0 0 128 64 56 128 64 32
'0 1 0 1 160 80 64 160 80 64
'0 1 1 0 192 96 80 192 96 80
'0 1 1 1 224 112 96 224 112 56
'1 0 0 0 256 128 112 256 128 64
'1 0 0 1 288 160 128 288 160 128
'1 0 1 0 320 192 160 320 192 160
'1 0 1 1 352 224 192 352 224 112
'1 1 0 0 384 256 224 384 256 128
'1 1 0 1 416 320 256 416 320 256
'1 1 1 0 448 384 320 448 384 320
'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.
-
Aug 31st, 2002, 10:58 PM
#10
Thread Starter
PowerPoster
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.

-
Aug 31st, 2002, 11:06 PM
#11
-
Aug 31st, 2002, 11:08 PM
#12
-
Aug 31st, 2002, 11:39 PM
#13
So Unbanned
You forget. Some mp3s don't even have ID tags.
-
Aug 31st, 2002, 11:46 PM
#14
Need-a-life Member
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.
-
Sep 1st, 2002, 10:25 AM
#15
Thread Starter
PowerPoster
-
Sep 1st, 2002, 04:26 PM
#16
Need-a-life Member
-
Sep 1st, 2002, 04:28 PM
#17
Need-a-life Member
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:
For lCount = 1 To 5000
Get #1, lCount, bHead(0)
If bHead(0) = 255 Then
Get #1, lCount + 1, bHead(1)
If bHead(1) = 250 Or bHead(1) = 251 Then
FirstFrame = lCount
Exit For
End If
End If
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.
-
Sep 1st, 2002, 07:21 PM
#18
Thread Starter
PowerPoster
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:
Get #fn, 11 + Len(Tag2), sHeader
I would put
For lCount = 1 To 5000
Get #1, lCount, sHeader(0)
If sHeader(0) = 255 Then
Get #1, lCount + 1, sHeader(1)
If sHeader(1) = 250 Or sHeader(1) = 251 Then
FirstFrame = lCount
Exit For
End If
End If
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.

-
Sep 1st, 2002, 09:49 PM
#19
Thread Starter
PowerPoster
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.

-
Sep 1st, 2002, 10:31 PM
#20
Need-a-life Member
Here are the changes:
VB Code:
Dim bHead(1) As String * 1
Dim lCount As Integer
For lCount = 1 To 5000
Get #fn, lCount, bHead(0)
If Asc(bHead(0)) = 255 Then
Get #fn, lCount + 1, bHead(1)
If Asc(bHead(1)) = 250 Or Asc(bHead(1)) = 251 Then
lngHeaderPosition = lCount
Exit For
End If
End If
Next lCount
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.
-
Sep 1st, 2002, 11:39 PM
#21
Thread Starter
PowerPoster
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:
Public Type MP3Header
MP3Length As Long
Position As Long
Duration As Integer
ID As String
Layer As String
SampleRate As String
Mode As String
Emphasis As String
Padding As Boolean
FrameSize As Long
FrameCount As Long
CopyRighted As Boolean
Original As Boolean
BitRate As String
CRC As Boolean
End Type
Public Version As Byte
Public Sub ReadFile(strFilename As String, mHeader As MP3Header)
Static BitRate(11 To 23, 1 To 14) As String
Dim bHead(1) As String * 1
Dim lCount As Integer
Dim fn As Integer
Dim lngHeaderPosition As Long
Dim lngFilesize As Long
Dim BitLine As Integer
Dim i As Byte
Dim Tag2 As String
Dim TagSize As String * 4
Dim ID3Tag As String * 3
Dim sHeader As String * 4
If BitRate(11, 1) = "" Then
BitRate(11, 1) = "32"
BitRate(11, 2) = "64"
BitRate(11, 3) = "96"
BitRate(11, 4) = "128"
BitRate(11, 5) = "160"
BitRate(11, 6) = "192"
BitRate(11, 7) = "224"
BitRate(11, 8) = "256"
BitRate(11, 9) = "288"
BitRate(11, 10) = "320"
BitRate(11, 11) = "352"
BitRate(11, 12) = "384"
BitRate(11, 13) = "416"
BitRate(11, 14) = "448"
BitRate(12, 1) = "32"
BitRate(12, 2) = "48"
BitRate(12, 3) = "56"
BitRate(12, 4) = "64"
BitRate(12, 5) = "80"
BitRate(12, 6) = "96"
BitRate(12, 7) = "112"
BitRate(12, 8) = "128"
BitRate(12, 9) = "160"
BitRate(12, 10) = "192"
BitRate(12, 11) = "224"
BitRate(12, 12) = "256"
BitRate(12, 13) = "320"
BitRate(12, 14) = "384"
BitRate(13, 1) = "32"
BitRate(13, 2) = "40"
BitRate(13, 3) = "48"
BitRate(13, 4) = "56"
BitRate(13, 5) = "64"
BitRate(13, 6) = "80"
BitRate(13, 7) = "96"
BitRate(13, 8) = "112"
BitRate(13, 9) = "128"
BitRate(13, 10) = "160"
BitRate(13, 11) = "192"
BitRate(13, 12) = "224"
BitRate(13, 13) = "256"
BitRate(13, 14) = "320"
BitRate(21, 1) = "32"
BitRate(21, 2) = "64"
BitRate(21, 3) = "96"
BitRate(21, 4) = "128"
BitRate(21, 5) = "160"
BitRate(21, 6) = "192"
BitRate(21, 7) = "224"
BitRate(21, 8) = "256"
BitRate(21, 9) = "288"
BitRate(21, 10) = "320"
BitRate(21, 11) = "352"
BitRate(21, 12) = "384"
BitRate(21, 13) = "416"
BitRate(21, 14) = "448"
BitRate(22, 1) = "32"
BitRate(22, 2) = "48"
BitRate(22, 3) = "56"
BitRate(22, 4) = "64"
BitRate(22, 5) = "80"
BitRate(22, 6) = "96"
BitRate(22, 7) = "112"
BitRate(22, 8) = "128"
BitRate(22, 9) = "160"
BitRate(22, 10) = "192"
BitRate(22, 11) = "224"
BitRate(22, 12) = "256"
BitRate(22, 13) = "320"
BitRate(22, 14) = "384"
BitRate(23, 1) = "8"
BitRate(23, 2) = "16"
BitRate(23, 3) = "24"
BitRate(23, 4) = "32"
BitRate(23, 5) = "64"
BitRate(23, 6) = "80"
BitRate(23, 7) = "56"
BitRate(23, 8) = "64"
BitRate(23, 9) = "128"
BitRate(23, 10) = "160"
BitRate(23, 11) = "112"
BitRate(23, 12) = "128"
BitRate(23, 13) = "256"
BitRate(23, 14) = "320"
End If
fn = FreeFile
Open strFilename For Binary As #1
lngFilesize = LOF(fn)
Get #fn, 1, ID3Tag
If ID3Tag = "ID3" Then
lngHeaderPosition = 1
Dim R As Long
Get #fn, 4, Version
Get #fn, 7, TagSize
R = CVL(TagSize, 128)
If R > lngFilesize Or R > 2147483647 Then
Exit Sub
End If
Tag2 = Space$(R)
Get #fn, 11, Tag2
lngHeaderPosition = R + 11
End If
'#########################
'%%%%%%%%%%%%%%%%%%%
' I put the new code here
For lCount = 1 To 5000
Get #fn, lCount, bHead(0)
If Asc(bHead(0)) = 255 Then
Get #fn, lCount + 1, bHead(1)
If Asc(bHead(1)) = 250 Or Asc(bHead(1)) = 251 Then
lngHeaderPosition = lCount
Exit For
End If
End If
Next lCount
Get #fn, lngHeaderPosition, sHeader
'#########################
'%%%%%%%%%%%%%%%%%%%
With mHeader
.MP3Length = FileLen(strFilename)
.Position = 11 + Len(Tag2)
'*** Second Byte ***
sHeader = Mid$(sHeader, 2)
'MPEG Audio version ID
'00 - MPEG Version 2.5
'01 - reserved
'10 - MPEG Version 2 (ISO/IEC 13818-3)
'11 - MPEG Version 1 (ISO/IEC 11172-3)
i = (Asc(sHeader) And 24) / 8
.ID = IIf(i = 0, "MPEG-2.5", IIf(i = 1, "reserved", _
IIf(i = 2, "MPEG-2", "MPEG-1")))
BitLine = IIf(i = 3, 10, 20)
'Layer description
'0 0 Not defined
'0 1 Layer III
'1 0 Layer II
'1 1 Layer I
i = (Asc(sHeader) And 6) / 2
.Layer = IIf(i = 0, "Not defined", IIf(i = 1, "Layer 3", _
IIf(i = 2, "Layer 2", "Layer 1")))
BitLine = BitLine + (4 - i)
'CRC
'0 = No
'1 = Yes
i = (Asc(sHeader) And 1)
.CRC = Not (-i)
' *** Third Byte ***
sHeader = Mid$(sHeader, 2)
i = (Asc(sHeader) And 240) / 16
On Error Resume Next
.BitRate = "Not defined"
.BitRate = BitRate(BitLine, i) & "kbit"
'Frequency
'value MPEG-1 MPEG-2
'0 0 44100 Hz 22050 Hz
'0 1 48000 Hz 24000 Hz
'1 0 32000 Hz 16000 Hz
'1 1
i = (Asc(sHeader) And 12) / 4
If .ID = "MPEG-1" Then
.SampleRate = IIf(i = 0, "44100 Hz", _
IIf(i = 1, "48000 Hz", "32000 Hz"))
Else
.SampleRate = IIf(i = 0, "22050 Hz", _
IIf(i = 1, "24000 Hz", "16000 Hz"))
End If
'Padding Bit
'0 - frame is not padded
'1 - frame is padded with one extra slot
i = (Asc(sHeader) And 2) / 2
.Padding = i
' *** Forth Byte ***
sHeader = Mid$(sHeader, 2)
'Mode value mode
'0 0 Stereo
'0 1 Joint stereo
'1 0 Dual channel
'1 1 Mono
i = (Asc(sHeader) And 192) / 64
.Mode = IIf(i = 0, "Stereo", IIf(i = 1, "Joint Stereo", _
IIf(i = 2, "Dual channel", "Mono")))
'Copyright
'0 - Audio is not copyrighted
'1 - Audio is copyrighted
i = (Asc(sHeader) And 8) / 8
.CopyRighted = i
'Original
'0 - Copy of original media
'1 - Original media
i = (Asc(sHeader) And 4) / 4
.Original = i
'Emphasis value Emphasis method
'0 0 none
'0 1 50/15ms
'1 0
'1 1 CCITT j.17
i = (Asc(sHeader) And 3)
.Emphasis = IIf(i = 0, "None", IIf(i = 1, "50/15ms", _
IIf(i = 2, "reserved", "CCITT j.17")))
.FrameSize = IIf(.Layer = "Layer 1", _
12 * Val(.BitRate) * 1000 \ Val(.SampleRate) - .Padding, _
144 * Val(.BitRate) * 1000 \ Val(.SampleRate) - .Padding)
.FrameCount = (.MP3Length - .Position - 4) \ .FrameSize
.Duration = ((.MP3Length - .Position - 4) * 8 \ Val(.BitRate)) / 1000
End With
Close
End Sub
Public Function CVL(ByVal Cadena As String, Optional Valor As Integer = 256) _
As Long
Dim i As Integer
CVL = 0
For i = 3 To 0 Step -1
CVL = CVL + (Valor ^ i) * Asc(Cadena)
Cadena = Mid$(Cadena, 2)
Next i
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.

-
Sep 1st, 2002, 11:47 PM
#22
-
Sep 2nd, 2002, 12:03 AM
#23
Thread Starter
PowerPoster
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.

-
Sep 2nd, 2002, 12:11 AM
#24
-
Sep 2nd, 2002, 12:40 AM
#25
Thread Starter
PowerPoster
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.

-
Sep 2nd, 2002, 06:13 AM
#26
-
Sep 2nd, 2002, 09:03 AM
#27
Thread Starter
PowerPoster
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.

-
Sep 2nd, 2002, 02:48 PM
#28
-
Sep 2nd, 2002, 08:50 PM
#29
Thread Starter
PowerPoster
-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.

-
Sep 2nd, 2002, 10:20 PM
#30
Need-a-life Member
Ok... I've found that there are some differences with the actual code. Check what happens with this:
VB Code:
Dim bHead(1) As String * 1
Dim lCount As Integer
For lCount = 1 To 5000
Get #fn, lCount, bHead(0)
If Asc(bHead(0)) = 255 Then
Get #fn, lCount + 1, bHead(1)
If Asc(bHead(1)) = 250 Or Asc(bHead(1)) = 251 Then
lngHeaderPosition = lCount
Exit For
End If
End If
Next lCount
Get #fn, lngHeaderPosition, sHeader
With mHeader
.MP3Length = FileLen(strFilename)
.Position = lngHeaderPosition - 1
'*** Second Byte ***
sHeader = Mid$(sHeader, 2)
'MPEG Audio version ID
'00 - MPEG Version 2.5
'01 - reserved
'10 - MPEG Version 2 (ISO/IEC 13818-3)
'11 - MPEG Version 1 (ISO/IEC 11172-3)
i = (Asc(sHeader) And 24) / 8
.ID = IIf(i = 0, "MPEG-2.5", IIf(i = 1, "reserved", IIf(i = 2, "MPEG-2", "MPEG-1")))
BitLine = IIf(i = 3, 10, 20)
'Layer description
'0 0 Not defined
'0 1 Layer III
'1 0 Layer II
'1 1 Layer I
i = (Asc(sHeader) And 6) / 2
.Layer = IIf(i = 0, "Not defined", IIf(i = 1, "Layer 3", IIf(i = 2, "Layer 2", "Layer 1")))
BitLine = BitLine + (4 - i)
'CRC
'0 = No
'1 = Yes
i = (Asc(sHeader) And 1)
.CRC = Not (-i)
' *** Third Byte ***
sHeader = Mid$(sHeader, 2)
'BitRate
' MPEG-1, MPEG-1, MPEG-1, MPEG-2, MPEG-2, MPEG-2,
'Value layer I layer II layer III layer I layer II Layer III
'0 0 0 0
'0 0 0 1 32 32 32 32 32 8
'0 0 1 0 64 48 40 64 48 16
'0 0 1 1 96 56 48 96 56 24
'0 1 0 0 128 64 56 128 64 32
'0 1 0 1 160 80 64 160 80 64
'0 1 1 0 192 96 80 192 96 80
'0 1 1 1 224 112 96 224 112 56
'1 0 0 0 256 128 112 256 128 64
'1 0 0 1 288 160 128 288 160 128
'1 0 1 0 320 192 160 320 192 160
'1 0 1 1 352 224 192 352 224 112
'1 1 0 0 384 256 224 384 256 128
'1 1 0 1 416 320 256 416 320 256
'1 1 1 0 448 384 320 448 384 320
'1 1 1 1
i = (Asc(sHeader) And 240) / 16
On Error Resume Next
.BitRate = "Not defined"
.BitRate = BitRate(BitLine, i) & "kbit"
On Error GoTo errorhandler
'Frequency
'value MPEG-1 MPEG-2
'0 0 44100 Hz 22050 Hz
'0 1 48000 Hz 24000 Hz
'1 0 32000 Hz 16000 Hz
'1 1
i = (Asc(sHeader) And 12) / 4
If .ID = "MPEG-1" Then
.SampleRate = IIf(i = 0, "44100 Hz", IIf(i = 1, "48000 Hz", "32000 Hz"))
Else
.SampleRate = IIf(i = 0, "22050 Hz", IIf(i = 1, "24000 Hz", "16000 Hz"))
End If
'Padding Bit
'0 - frame is not padded
'1 - frame is padded with one extra slot
i = (Asc(sHeader) And 2) / 2
.Padding = i
' *** Forth Byte ***
sHeader = Mid$(sHeader, 2)
'Mode value mode
'0 0 Stereo
'0 1 Joint stereo
'1 0 Dual channel
'1 1 Mono
i = (Asc(sHeader) And 192) / 64
.Mode = IIf(i = 0, "Stereo", IIf(i = 1, "Joint Stereo", IIf(i = 2, "Dual channel", "Mono")))
'Copyright
'0 - Audio is not copyrighted
'1 - Audio is copyrighted
i = (Asc(sHeader) And 8) / 8
.CopyRighted = i
'Original
'0 - Copy of original media
'1 - Original media
i = (Asc(sHeader) And 4) / 4
.Original = i
'Emphasis value Emphasis method
'0 0 none
'0 1 50/15ms
'1 0
'1 1 CCITT j.17
i = (Asc(sHeader) And 3)
.Emphasis = IIf(i = 0, "None", IIf(i = 1, "50/15ms", IIf(i = 2, "reserved", "CCITT j.17")))
.FrameSize = IIf(.Layer = "Layer 1", _
12 * Val(.BitRate) * 1000 \ Val(.SampleRate) - .Padding, _
144 * Val(.BitRate) * 1000 \ Val(.SampleRate) - .Padding)
.FrameCount = (.MP3Length - .Position - 4) \ .FrameSize
.Duration = ((.MP3Length - .Position - 4) * 8 \ Val(.BitRate)) / 1000
End With
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.
-
Sep 4th, 2002, 12:06 AM
#31
Thread Starter
PowerPoster
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.

-
Sep 4th, 2002, 12:12 AM
#32
-
Sep 4th, 2002, 06:51 AM
#33
Need-a-life Member
-
Sep 5th, 2002, 06:26 AM
#34
Need-a-life Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|